@@ -8,103 +8,103 @@ |
||
8 | 8 | |
9 | 9 | class ReviewLimits |
10 | 10 | { |
11 | - protected $request; |
|
11 | + protected $request; |
|
12 | 12 | |
13 | - /** |
|
14 | - * @return array |
|
15 | - * @filter site-reviews/get/reviews/query |
|
16 | - */ |
|
17 | - public function filterReviewsQuery(array $parameters, array $args) |
|
18 | - { |
|
19 | - if ($authorId = get_current_user_id()) { |
|
20 | - $parameters['author'] = $authorId; |
|
21 | - } |
|
22 | - $parameters['post_status'] = ['pending', 'publish']; |
|
23 | - return apply_filters('site-reviews/reviews-limits/query', $parameters, $args); |
|
24 | - } |
|
13 | + /** |
|
14 | + * @return array |
|
15 | + * @filter site-reviews/get/reviews/query |
|
16 | + */ |
|
17 | + public function filterReviewsQuery(array $parameters, array $args) |
|
18 | + { |
|
19 | + if ($authorId = get_current_user_id()) { |
|
20 | + $parameters['author'] = $authorId; |
|
21 | + } |
|
22 | + $parameters['post_status'] = ['pending', 'publish']; |
|
23 | + return apply_filters('site-reviews/reviews-limits/query', $parameters, $args); |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * @return bool |
|
28 | - */ |
|
29 | - public function hasReachedLimit(array $request = []) |
|
30 | - { |
|
31 | - $this->request = $request; |
|
32 | - $method = Helper::buildMethodName( |
|
33 | - glsr(OptionManager::class)->get('settings.submissions.limit'), 'validateBy' |
|
34 | - ); |
|
35 | - return method_exists($this, $method) |
|
36 | - ? !call_user_func([$this, $method]) |
|
37 | - : false; |
|
38 | - } |
|
26 | + /** |
|
27 | + * @return bool |
|
28 | + */ |
|
29 | + public function hasReachedLimit(array $request = []) |
|
30 | + { |
|
31 | + $this->request = $request; |
|
32 | + $method = Helper::buildMethodName( |
|
33 | + glsr(OptionManager::class)->get('settings.submissions.limit'), 'validateBy' |
|
34 | + ); |
|
35 | + return method_exists($this, $method) |
|
36 | + ? !call_user_func([$this, $method]) |
|
37 | + : false; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @param string $value |
|
42 | - * @param string $whitelist |
|
43 | - * @return bool |
|
44 | - */ |
|
45 | - public function isWhitelisted($value, $whitelist) |
|
46 | - { |
|
47 | - if (empty($whitelist)) { |
|
48 | - return false; |
|
49 | - } |
|
50 | - return in_array($value, array_filter(explode("\n", $whitelist), 'trim')); |
|
51 | - } |
|
40 | + /** |
|
41 | + * @param string $value |
|
42 | + * @param string $whitelist |
|
43 | + * @return bool |
|
44 | + */ |
|
45 | + public function isWhitelisted($value, $whitelist) |
|
46 | + { |
|
47 | + if (empty($whitelist)) { |
|
48 | + return false; |
|
49 | + } |
|
50 | + return in_array($value, array_filter(explode("\n", $whitelist), 'trim')); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @param string $whitelistName |
|
55 | - * @return string |
|
56 | - */ |
|
57 | - protected function getWhitelist($whitelistName) |
|
58 | - { |
|
59 | - return glsr(OptionManager::class)->get('settings.submissions.limit_whitelist.'.$whitelistName); |
|
60 | - } |
|
53 | + /** |
|
54 | + * @param string $whitelistName |
|
55 | + * @return string |
|
56 | + */ |
|
57 | + protected function getWhitelist($whitelistName) |
|
58 | + { |
|
59 | + return glsr(OptionManager::class)->get('settings.submissions.limit_whitelist.'.$whitelistName); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @return bool |
|
64 | - */ |
|
65 | - protected function validate($key, $value, $addMetaQuery = true) |
|
66 | - { |
|
67 | - if ($this->isWhitelisted($value, $this->getWhitelist($key))) { |
|
68 | - return true; |
|
69 | - } |
|
70 | - add_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5, 2); |
|
71 | - $args = ['assigned_to' => Arr::get($this->request, 'assign_to')]; |
|
72 | - if ($addMetaQuery) { |
|
73 | - $args[$key] = $value; |
|
74 | - } |
|
75 | - $reviews = glsr_get_reviews($args); |
|
76 | - remove_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5); |
|
77 | - return 0 === count($reviews); |
|
78 | - } |
|
62 | + /** |
|
63 | + * @return bool |
|
64 | + */ |
|
65 | + protected function validate($key, $value, $addMetaQuery = true) |
|
66 | + { |
|
67 | + if ($this->isWhitelisted($value, $this->getWhitelist($key))) { |
|
68 | + return true; |
|
69 | + } |
|
70 | + add_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5, 2); |
|
71 | + $args = ['assigned_to' => Arr::get($this->request, 'assign_to')]; |
|
72 | + if ($addMetaQuery) { |
|
73 | + $args[$key] = $value; |
|
74 | + } |
|
75 | + $reviews = glsr_get_reviews($args); |
|
76 | + remove_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5); |
|
77 | + return 0 === count($reviews); |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * @return bool |
|
82 | - */ |
|
83 | - protected function validateByEmail() |
|
84 | - { |
|
85 | - glsr_log()->debug('Email is: '.Arr::get($this->request, 'email')); |
|
86 | - return $this->validate('email', Arr::get($this->request, 'email')); |
|
87 | - } |
|
80 | + /** |
|
81 | + * @return bool |
|
82 | + */ |
|
83 | + protected function validateByEmail() |
|
84 | + { |
|
85 | + glsr_log()->debug('Email is: '.Arr::get($this->request, 'email')); |
|
86 | + return $this->validate('email', Arr::get($this->request, 'email')); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @return bool |
|
91 | - */ |
|
92 | - protected function validateByIpAddress() |
|
93 | - { |
|
94 | - glsr_log()->debug('IP Address is: '.Arr::get($this->request, 'ip_address')); |
|
95 | - return $this->validate('ip_address', Arr::get($this->request, 'ip_address')); |
|
96 | - } |
|
89 | + /** |
|
90 | + * @return bool |
|
91 | + */ |
|
92 | + protected function validateByIpAddress() |
|
93 | + { |
|
94 | + glsr_log()->debug('IP Address is: '.Arr::get($this->request, 'ip_address')); |
|
95 | + return $this->validate('ip_address', Arr::get($this->request, 'ip_address')); |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * @return bool |
|
100 | - */ |
|
101 | - protected function validateByUsername() |
|
102 | - { |
|
103 | - $user = wp_get_current_user(); |
|
104 | - if (!$user->exists()) { |
|
105 | - return true; |
|
106 | - } |
|
107 | - glsr_log()->debug('Username is: '.$user->user_login); |
|
108 | - return $this->validate('username', $user->user_login, false); |
|
109 | - } |
|
98 | + /** |
|
99 | + * @return bool |
|
100 | + */ |
|
101 | + protected function validateByUsername() |
|
102 | + { |
|
103 | + $user = wp_get_current_user(); |
|
104 | + if (!$user->exists()) { |
|
105 | + return true; |
|
106 | + } |
|
107 | + glsr_log()->debug('Username is: '.$user->user_login); |
|
108 | + return $this->validate('username', $user->user_login, false); |
|
109 | + } |
|
110 | 110 | } |
@@ -14,26 +14,26 @@ discard block |
||
14 | 14 | * @return array |
15 | 15 | * @filter site-reviews/get/reviews/query |
16 | 16 | */ |
17 | - public function filterReviewsQuery(array $parameters, array $args) |
|
17 | + public function filterReviewsQuery( array $parameters, array $args ) |
|
18 | 18 | { |
19 | - if ($authorId = get_current_user_id()) { |
|
19 | + if( $authorId = get_current_user_id() ) { |
|
20 | 20 | $parameters['author'] = $authorId; |
21 | 21 | } |
22 | 22 | $parameters['post_status'] = ['pending', 'publish']; |
23 | - return apply_filters('site-reviews/reviews-limits/query', $parameters, $args); |
|
23 | + return apply_filters( 'site-reviews/reviews-limits/query', $parameters, $args ); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
27 | 27 | * @return bool |
28 | 28 | */ |
29 | - public function hasReachedLimit(array $request = []) |
|
29 | + public function hasReachedLimit( array $request = [] ) |
|
30 | 30 | { |
31 | 31 | $this->request = $request; |
32 | 32 | $method = Helper::buildMethodName( |
33 | - glsr(OptionManager::class)->get('settings.submissions.limit'), 'validateBy' |
|
33 | + glsr( OptionManager::class )->get( 'settings.submissions.limit' ), 'validateBy' |
|
34 | 34 | ); |
35 | - return method_exists($this, $method) |
|
36 | - ? !call_user_func([$this, $method]) |
|
35 | + return method_exists( $this, $method ) |
|
36 | + ? !call_user_func( [$this, $method] ) |
|
37 | 37 | : false; |
38 | 38 | } |
39 | 39 | |
@@ -42,39 +42,39 @@ discard block |
||
42 | 42 | * @param string $whitelist |
43 | 43 | * @return bool |
44 | 44 | */ |
45 | - public function isWhitelisted($value, $whitelist) |
|
45 | + public function isWhitelisted( $value, $whitelist ) |
|
46 | 46 | { |
47 | - if (empty($whitelist)) { |
|
47 | + if( empty($whitelist) ) { |
|
48 | 48 | return false; |
49 | 49 | } |
50 | - return in_array($value, array_filter(explode("\n", $whitelist), 'trim')); |
|
50 | + return in_array( $value, array_filter( explode( "\n", $whitelist ), 'trim' ) ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
54 | 54 | * @param string $whitelistName |
55 | 55 | * @return string |
56 | 56 | */ |
57 | - protected function getWhitelist($whitelistName) |
|
57 | + protected function getWhitelist( $whitelistName ) |
|
58 | 58 | { |
59 | - return glsr(OptionManager::class)->get('settings.submissions.limit_whitelist.'.$whitelistName); |
|
59 | + return glsr( OptionManager::class )->get( 'settings.submissions.limit_whitelist.'.$whitelistName ); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
63 | 63 | * @return bool |
64 | 64 | */ |
65 | - protected function validate($key, $value, $addMetaQuery = true) |
|
65 | + protected function validate( $key, $value, $addMetaQuery = true ) |
|
66 | 66 | { |
67 | - if ($this->isWhitelisted($value, $this->getWhitelist($key))) { |
|
67 | + if( $this->isWhitelisted( $value, $this->getWhitelist( $key ) ) ) { |
|
68 | 68 | return true; |
69 | 69 | } |
70 | - add_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5, 2); |
|
71 | - $args = ['assigned_to' => Arr::get($this->request, 'assign_to')]; |
|
72 | - if ($addMetaQuery) { |
|
70 | + add_filter( 'site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5, 2 ); |
|
71 | + $args = ['assigned_to' => Arr::get( $this->request, 'assign_to' )]; |
|
72 | + if( $addMetaQuery ) { |
|
73 | 73 | $args[$key] = $value; |
74 | 74 | } |
75 | - $reviews = glsr_get_reviews($args); |
|
76 | - remove_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5); |
|
77 | - return 0 === count($reviews); |
|
75 | + $reviews = glsr_get_reviews( $args ); |
|
76 | + remove_filter( 'site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5 ); |
|
77 | + return 0 === count( $reviews ); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | */ |
83 | 83 | protected function validateByEmail() |
84 | 84 | { |
85 | - glsr_log()->debug('Email is: '.Arr::get($this->request, 'email')); |
|
86 | - return $this->validate('email', Arr::get($this->request, 'email')); |
|
85 | + glsr_log()->debug( 'Email is: '.Arr::get( $this->request, 'email' ) ); |
|
86 | + return $this->validate( 'email', Arr::get( $this->request, 'email' ) ); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | */ |
92 | 92 | protected function validateByIpAddress() |
93 | 93 | { |
94 | - glsr_log()->debug('IP Address is: '.Arr::get($this->request, 'ip_address')); |
|
95 | - return $this->validate('ip_address', Arr::get($this->request, 'ip_address')); |
|
94 | + glsr_log()->debug( 'IP Address is: '.Arr::get( $this->request, 'ip_address' ) ); |
|
95 | + return $this->validate( 'ip_address', Arr::get( $this->request, 'ip_address' ) ); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | protected function validateByUsername() |
102 | 102 | { |
103 | 103 | $user = wp_get_current_user(); |
104 | - if (!$user->exists()) { |
|
104 | + if( !$user->exists() ) { |
|
105 | 105 | return true; |
106 | 106 | } |
107 | - glsr_log()->debug('Username is: '.$user->user_login); |
|
108 | - return $this->validate('username', $user->user_login, false); |
|
107 | + glsr_log()->debug( 'Username is: '.$user->user_login ); |
|
108 | + return $this->validate( 'username', $user->user_login, false ); |
|
109 | 109 | } |
110 | 110 | } |
@@ -13,248 +13,248 @@ |
||
13 | 13 | |
14 | 14 | abstract class BaseType implements ArrayAccess, JsonSerializable, Type |
15 | 15 | { |
16 | - /** |
|
17 | - * @var array |
|
18 | - */ |
|
19 | - public $allowed = []; |
|
16 | + /** |
|
17 | + * @var array |
|
18 | + */ |
|
19 | + public $allowed = []; |
|
20 | 20 | |
21 | - /** |
|
22 | - * @var array |
|
23 | - */ |
|
24 | - public $parents = []; |
|
21 | + /** |
|
22 | + * @var array |
|
23 | + */ |
|
24 | + public $parents = []; |
|
25 | 25 | |
26 | - /** |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - protected $properties = []; |
|
26 | + /** |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + protected $properties = []; |
|
30 | 30 | |
31 | - /** |
|
32 | - * @var string |
|
33 | - */ |
|
34 | - protected $type; |
|
31 | + /** |
|
32 | + * @var string |
|
33 | + */ |
|
34 | + protected $type; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @param string $method |
|
38 | - * @return static |
|
39 | - */ |
|
40 | - public function __call($method, array $arguments) |
|
41 | - { |
|
42 | - return $this->setProperty($method, Arr::get($arguments, 0)); |
|
43 | - } |
|
36 | + /** |
|
37 | + * @param string $method |
|
38 | + * @return static |
|
39 | + */ |
|
40 | + public function __call($method, array $arguments) |
|
41 | + { |
|
42 | + return $this->setProperty($method, Arr::get($arguments, 0)); |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @param string $type |
|
47 | - */ |
|
48 | - public function __construct($type = null) |
|
49 | - { |
|
50 | - $this->type = !is_string($type) |
|
51 | - ? (new ReflectionClass($this))->getShortName() |
|
52 | - : $type; |
|
53 | - $this->setAllowedProperties(); |
|
54 | - } |
|
45 | + /** |
|
46 | + * @param string $type |
|
47 | + */ |
|
48 | + public function __construct($type = null) |
|
49 | + { |
|
50 | + $this->type = !is_string($type) |
|
51 | + ? (new ReflectionClass($this))->getShortName() |
|
52 | + : $type; |
|
53 | + $this->setAllowedProperties(); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @return string |
|
58 | - */ |
|
59 | - public function __toString() |
|
60 | - { |
|
61 | - return $this->toScript(); |
|
62 | - } |
|
56 | + /** |
|
57 | + * @return string |
|
58 | + */ |
|
59 | + public function __toString() |
|
60 | + { |
|
61 | + return $this->toScript(); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @return static |
|
66 | - */ |
|
67 | - public function addProperties(array $properties) |
|
68 | - { |
|
69 | - foreach ($properties as $property => $value) { |
|
70 | - $this->setProperty($property, $value); |
|
71 | - } |
|
72 | - return $this; |
|
73 | - } |
|
64 | + /** |
|
65 | + * @return static |
|
66 | + */ |
|
67 | + public function addProperties(array $properties) |
|
68 | + { |
|
69 | + foreach ($properties as $property => $value) { |
|
70 | + $this->setProperty($property, $value); |
|
71 | + } |
|
72 | + return $this; |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * @return string |
|
77 | - */ |
|
78 | - public function getContext() |
|
79 | - { |
|
80 | - return 'https://schema.org'; |
|
81 | - } |
|
75 | + /** |
|
76 | + * @return string |
|
77 | + */ |
|
78 | + public function getContext() |
|
79 | + { |
|
80 | + return 'https://schema.org'; |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * @return array |
|
85 | - */ |
|
86 | - public function getProperties() |
|
87 | - { |
|
88 | - return $this->properties; |
|
89 | - } |
|
83 | + /** |
|
84 | + * @return array |
|
85 | + */ |
|
86 | + public function getProperties() |
|
87 | + { |
|
88 | + return $this->properties; |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * @param string $property |
|
93 | - * @param mixed $default |
|
94 | - * @return mixed |
|
95 | - */ |
|
96 | - public function getProperty($property, $default = null) |
|
97 | - { |
|
98 | - return Arr::get($this->properties, $property, $default); |
|
99 | - } |
|
91 | + /** |
|
92 | + * @param string $property |
|
93 | + * @param mixed $default |
|
94 | + * @return mixed |
|
95 | + */ |
|
96 | + public function getProperty($property, $default = null) |
|
97 | + { |
|
98 | + return Arr::get($this->properties, $property, $default); |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * @return string |
|
103 | - */ |
|
104 | - public function getType() |
|
105 | - { |
|
106 | - return $this->type; |
|
107 | - } |
|
101 | + /** |
|
102 | + * @return string |
|
103 | + */ |
|
104 | + public function getType() |
|
105 | + { |
|
106 | + return $this->type; |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * @param bool $condition |
|
111 | - * @param mixed $callback |
|
112 | - * @return static |
|
113 | - */ |
|
114 | - public function doIf($condition, $callback) |
|
115 | - { |
|
116 | - if ($condition) { |
|
117 | - $callback($this); |
|
118 | - } |
|
119 | - return $this; |
|
120 | - } |
|
109 | + /** |
|
110 | + * @param bool $condition |
|
111 | + * @param mixed $callback |
|
112 | + * @return static |
|
113 | + */ |
|
114 | + public function doIf($condition, $callback) |
|
115 | + { |
|
116 | + if ($condition) { |
|
117 | + $callback($this); |
|
118 | + } |
|
119 | + return $this; |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * @return array |
|
124 | - */ |
|
125 | - public function jsonSerialize() |
|
126 | - { |
|
127 | - return $this->toArray(); |
|
128 | - } |
|
122 | + /** |
|
123 | + * @return array |
|
124 | + */ |
|
125 | + public function jsonSerialize() |
|
126 | + { |
|
127 | + return $this->toArray(); |
|
128 | + } |
|
129 | 129 | |
130 | - /** |
|
131 | - * @param mixed $offset |
|
132 | - * @return bool |
|
133 | - */ |
|
134 | - public function offsetExists($offset) |
|
135 | - { |
|
136 | - return array_key_exists($offset, $this->properties); |
|
137 | - } |
|
130 | + /** |
|
131 | + * @param mixed $offset |
|
132 | + * @return bool |
|
133 | + */ |
|
134 | + public function offsetExists($offset) |
|
135 | + { |
|
136 | + return array_key_exists($offset, $this->properties); |
|
137 | + } |
|
138 | 138 | |
139 | - /** |
|
140 | - * @param string $offset |
|
141 | - * @return mixed |
|
142 | - */ |
|
143 | - public function offsetGet($offset) |
|
144 | - { |
|
145 | - return $this->getProperty($offset); |
|
146 | - } |
|
139 | + /** |
|
140 | + * @param string $offset |
|
141 | + * @return mixed |
|
142 | + */ |
|
143 | + public function offsetGet($offset) |
|
144 | + { |
|
145 | + return $this->getProperty($offset); |
|
146 | + } |
|
147 | 147 | |
148 | - /** |
|
149 | - * @param string $offset |
|
150 | - * @param mixed $value |
|
151 | - * @return void |
|
152 | - */ |
|
153 | - public function offsetSet($offset, $value) |
|
154 | - { |
|
155 | - $this->setProperty($offset, $value); |
|
156 | - } |
|
148 | + /** |
|
149 | + * @param string $offset |
|
150 | + * @param mixed $value |
|
151 | + * @return void |
|
152 | + */ |
|
153 | + public function offsetSet($offset, $value) |
|
154 | + { |
|
155 | + $this->setProperty($offset, $value); |
|
156 | + } |
|
157 | 157 | |
158 | - /** |
|
159 | - * @param string $offset |
|
160 | - * @return void |
|
161 | - */ |
|
162 | - public function offsetUnset($offset) |
|
163 | - { |
|
164 | - unset($this->properties[$offset]); |
|
165 | - } |
|
158 | + /** |
|
159 | + * @param string $offset |
|
160 | + * @return void |
|
161 | + */ |
|
162 | + public function offsetUnset($offset) |
|
163 | + { |
|
164 | + unset($this->properties[$offset]); |
|
165 | + } |
|
166 | 166 | |
167 | - /** |
|
168 | - * @param string $property |
|
169 | - * @param mixed $value |
|
170 | - * @return static |
|
171 | - */ |
|
172 | - public function setProperty($property, $value) |
|
173 | - { |
|
174 | - if (!in_array($property, $this->allowed) |
|
175 | - && 'UnknownType' != (new ReflectionClass($this))->getShortName()) { |
|
176 | - glsr_log()->warning($this->getType().' does not allow the "'.$property.'" property'); |
|
177 | - return $this; |
|
178 | - } |
|
179 | - $this->properties[$property] = $value; |
|
180 | - return $this; |
|
181 | - } |
|
167 | + /** |
|
168 | + * @param string $property |
|
169 | + * @param mixed $value |
|
170 | + * @return static |
|
171 | + */ |
|
172 | + public function setProperty($property, $value) |
|
173 | + { |
|
174 | + if (!in_array($property, $this->allowed) |
|
175 | + && 'UnknownType' != (new ReflectionClass($this))->getShortName()) { |
|
176 | + glsr_log()->warning($this->getType().' does not allow the "'.$property.'" property'); |
|
177 | + return $this; |
|
178 | + } |
|
179 | + $this->properties[$property] = $value; |
|
180 | + return $this; |
|
181 | + } |
|
182 | 182 | |
183 | - /** |
|
184 | - * @return array |
|
185 | - */ |
|
186 | - public function toArray() |
|
187 | - { |
|
188 | - return [ |
|
189 | - '@context' => $this->getContext(), |
|
190 | - '@type' => $this->getType(), |
|
191 | - ] + $this->serializeProperty($this->getProperties()); |
|
192 | - } |
|
183 | + /** |
|
184 | + * @return array |
|
185 | + */ |
|
186 | + public function toArray() |
|
187 | + { |
|
188 | + return [ |
|
189 | + '@context' => $this->getContext(), |
|
190 | + '@type' => $this->getType(), |
|
191 | + ] + $this->serializeProperty($this->getProperties()); |
|
192 | + } |
|
193 | 193 | |
194 | - /** |
|
195 | - * @return string |
|
196 | - */ |
|
197 | - public function toScript() |
|
198 | - { |
|
199 | - return sprintf('<script type="application/ld+json">%s</script>', |
|
200 | - json_encode($this->toArray(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) |
|
201 | - ); |
|
202 | - } |
|
194 | + /** |
|
195 | + * @return string |
|
196 | + */ |
|
197 | + public function toScript() |
|
198 | + { |
|
199 | + return sprintf('<script type="application/ld+json">%s</script>', |
|
200 | + json_encode($this->toArray(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) |
|
201 | + ); |
|
202 | + } |
|
203 | 203 | |
204 | - /** |
|
205 | - * @param array|null $parents |
|
206 | - * @return array |
|
207 | - */ |
|
208 | - protected function getParents($parents = null) |
|
209 | - { |
|
210 | - if (!isset($parents)) { |
|
211 | - $parents = $this->parents; |
|
212 | - } |
|
213 | - $newParents = $parents; |
|
214 | - foreach ($parents as $parent) { |
|
215 | - $parentClass = Helper::buildClassName($parent, __NAMESPACE__); |
|
216 | - if (!class_exists($parentClass)) { |
|
217 | - continue; |
|
218 | - } |
|
219 | - $newParents = array_merge($newParents, $this->getParents((new $parentClass())->parents)); |
|
220 | - } |
|
221 | - return array_values(array_unique($newParents)); |
|
222 | - } |
|
204 | + /** |
|
205 | + * @param array|null $parents |
|
206 | + * @return array |
|
207 | + */ |
|
208 | + protected function getParents($parents = null) |
|
209 | + { |
|
210 | + if (!isset($parents)) { |
|
211 | + $parents = $this->parents; |
|
212 | + } |
|
213 | + $newParents = $parents; |
|
214 | + foreach ($parents as $parent) { |
|
215 | + $parentClass = Helper::buildClassName($parent, __NAMESPACE__); |
|
216 | + if (!class_exists($parentClass)) { |
|
217 | + continue; |
|
218 | + } |
|
219 | + $newParents = array_merge($newParents, $this->getParents((new $parentClass())->parents)); |
|
220 | + } |
|
221 | + return array_values(array_unique($newParents)); |
|
222 | + } |
|
223 | 223 | |
224 | - /** |
|
225 | - * @return void |
|
226 | - */ |
|
227 | - protected function setAllowedProperties() |
|
228 | - { |
|
229 | - $parents = $this->getParents(); |
|
230 | - foreach ($parents as $parent) { |
|
231 | - $parentClass = Helper::buildClassName($parent, __NAMESPACE__); |
|
232 | - if (!class_exists($parentClass)) { |
|
233 | - continue; |
|
234 | - } |
|
235 | - $this->allowed = array_values(array_unique(array_merge((new $parentClass())->allowed, $this->allowed))); |
|
236 | - } |
|
237 | - } |
|
224 | + /** |
|
225 | + * @return void |
|
226 | + */ |
|
227 | + protected function setAllowedProperties() |
|
228 | + { |
|
229 | + $parents = $this->getParents(); |
|
230 | + foreach ($parents as $parent) { |
|
231 | + $parentClass = Helper::buildClassName($parent, __NAMESPACE__); |
|
232 | + if (!class_exists($parentClass)) { |
|
233 | + continue; |
|
234 | + } |
|
235 | + $this->allowed = array_values(array_unique(array_merge((new $parentClass())->allowed, $this->allowed))); |
|
236 | + } |
|
237 | + } |
|
238 | 238 | |
239 | - /** |
|
240 | - * @param mixed $property |
|
241 | - * @return array|string |
|
242 | - */ |
|
243 | - protected function serializeProperty($property) |
|
244 | - { |
|
245 | - if (is_array($property)) { |
|
246 | - return array_map([$this, 'serializeProperty'], $property); |
|
247 | - } |
|
248 | - if ($property instanceof Type) { |
|
249 | - $property = $property->toArray(); |
|
250 | - unset($property['@context']); |
|
251 | - } |
|
252 | - if ($property instanceof DateTimeInterface) { |
|
253 | - $property = $property->format(DateTime::ATOM); |
|
254 | - } |
|
255 | - if (is_object($property)) { |
|
256 | - throw new InvalidProperty(); |
|
257 | - } |
|
258 | - return $property; |
|
259 | - } |
|
239 | + /** |
|
240 | + * @param mixed $property |
|
241 | + * @return array|string |
|
242 | + */ |
|
243 | + protected function serializeProperty($property) |
|
244 | + { |
|
245 | + if (is_array($property)) { |
|
246 | + return array_map([$this, 'serializeProperty'], $property); |
|
247 | + } |
|
248 | + if ($property instanceof Type) { |
|
249 | + $property = $property->toArray(); |
|
250 | + unset($property['@context']); |
|
251 | + } |
|
252 | + if ($property instanceof DateTimeInterface) { |
|
253 | + $property = $property->format(DateTime::ATOM); |
|
254 | + } |
|
255 | + if (is_object($property)) { |
|
256 | + throw new InvalidProperty(); |
|
257 | + } |
|
258 | + return $property; |
|
259 | + } |
|
260 | 260 | } |
@@ -37,18 +37,18 @@ discard block |
||
37 | 37 | * @param string $method |
38 | 38 | * @return static |
39 | 39 | */ |
40 | - public function __call($method, array $arguments) |
|
40 | + public function __call( $method, array $arguments ) |
|
41 | 41 | { |
42 | - return $this->setProperty($method, Arr::get($arguments, 0)); |
|
42 | + return $this->setProperty( $method, Arr::get( $arguments, 0 ) ); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @param string $type |
47 | 47 | */ |
48 | - public function __construct($type = null) |
|
48 | + public function __construct( $type = null ) |
|
49 | 49 | { |
50 | - $this->type = !is_string($type) |
|
51 | - ? (new ReflectionClass($this))->getShortName() |
|
50 | + $this->type = !is_string( $type ) |
|
51 | + ? (new ReflectionClass( $this ))->getShortName() |
|
52 | 52 | : $type; |
53 | 53 | $this->setAllowedProperties(); |
54 | 54 | } |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | /** |
65 | 65 | * @return static |
66 | 66 | */ |
67 | - public function addProperties(array $properties) |
|
67 | + public function addProperties( array $properties ) |
|
68 | 68 | { |
69 | - foreach ($properties as $property => $value) { |
|
70 | - $this->setProperty($property, $value); |
|
69 | + foreach( $properties as $property => $value ) { |
|
70 | + $this->setProperty( $property, $value ); |
|
71 | 71 | } |
72 | 72 | return $this; |
73 | 73 | } |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | * @param mixed $default |
94 | 94 | * @return mixed |
95 | 95 | */ |
96 | - public function getProperty($property, $default = null) |
|
96 | + public function getProperty( $property, $default = null ) |
|
97 | 97 | { |
98 | - return Arr::get($this->properties, $property, $default); |
|
98 | + return Arr::get( $this->properties, $property, $default ); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -111,10 +111,10 @@ discard block |
||
111 | 111 | * @param mixed $callback |
112 | 112 | * @return static |
113 | 113 | */ |
114 | - public function doIf($condition, $callback) |
|
114 | + public function doIf( $condition, $callback ) |
|
115 | 115 | { |
116 | - if ($condition) { |
|
117 | - $callback($this); |
|
116 | + if( $condition ) { |
|
117 | + $callback( $this ); |
|
118 | 118 | } |
119 | 119 | return $this; |
120 | 120 | } |
@@ -131,18 +131,18 @@ discard block |
||
131 | 131 | * @param mixed $offset |
132 | 132 | * @return bool |
133 | 133 | */ |
134 | - public function offsetExists($offset) |
|
134 | + public function offsetExists( $offset ) |
|
135 | 135 | { |
136 | - return array_key_exists($offset, $this->properties); |
|
136 | + return array_key_exists( $offset, $this->properties ); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
140 | 140 | * @param string $offset |
141 | 141 | * @return mixed |
142 | 142 | */ |
143 | - public function offsetGet($offset) |
|
143 | + public function offsetGet( $offset ) |
|
144 | 144 | { |
145 | - return $this->getProperty($offset); |
|
145 | + return $this->getProperty( $offset ); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -150,16 +150,16 @@ discard block |
||
150 | 150 | * @param mixed $value |
151 | 151 | * @return void |
152 | 152 | */ |
153 | - public function offsetSet($offset, $value) |
|
153 | + public function offsetSet( $offset, $value ) |
|
154 | 154 | { |
155 | - $this->setProperty($offset, $value); |
|
155 | + $this->setProperty( $offset, $value ); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
159 | 159 | * @param string $offset |
160 | 160 | * @return void |
161 | 161 | */ |
162 | - public function offsetUnset($offset) |
|
162 | + public function offsetUnset( $offset ) |
|
163 | 163 | { |
164 | 164 | unset($this->properties[$offset]); |
165 | 165 | } |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | * @param mixed $value |
170 | 170 | * @return static |
171 | 171 | */ |
172 | - public function setProperty($property, $value) |
|
172 | + public function setProperty( $property, $value ) |
|
173 | 173 | { |
174 | - if (!in_array($property, $this->allowed) |
|
175 | - && 'UnknownType' != (new ReflectionClass($this))->getShortName()) { |
|
176 | - glsr_log()->warning($this->getType().' does not allow the "'.$property.'" property'); |
|
174 | + if( !in_array( $property, $this->allowed ) |
|
175 | + && 'UnknownType' != (new ReflectionClass( $this ))->getShortName() ) { |
|
176 | + glsr_log()->warning( $this->getType().' does not allow the "'.$property.'" property' ); |
|
177 | 177 | return $this; |
178 | 178 | } |
179 | 179 | $this->properties[$property] = $value; |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | return [ |
189 | 189 | '@context' => $this->getContext(), |
190 | 190 | '@type' => $this->getType(), |
191 | - ] + $this->serializeProperty($this->getProperties()); |
|
191 | + ] + $this->serializeProperty( $this->getProperties() ); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -196,8 +196,8 @@ discard block |
||
196 | 196 | */ |
197 | 197 | public function toScript() |
198 | 198 | { |
199 | - return sprintf('<script type="application/ld+json">%s</script>', |
|
200 | - json_encode($this->toArray(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) |
|
199 | + return sprintf( '<script type="application/ld+json">%s</script>', |
|
200 | + json_encode( $this->toArray(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ) |
|
201 | 201 | ); |
202 | 202 | } |
203 | 203 | |
@@ -205,20 +205,20 @@ discard block |
||
205 | 205 | * @param array|null $parents |
206 | 206 | * @return array |
207 | 207 | */ |
208 | - protected function getParents($parents = null) |
|
208 | + protected function getParents( $parents = null ) |
|
209 | 209 | { |
210 | - if (!isset($parents)) { |
|
210 | + if( !isset($parents) ) { |
|
211 | 211 | $parents = $this->parents; |
212 | 212 | } |
213 | 213 | $newParents = $parents; |
214 | - foreach ($parents as $parent) { |
|
215 | - $parentClass = Helper::buildClassName($parent, __NAMESPACE__); |
|
216 | - if (!class_exists($parentClass)) { |
|
214 | + foreach( $parents as $parent ) { |
|
215 | + $parentClass = Helper::buildClassName( $parent, __NAMESPACE__ ); |
|
216 | + if( !class_exists( $parentClass ) ) { |
|
217 | 217 | continue; |
218 | 218 | } |
219 | - $newParents = array_merge($newParents, $this->getParents((new $parentClass())->parents)); |
|
219 | + $newParents = array_merge( $newParents, $this->getParents( (new $parentClass())->parents ) ); |
|
220 | 220 | } |
221 | - return array_values(array_unique($newParents)); |
|
221 | + return array_values( array_unique( $newParents ) ); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | /** |
@@ -227,12 +227,12 @@ discard block |
||
227 | 227 | protected function setAllowedProperties() |
228 | 228 | { |
229 | 229 | $parents = $this->getParents(); |
230 | - foreach ($parents as $parent) { |
|
231 | - $parentClass = Helper::buildClassName($parent, __NAMESPACE__); |
|
232 | - if (!class_exists($parentClass)) { |
|
230 | + foreach( $parents as $parent ) { |
|
231 | + $parentClass = Helper::buildClassName( $parent, __NAMESPACE__ ); |
|
232 | + if( !class_exists( $parentClass ) ) { |
|
233 | 233 | continue; |
234 | 234 | } |
235 | - $this->allowed = array_values(array_unique(array_merge((new $parentClass())->allowed, $this->allowed))); |
|
235 | + $this->allowed = array_values( array_unique( array_merge( (new $parentClass())->allowed, $this->allowed ) ) ); |
|
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
@@ -240,19 +240,19 @@ discard block |
||
240 | 240 | * @param mixed $property |
241 | 241 | * @return array|string |
242 | 242 | */ |
243 | - protected function serializeProperty($property) |
|
243 | + protected function serializeProperty( $property ) |
|
244 | 244 | { |
245 | - if (is_array($property)) { |
|
246 | - return array_map([$this, 'serializeProperty'], $property); |
|
245 | + if( is_array( $property ) ) { |
|
246 | + return array_map( [$this, 'serializeProperty'], $property ); |
|
247 | 247 | } |
248 | - if ($property instanceof Type) { |
|
248 | + if( $property instanceof Type ) { |
|
249 | 249 | $property = $property->toArray(); |
250 | 250 | unset($property['@context']); |
251 | 251 | } |
252 | - if ($property instanceof DateTimeInterface) { |
|
253 | - $property = $property->format(DateTime::ATOM); |
|
252 | + if( $property instanceof DateTimeInterface ) { |
|
253 | + $property = $property->format( DateTime::ATOM ); |
|
254 | 254 | } |
255 | - if (is_object($property)) { |
|
255 | + if( is_object( $property ) ) { |
|
256 | 256 | throw new InvalidProperty(); |
257 | 257 | } |
258 | 258 | return $property; |
@@ -7,73 +7,73 @@ |
||
7 | 7 | |
8 | 8 | abstract class Field |
9 | 9 | { |
10 | - /** |
|
11 | - * @var Builder |
|
12 | - */ |
|
13 | - protected $builder; |
|
10 | + /** |
|
11 | + * @var Builder |
|
12 | + */ |
|
13 | + protected $builder; |
|
14 | 14 | |
15 | - public function __construct(Builder $builder) |
|
16 | - { |
|
17 | - $this->builder = $builder; |
|
18 | - } |
|
15 | + public function __construct(Builder $builder) |
|
16 | + { |
|
17 | + $this->builder = $builder; |
|
18 | + } |
|
19 | 19 | |
20 | - /** |
|
21 | - * @return string|void |
|
22 | - */ |
|
23 | - public function build() |
|
24 | - { |
|
25 | - glsr_log()->error('Build method is not implemented for '.get_class($this)); |
|
26 | - } |
|
20 | + /** |
|
21 | + * @return string|void |
|
22 | + */ |
|
23 | + public function build() |
|
24 | + { |
|
25 | + glsr_log()->error('Build method is not implemented for '.get_class($this)); |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * @return array |
|
30 | - */ |
|
31 | - public static function defaults() |
|
32 | - { |
|
33 | - return []; |
|
34 | - } |
|
28 | + /** |
|
29 | + * @return array |
|
30 | + */ |
|
31 | + public static function defaults() |
|
32 | + { |
|
33 | + return []; |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * @return array |
|
38 | - */ |
|
39 | - public static function merge(array $args) |
|
40 | - { |
|
41 | - $merged = array_merge( |
|
42 | - wp_parse_args($args, static::defaults()), |
|
43 | - static::required() |
|
44 | - ); |
|
45 | - $merged['class'] = implode(' ', static::mergedAttribute('class', ' ', $args)); |
|
46 | - $merged['style'] = implode(';', static::mergedAttribute('style', ';', $args)); |
|
47 | - return $merged; |
|
48 | - } |
|
36 | + /** |
|
37 | + * @return array |
|
38 | + */ |
|
39 | + public static function merge(array $args) |
|
40 | + { |
|
41 | + $merged = array_merge( |
|
42 | + wp_parse_args($args, static::defaults()), |
|
43 | + static::required() |
|
44 | + ); |
|
45 | + $merged['class'] = implode(' ', static::mergedAttribute('class', ' ', $args)); |
|
46 | + $merged['style'] = implode(';', static::mergedAttribute('style', ';', $args)); |
|
47 | + return $merged; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @param string $delimiter |
|
52 | - * @param string $key |
|
53 | - * @return array |
|
54 | - */ |
|
55 | - public static function mergedAttribute($key, $delimiter, array $args) |
|
56 | - { |
|
57 | - return array_filter(array_merge( |
|
58 | - explode($delimiter, Arr::get($args, $key)), |
|
59 | - explode($delimiter, Arr::get(static::defaults(), $key)), |
|
60 | - explode($delimiter, Arr::get(static::required(), $key)) |
|
61 | - )); |
|
62 | - } |
|
50 | + /** |
|
51 | + * @param string $delimiter |
|
52 | + * @param string $key |
|
53 | + * @return array |
|
54 | + */ |
|
55 | + public static function mergedAttribute($key, $delimiter, array $args) |
|
56 | + { |
|
57 | + return array_filter(array_merge( |
|
58 | + explode($delimiter, Arr::get($args, $key)), |
|
59 | + explode($delimiter, Arr::get(static::defaults(), $key)), |
|
60 | + explode($delimiter, Arr::get(static::required(), $key)) |
|
61 | + )); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @return array |
|
66 | - */ |
|
67 | - public static function required() |
|
68 | - { |
|
69 | - return []; |
|
70 | - } |
|
64 | + /** |
|
65 | + * @return array |
|
66 | + */ |
|
67 | + public static function required() |
|
68 | + { |
|
69 | + return []; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @return void |
|
74 | - */ |
|
75 | - protected function mergeFieldArgs() |
|
76 | - { |
|
77 | - $this->builder->args = static::merge($this->builder->args); |
|
78 | - } |
|
72 | + /** |
|
73 | + * @return void |
|
74 | + */ |
|
75 | + protected function mergeFieldArgs() |
|
76 | + { |
|
77 | + $this->builder->args = static::merge($this->builder->args); |
|
78 | + } |
|
79 | 79 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | protected $builder; |
14 | 14 | |
15 | - public function __construct(Builder $builder) |
|
15 | + public function __construct( Builder $builder ) |
|
16 | 16 | { |
17 | 17 | $this->builder = $builder; |
18 | 18 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function build() |
24 | 24 | { |
25 | - glsr_log()->error('Build method is not implemented for '.get_class($this)); |
|
25 | + glsr_log()->error( 'Build method is not implemented for '.get_class( $this ) ); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -36,14 +36,14 @@ discard block |
||
36 | 36 | /** |
37 | 37 | * @return array |
38 | 38 | */ |
39 | - public static function merge(array $args) |
|
39 | + public static function merge( array $args ) |
|
40 | 40 | { |
41 | 41 | $merged = array_merge( |
42 | - wp_parse_args($args, static::defaults()), |
|
42 | + wp_parse_args( $args, static::defaults() ), |
|
43 | 43 | static::required() |
44 | 44 | ); |
45 | - $merged['class'] = implode(' ', static::mergedAttribute('class', ' ', $args)); |
|
46 | - $merged['style'] = implode(';', static::mergedAttribute('style', ';', $args)); |
|
45 | + $merged['class'] = implode( ' ', static::mergedAttribute( 'class', ' ', $args ) ); |
|
46 | + $merged['style'] = implode( ';', static::mergedAttribute( 'style', ';', $args ) ); |
|
47 | 47 | return $merged; |
48 | 48 | } |
49 | 49 | |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | * @param string $key |
53 | 53 | * @return array |
54 | 54 | */ |
55 | - public static function mergedAttribute($key, $delimiter, array $args) |
|
55 | + public static function mergedAttribute( $key, $delimiter, array $args ) |
|
56 | 56 | { |
57 | - return array_filter(array_merge( |
|
58 | - explode($delimiter, Arr::get($args, $key)), |
|
59 | - explode($delimiter, Arr::get(static::defaults(), $key)), |
|
60 | - explode($delimiter, Arr::get(static::required(), $key)) |
|
61 | - )); |
|
57 | + return array_filter( array_merge( |
|
58 | + explode( $delimiter, Arr::get( $args, $key ) ), |
|
59 | + explode( $delimiter, Arr::get( static::defaults(), $key ) ), |
|
60 | + explode( $delimiter, Arr::get( static::required(), $key ) ) |
|
61 | + ) ); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -74,6 +74,6 @@ discard block |
||
74 | 74 | */ |
75 | 75 | protected function mergeFieldArgs() |
76 | 76 | { |
77 | - $this->builder->args = static::merge($this->builder->args); |
|
77 | + $this->builder->args = static::merge( $this->builder->args ); |
|
78 | 78 | } |
79 | 79 | } |
@@ -7,78 +7,78 @@ |
||
7 | 7 | |
8 | 8 | class Template |
9 | 9 | { |
10 | - /** |
|
11 | - * @param string $templatePath |
|
12 | - * @return void|string |
|
13 | - */ |
|
14 | - public function build($templatePath, array $data = []) |
|
15 | - { |
|
16 | - $data = $this->normalize($data); |
|
17 | - ob_start(); |
|
18 | - glsr()->render($templatePath, $data); |
|
19 | - $template = ob_get_clean(); |
|
20 | - $path = Str::removePrefix('templates/', $templatePath); |
|
21 | - $template = apply_filters('site-reviews/build/template/'.$path, $template, $data); |
|
22 | - $template = $this->interpolate($template, $data, $path); |
|
23 | - $template = apply_filters('site-reviews/rendered/template', $template, $templatePath, $data); |
|
24 | - $template = apply_filters('site-reviews/rendered/template/'.$path, $template, $data); |
|
25 | - return $template; |
|
26 | - } |
|
10 | + /** |
|
11 | + * @param string $templatePath |
|
12 | + * @return void|string |
|
13 | + */ |
|
14 | + public function build($templatePath, array $data = []) |
|
15 | + { |
|
16 | + $data = $this->normalize($data); |
|
17 | + ob_start(); |
|
18 | + glsr()->render($templatePath, $data); |
|
19 | + $template = ob_get_clean(); |
|
20 | + $path = Str::removePrefix('templates/', $templatePath); |
|
21 | + $template = apply_filters('site-reviews/build/template/'.$path, $template, $data); |
|
22 | + $template = $this->interpolate($template, $data, $path); |
|
23 | + $template = apply_filters('site-reviews/rendered/template', $template, $templatePath, $data); |
|
24 | + $template = apply_filters('site-reviews/rendered/template/'.$path, $template, $data); |
|
25 | + return $template; |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * Interpolate context values into template placeholders. |
|
30 | - * @param string $template |
|
31 | - * @param string $templatePath |
|
32 | - * @return string |
|
33 | - */ |
|
34 | - public function interpolate($template, array $data = [], $templatePath) |
|
35 | - { |
|
36 | - $context = $this->normalizeContext(Arr::get($data, 'context', [])); |
|
37 | - $context = apply_filters('site-reviews/interpolate/'.$templatePath, $context, $template, $data); |
|
38 | - foreach ($context as $key => $value) { |
|
39 | - $template = strtr( |
|
40 | - $template, |
|
41 | - array_fill_keys(['{'.$key.'}', '{{ '.$key.' }}'], $value) |
|
42 | - ); |
|
43 | - } |
|
44 | - return trim($template); |
|
45 | - } |
|
28 | + /** |
|
29 | + * Interpolate context values into template placeholders. |
|
30 | + * @param string $template |
|
31 | + * @param string $templatePath |
|
32 | + * @return string |
|
33 | + */ |
|
34 | + public function interpolate($template, array $data = [], $templatePath) |
|
35 | + { |
|
36 | + $context = $this->normalizeContext(Arr::get($data, 'context', [])); |
|
37 | + $context = apply_filters('site-reviews/interpolate/'.$templatePath, $context, $template, $data); |
|
38 | + foreach ($context as $key => $value) { |
|
39 | + $template = strtr( |
|
40 | + $template, |
|
41 | + array_fill_keys(['{'.$key.'}', '{{ '.$key.' }}'], $value) |
|
42 | + ); |
|
43 | + } |
|
44 | + return trim($template); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * @param string $templatePath |
|
49 | - * @return void|string |
|
50 | - */ |
|
51 | - public function render($templatePath, array $data = []) |
|
52 | - { |
|
53 | - echo $this->build($templatePath, $data); |
|
54 | - } |
|
47 | + /** |
|
48 | + * @param string $templatePath |
|
49 | + * @return void|string |
|
50 | + */ |
|
51 | + public function render($templatePath, array $data = []) |
|
52 | + { |
|
53 | + echo $this->build($templatePath, $data); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @return array |
|
58 | - */ |
|
59 | - protected function normalize(array $data) |
|
60 | - { |
|
61 | - $arrayKeys = ['context', 'globals']; |
|
62 | - $data = wp_parse_args($data, array_fill_keys($arrayKeys, [])); |
|
63 | - foreach ($arrayKeys as $key) { |
|
64 | - if (is_array($data[$key])) { |
|
65 | - continue; |
|
66 | - } |
|
67 | - $data[$key] = []; |
|
68 | - } |
|
69 | - return $data; |
|
70 | - } |
|
56 | + /** |
|
57 | + * @return array |
|
58 | + */ |
|
59 | + protected function normalize(array $data) |
|
60 | + { |
|
61 | + $arrayKeys = ['context', 'globals']; |
|
62 | + $data = wp_parse_args($data, array_fill_keys($arrayKeys, [])); |
|
63 | + foreach ($arrayKeys as $key) { |
|
64 | + if (is_array($data[$key])) { |
|
65 | + continue; |
|
66 | + } |
|
67 | + $data[$key] = []; |
|
68 | + } |
|
69 | + return $data; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @return array |
|
74 | - */ |
|
75 | - protected function normalizeContext(array $context) |
|
76 | - { |
|
77 | - $context = array_filter($context, function ($value) { |
|
78 | - return !is_array($value) && !is_object($value); |
|
79 | - }); |
|
80 | - return array_map(function ($value) { |
|
81 | - return (string) $value; |
|
82 | - }, $context); |
|
83 | - } |
|
72 | + /** |
|
73 | + * @return array |
|
74 | + */ |
|
75 | + protected function normalizeContext(array $context) |
|
76 | + { |
|
77 | + $context = array_filter($context, function ($value) { |
|
78 | + return !is_array($value) && !is_object($value); |
|
79 | + }); |
|
80 | + return array_map(function ($value) { |
|
81 | + return (string) $value; |
|
82 | + }, $context); |
|
83 | + } |
|
84 | 84 | } |
@@ -11,17 +11,17 @@ discard block |
||
11 | 11 | * @param string $templatePath |
12 | 12 | * @return void|string |
13 | 13 | */ |
14 | - public function build($templatePath, array $data = []) |
|
14 | + public function build( $templatePath, array $data = [] ) |
|
15 | 15 | { |
16 | - $data = $this->normalize($data); |
|
16 | + $data = $this->normalize( $data ); |
|
17 | 17 | ob_start(); |
18 | - glsr()->render($templatePath, $data); |
|
18 | + glsr()->render( $templatePath, $data ); |
|
19 | 19 | $template = ob_get_clean(); |
20 | - $path = Str::removePrefix('templates/', $templatePath); |
|
21 | - $template = apply_filters('site-reviews/build/template/'.$path, $template, $data); |
|
22 | - $template = $this->interpolate($template, $data, $path); |
|
23 | - $template = apply_filters('site-reviews/rendered/template', $template, $templatePath, $data); |
|
24 | - $template = apply_filters('site-reviews/rendered/template/'.$path, $template, $data); |
|
20 | + $path = Str::removePrefix( 'templates/', $templatePath ); |
|
21 | + $template = apply_filters( 'site-reviews/build/template/'.$path, $template, $data ); |
|
22 | + $template = $this->interpolate( $template, $data, $path ); |
|
23 | + $template = apply_filters( 'site-reviews/rendered/template', $template, $templatePath, $data ); |
|
24 | + $template = apply_filters( 'site-reviews/rendered/template/'.$path, $template, $data ); |
|
25 | 25 | return $template; |
26 | 26 | } |
27 | 27 | |
@@ -31,37 +31,37 @@ discard block |
||
31 | 31 | * @param string $templatePath |
32 | 32 | * @return string |
33 | 33 | */ |
34 | - public function interpolate($template, array $data = [], $templatePath) |
|
34 | + public function interpolate( $template, array $data = [], $templatePath ) |
|
35 | 35 | { |
36 | - $context = $this->normalizeContext(Arr::get($data, 'context', [])); |
|
37 | - $context = apply_filters('site-reviews/interpolate/'.$templatePath, $context, $template, $data); |
|
38 | - foreach ($context as $key => $value) { |
|
36 | + $context = $this->normalizeContext( Arr::get( $data, 'context', [] ) ); |
|
37 | + $context = apply_filters( 'site-reviews/interpolate/'.$templatePath, $context, $template, $data ); |
|
38 | + foreach( $context as $key => $value ) { |
|
39 | 39 | $template = strtr( |
40 | 40 | $template, |
41 | - array_fill_keys(['{'.$key.'}', '{{ '.$key.' }}'], $value) |
|
41 | + array_fill_keys( ['{'.$key.'}', '{{ '.$key.' }}'], $value ) |
|
42 | 42 | ); |
43 | 43 | } |
44 | - return trim($template); |
|
44 | + return trim( $template ); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
48 | 48 | * @param string $templatePath |
49 | 49 | * @return void|string |
50 | 50 | */ |
51 | - public function render($templatePath, array $data = []) |
|
51 | + public function render( $templatePath, array $data = [] ) |
|
52 | 52 | { |
53 | - echo $this->build($templatePath, $data); |
|
53 | + echo $this->build( $templatePath, $data ); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
57 | 57 | * @return array |
58 | 58 | */ |
59 | - protected function normalize(array $data) |
|
59 | + protected function normalize( array $data ) |
|
60 | 60 | { |
61 | 61 | $arrayKeys = ['context', 'globals']; |
62 | - $data = wp_parse_args($data, array_fill_keys($arrayKeys, [])); |
|
63 | - foreach ($arrayKeys as $key) { |
|
64 | - if (is_array($data[$key])) { |
|
62 | + $data = wp_parse_args( $data, array_fill_keys( $arrayKeys, [] ) ); |
|
63 | + foreach( $arrayKeys as $key ) { |
|
64 | + if( is_array( $data[$key] ) ) { |
|
65 | 65 | continue; |
66 | 66 | } |
67 | 67 | $data[$key] = []; |
@@ -72,13 +72,13 @@ discard block |
||
72 | 72 | /** |
73 | 73 | * @return array |
74 | 74 | */ |
75 | - protected function normalizeContext(array $context) |
|
75 | + protected function normalizeContext( array $context ) |
|
76 | 76 | { |
77 | - $context = array_filter($context, function ($value) { |
|
78 | - return !is_array($value) && !is_object($value); |
|
77 | + $context = array_filter( $context, function( $value ) { |
|
78 | + return !is_array( $value ) && !is_object( $value ); |
|
79 | 79 | }); |
80 | - return array_map(function ($value) { |
|
81 | - return (string) $value; |
|
82 | - }, $context); |
|
80 | + return array_map( function( $value ) { |
|
81 | + return (string)$value; |
|
82 | + }, $context ); |
|
83 | 83 | } |
84 | 84 | } |
@@ -8,160 +8,160 @@ |
||
8 | 8 | |
9 | 9 | class Upgrade_3_0_0 |
10 | 10 | { |
11 | - const MAPPED_SETTINGS = [ |
|
12 | - 'settings.general.notification' => 'settings.general.notifications', // array |
|
13 | - 'settings.general.notification_email' => 'settings.general.notification_email', |
|
14 | - 'settings.general.notification_message' => 'settings.general.notification_message', |
|
15 | - 'settings.general.require.approval' => 'settings.general.require.approval', |
|
16 | - 'settings.general.require.login' => 'settings.general.require.login', |
|
17 | - 'settings.general.require.login_register' => 'settings.general.require.login_register', |
|
18 | - 'settings.general.webhook_url' => 'settings.general.notification_slack', |
|
19 | - 'settings.reviews-form.akismet' => 'settings.submissions.akismet', |
|
20 | - 'settings.reviews-form.blacklist.action' => 'settings.submissions.blacklist.action', |
|
21 | - 'settings.reviews-form.blacklist.entries' => 'settings.submissions.blacklist.entries', |
|
22 | - 'settings.reviews-form.recaptcha.integration' => 'settings.submissions.recaptcha.integration', |
|
23 | - 'settings.reviews-form.recaptcha.key' => 'settings.submissions.recaptcha.key', |
|
24 | - 'settings.reviews-form.recaptcha.position' => 'settings.submissions.recaptcha.position', |
|
25 | - 'settings.reviews-form.recaptcha.secret' => 'settings.submissions.recaptcha.secret', |
|
26 | - 'settings.reviews-form.required' => 'settings.submissions.required', // array |
|
27 | - 'settings.reviews.assigned_links.enabled' => 'settings.reviews.assigned_links', |
|
28 | - 'settings.reviews.avatars.enabled' => 'settings.reviews.avatars', |
|
29 | - 'settings.reviews.date.custom' => 'settings.reviews.date.custom', |
|
30 | - 'settings.reviews.date.format' => 'settings.reviews.date.format', |
|
31 | - 'settings.reviews.excerpt.enabled' => 'settings.reviews.excerpts', |
|
32 | - 'settings.reviews.excerpt.length' => 'settings.reviews.excerpts_length', |
|
33 | - 'settings.reviews.schema.address' => 'settings.schema.address', |
|
34 | - 'settings.reviews.schema.description.custom' => 'settings.schema.description.custom', |
|
35 | - 'settings.reviews.schema.description.default' => 'settings.schema.description.default', |
|
36 | - 'settings.reviews.schema.highprice' => 'settings.schema.highprice', |
|
37 | - 'settings.reviews.schema.image.custom' => 'settings.schema.image.custom', |
|
38 | - 'settings.reviews.schema.image.default' => 'settings.schema.image.default', |
|
39 | - 'settings.reviews.schema.lowprice' => 'settings.schema.lowprice', |
|
40 | - 'settings.reviews.schema.name.custom' => 'settings.schema.name.custom', |
|
41 | - 'settings.reviews.schema.name.default' => 'settings.schema.name.default', |
|
42 | - 'settings.reviews.schema.pricecurrency' => 'settings.schema.pricecurrency', |
|
43 | - 'settings.reviews.schema.pricerange' => 'settings.schema.pricerange', |
|
44 | - 'settings.reviews.schema.telephone' => 'settings.schema.telephone', |
|
45 | - 'settings.reviews.schema.type.custom' => 'settings.schema.type.custom', |
|
46 | - 'settings.reviews.schema.type.default' => 'settings.schema.type.default', |
|
47 | - 'settings.reviews.schema.url.custom' => 'settings.schema.url.custom', |
|
48 | - 'settings.reviews.schema.url.default' => 'settings.schema.url.default', |
|
49 | - 'version' => 'version_upgraded_from', |
|
50 | - ]; |
|
11 | + const MAPPED_SETTINGS = [ |
|
12 | + 'settings.general.notification' => 'settings.general.notifications', // array |
|
13 | + 'settings.general.notification_email' => 'settings.general.notification_email', |
|
14 | + 'settings.general.notification_message' => 'settings.general.notification_message', |
|
15 | + 'settings.general.require.approval' => 'settings.general.require.approval', |
|
16 | + 'settings.general.require.login' => 'settings.general.require.login', |
|
17 | + 'settings.general.require.login_register' => 'settings.general.require.login_register', |
|
18 | + 'settings.general.webhook_url' => 'settings.general.notification_slack', |
|
19 | + 'settings.reviews-form.akismet' => 'settings.submissions.akismet', |
|
20 | + 'settings.reviews-form.blacklist.action' => 'settings.submissions.blacklist.action', |
|
21 | + 'settings.reviews-form.blacklist.entries' => 'settings.submissions.blacklist.entries', |
|
22 | + 'settings.reviews-form.recaptcha.integration' => 'settings.submissions.recaptcha.integration', |
|
23 | + 'settings.reviews-form.recaptcha.key' => 'settings.submissions.recaptcha.key', |
|
24 | + 'settings.reviews-form.recaptcha.position' => 'settings.submissions.recaptcha.position', |
|
25 | + 'settings.reviews-form.recaptcha.secret' => 'settings.submissions.recaptcha.secret', |
|
26 | + 'settings.reviews-form.required' => 'settings.submissions.required', // array |
|
27 | + 'settings.reviews.assigned_links.enabled' => 'settings.reviews.assigned_links', |
|
28 | + 'settings.reviews.avatars.enabled' => 'settings.reviews.avatars', |
|
29 | + 'settings.reviews.date.custom' => 'settings.reviews.date.custom', |
|
30 | + 'settings.reviews.date.format' => 'settings.reviews.date.format', |
|
31 | + 'settings.reviews.excerpt.enabled' => 'settings.reviews.excerpts', |
|
32 | + 'settings.reviews.excerpt.length' => 'settings.reviews.excerpts_length', |
|
33 | + 'settings.reviews.schema.address' => 'settings.schema.address', |
|
34 | + 'settings.reviews.schema.description.custom' => 'settings.schema.description.custom', |
|
35 | + 'settings.reviews.schema.description.default' => 'settings.schema.description.default', |
|
36 | + 'settings.reviews.schema.highprice' => 'settings.schema.highprice', |
|
37 | + 'settings.reviews.schema.image.custom' => 'settings.schema.image.custom', |
|
38 | + 'settings.reviews.schema.image.default' => 'settings.schema.image.default', |
|
39 | + 'settings.reviews.schema.lowprice' => 'settings.schema.lowprice', |
|
40 | + 'settings.reviews.schema.name.custom' => 'settings.schema.name.custom', |
|
41 | + 'settings.reviews.schema.name.default' => 'settings.schema.name.default', |
|
42 | + 'settings.reviews.schema.pricecurrency' => 'settings.schema.pricecurrency', |
|
43 | + 'settings.reviews.schema.pricerange' => 'settings.schema.pricerange', |
|
44 | + 'settings.reviews.schema.telephone' => 'settings.schema.telephone', |
|
45 | + 'settings.reviews.schema.type.custom' => 'settings.schema.type.custom', |
|
46 | + 'settings.reviews.schema.type.default' => 'settings.schema.type.default', |
|
47 | + 'settings.reviews.schema.url.custom' => 'settings.schema.url.custom', |
|
48 | + 'settings.reviews.schema.url.default' => 'settings.schema.url.default', |
|
49 | + 'version' => 'version_upgraded_from', |
|
50 | + ]; |
|
51 | 51 | |
52 | - /** |
|
53 | - * @var array |
|
54 | - */ |
|
55 | - protected $newSettings; |
|
52 | + /** |
|
53 | + * @var array |
|
54 | + */ |
|
55 | + protected $newSettings; |
|
56 | 56 | |
57 | - /** |
|
58 | - * @var array |
|
59 | - */ |
|
60 | - protected $oldSettings; |
|
57 | + /** |
|
58 | + * @var array |
|
59 | + */ |
|
60 | + protected $oldSettings; |
|
61 | 61 | |
62 | - public function __construct() |
|
63 | - { |
|
64 | - $this->migrateSettings(); |
|
65 | - } |
|
62 | + public function __construct() |
|
63 | + { |
|
64 | + $this->migrateSettings(); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * @return void |
|
69 | - */ |
|
70 | - public function migrateSettings() |
|
71 | - { |
|
72 | - $this->newSettings = $this->getNewSettings(); |
|
73 | - $this->oldSettings = $this->getOldSettings(); |
|
74 | - if (empty($this->oldSettings)) { |
|
75 | - return; |
|
76 | - } |
|
77 | - foreach (static::MAPPED_SETTINGS as $old => $new) { |
|
78 | - if (empty($this->oldSettings[$old])) { |
|
79 | - continue; |
|
80 | - } |
|
81 | - $this->newSettings[$new] = $this->oldSettings[$old]; |
|
82 | - } |
|
83 | - $this->migrateNotificationSettings(); |
|
84 | - $this->migrateRecaptchaSettings(); |
|
85 | - $this->migrateRequiredSettings(); |
|
86 | - $oldSettings = Arr::convertDotNotationArray($this->oldSettings); |
|
87 | - $newSettings = Arr::convertDotNotationArray($this->newSettings); |
|
88 | - if (isset($oldSettings['settings']['strings']) && is_array($oldSettings['settings']['strings'])) { |
|
89 | - $newSettings['settings']['strings'] = $oldSettings['settings']['strings']; |
|
90 | - } |
|
91 | - glsr(OptionManager::class)->set($newSettings); |
|
92 | - } |
|
67 | + /** |
|
68 | + * @return void |
|
69 | + */ |
|
70 | + public function migrateSettings() |
|
71 | + { |
|
72 | + $this->newSettings = $this->getNewSettings(); |
|
73 | + $this->oldSettings = $this->getOldSettings(); |
|
74 | + if (empty($this->oldSettings)) { |
|
75 | + return; |
|
76 | + } |
|
77 | + foreach (static::MAPPED_SETTINGS as $old => $new) { |
|
78 | + if (empty($this->oldSettings[$old])) { |
|
79 | + continue; |
|
80 | + } |
|
81 | + $this->newSettings[$new] = $this->oldSettings[$old]; |
|
82 | + } |
|
83 | + $this->migrateNotificationSettings(); |
|
84 | + $this->migrateRecaptchaSettings(); |
|
85 | + $this->migrateRequiredSettings(); |
|
86 | + $oldSettings = Arr::convertDotNotationArray($this->oldSettings); |
|
87 | + $newSettings = Arr::convertDotNotationArray($this->newSettings); |
|
88 | + if (isset($oldSettings['settings']['strings']) && is_array($oldSettings['settings']['strings'])) { |
|
89 | + $newSettings['settings']['strings'] = $oldSettings['settings']['strings']; |
|
90 | + } |
|
91 | + glsr(OptionManager::class)->set($newSettings); |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * @return array |
|
96 | - */ |
|
97 | - protected function getNewSettings() |
|
98 | - { |
|
99 | - return wp_parse_args( |
|
100 | - Arr::flattenArray(glsr(OptionManager::class)->all()), |
|
101 | - glsr(DefaultsManager::class)->defaults() |
|
102 | - ); |
|
103 | - } |
|
94 | + /** |
|
95 | + * @return array |
|
96 | + */ |
|
97 | + protected function getNewSettings() |
|
98 | + { |
|
99 | + return wp_parse_args( |
|
100 | + Arr::flattenArray(glsr(OptionManager::class)->all()), |
|
101 | + glsr(DefaultsManager::class)->defaults() |
|
102 | + ); |
|
103 | + } |
|
104 | 104 | |
105 | - /** |
|
106 | - * @return array |
|
107 | - */ |
|
108 | - protected function getOldSettings() |
|
109 | - { |
|
110 | - $defaults = array_fill_keys(array_keys(static::MAPPED_SETTINGS), ''); |
|
111 | - $settings = Arr::flattenArray((array) get_option('geminilabs_site_reviews-v2', [])); |
|
112 | - if (!empty($settings)) { |
|
113 | - $settings = wp_parse_args($settings, $defaults); |
|
114 | - } |
|
115 | - return $settings; |
|
116 | - } |
|
105 | + /** |
|
106 | + * @return array |
|
107 | + */ |
|
108 | + protected function getOldSettings() |
|
109 | + { |
|
110 | + $defaults = array_fill_keys(array_keys(static::MAPPED_SETTINGS), ''); |
|
111 | + $settings = Arr::flattenArray((array) get_option('geminilabs_site_reviews-v2', [])); |
|
112 | + if (!empty($settings)) { |
|
113 | + $settings = wp_parse_args($settings, $defaults); |
|
114 | + } |
|
115 | + return $settings; |
|
116 | + } |
|
117 | 117 | |
118 | - /** |
|
119 | - * @return void |
|
120 | - */ |
|
121 | - protected function migrateNotificationSettings() |
|
122 | - { |
|
123 | - $notifications = [ |
|
124 | - 'custom' => 'custom', |
|
125 | - 'default' => 'admin', |
|
126 | - 'webhook' => 'slack', |
|
127 | - ]; |
|
128 | - $this->newSettings['settings.general.notifications'] = []; |
|
129 | - foreach ($notifications as $old => $new) { |
|
130 | - if ($this->oldSettings['settings.general.notification'] != $old) { |
|
131 | - continue; |
|
132 | - } |
|
133 | - $this->newSettings['settings.general.notifications'][] = $new; |
|
134 | - } |
|
135 | - } |
|
118 | + /** |
|
119 | + * @return void |
|
120 | + */ |
|
121 | + protected function migrateNotificationSettings() |
|
122 | + { |
|
123 | + $notifications = [ |
|
124 | + 'custom' => 'custom', |
|
125 | + 'default' => 'admin', |
|
126 | + 'webhook' => 'slack', |
|
127 | + ]; |
|
128 | + $this->newSettings['settings.general.notifications'] = []; |
|
129 | + foreach ($notifications as $old => $new) { |
|
130 | + if ($this->oldSettings['settings.general.notification'] != $old) { |
|
131 | + continue; |
|
132 | + } |
|
133 | + $this->newSettings['settings.general.notifications'][] = $new; |
|
134 | + } |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * @return void |
|
139 | - */ |
|
140 | - protected function migrateRecaptchaSettings() |
|
141 | - { |
|
142 | - $recaptcha = [ |
|
143 | - 'BadgePosition' => $this->oldSettings['settings.reviews-form.recaptcha.position'], |
|
144 | - 'SecretKey' => $this->oldSettings['settings.reviews-form.recaptcha.secret'], |
|
145 | - 'SiteKey' => $this->oldSettings['settings.reviews-form.recaptcha.key'], |
|
146 | - ]; |
|
147 | - if (in_array($this->oldSettings['settings.reviews-form.recaptcha.integration'], ['custom', 'invisible-recaptcha'])) { |
|
148 | - $this->newSettings['settings.submissions.recaptcha.integration'] = 'all'; |
|
149 | - } |
|
150 | - if ('invisible-recaptcha' == $this->oldSettings['settings.reviews-form.recaptcha.integration']) { |
|
151 | - $recaptcha = wp_parse_args((array) get_site_option('ic-settings', [], false), $recaptcha); |
|
152 | - } |
|
153 | - $this->newSettings['settings.submissions.recaptcha.key'] = $recaptcha['SiteKey']; |
|
154 | - $this->newSettings['settings.submissions.recaptcha.secret'] = $recaptcha['SecretKey']; |
|
155 | - $this->newSettings['settings.submissions.recaptcha.position'] = $recaptcha['BadgePosition']; |
|
156 | - } |
|
137 | + /** |
|
138 | + * @return void |
|
139 | + */ |
|
140 | + protected function migrateRecaptchaSettings() |
|
141 | + { |
|
142 | + $recaptcha = [ |
|
143 | + 'BadgePosition' => $this->oldSettings['settings.reviews-form.recaptcha.position'], |
|
144 | + 'SecretKey' => $this->oldSettings['settings.reviews-form.recaptcha.secret'], |
|
145 | + 'SiteKey' => $this->oldSettings['settings.reviews-form.recaptcha.key'], |
|
146 | + ]; |
|
147 | + if (in_array($this->oldSettings['settings.reviews-form.recaptcha.integration'], ['custom', 'invisible-recaptcha'])) { |
|
148 | + $this->newSettings['settings.submissions.recaptcha.integration'] = 'all'; |
|
149 | + } |
|
150 | + if ('invisible-recaptcha' == $this->oldSettings['settings.reviews-form.recaptcha.integration']) { |
|
151 | + $recaptcha = wp_parse_args((array) get_site_option('ic-settings', [], false), $recaptcha); |
|
152 | + } |
|
153 | + $this->newSettings['settings.submissions.recaptcha.key'] = $recaptcha['SiteKey']; |
|
154 | + $this->newSettings['settings.submissions.recaptcha.secret'] = $recaptcha['SecretKey']; |
|
155 | + $this->newSettings['settings.submissions.recaptcha.position'] = $recaptcha['BadgePosition']; |
|
156 | + } |
|
157 | 157 | |
158 | - /** |
|
159 | - * @return void |
|
160 | - */ |
|
161 | - protected function migrateRequiredSettings() |
|
162 | - { |
|
163 | - $this->newSettings['settings.submissions.required'] = array_filter((array) $this->oldSettings['settings.reviews-form.required']); |
|
164 | - $this->newSettings['settings.submissions.required'][] = 'rating'; |
|
165 | - $this->newSettings['settings.submissions.required'][] = 'terms'; |
|
166 | - } |
|
158 | + /** |
|
159 | + * @return void |
|
160 | + */ |
|
161 | + protected function migrateRequiredSettings() |
|
162 | + { |
|
163 | + $this->newSettings['settings.submissions.required'] = array_filter((array) $this->oldSettings['settings.reviews-form.required']); |
|
164 | + $this->newSettings['settings.submissions.required'][] = 'rating'; |
|
165 | + $this->newSettings['settings.submissions.required'][] = 'terms'; |
|
166 | + } |
|
167 | 167 | } |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | { |
72 | 72 | $this->newSettings = $this->getNewSettings(); |
73 | 73 | $this->oldSettings = $this->getOldSettings(); |
74 | - if (empty($this->oldSettings)) { |
|
74 | + if( empty($this->oldSettings) ) { |
|
75 | 75 | return; |
76 | 76 | } |
77 | - foreach (static::MAPPED_SETTINGS as $old => $new) { |
|
78 | - if (empty($this->oldSettings[$old])) { |
|
77 | + foreach( static::MAPPED_SETTINGS as $old => $new ) { |
|
78 | + if( empty($this->oldSettings[$old]) ) { |
|
79 | 79 | continue; |
80 | 80 | } |
81 | 81 | $this->newSettings[$new] = $this->oldSettings[$old]; |
@@ -83,12 +83,12 @@ discard block |
||
83 | 83 | $this->migrateNotificationSettings(); |
84 | 84 | $this->migrateRecaptchaSettings(); |
85 | 85 | $this->migrateRequiredSettings(); |
86 | - $oldSettings = Arr::convertDotNotationArray($this->oldSettings); |
|
87 | - $newSettings = Arr::convertDotNotationArray($this->newSettings); |
|
88 | - if (isset($oldSettings['settings']['strings']) && is_array($oldSettings['settings']['strings'])) { |
|
86 | + $oldSettings = Arr::convertDotNotationArray( $this->oldSettings ); |
|
87 | + $newSettings = Arr::convertDotNotationArray( $this->newSettings ); |
|
88 | + if( isset($oldSettings['settings']['strings']) && is_array( $oldSettings['settings']['strings'] ) ) { |
|
89 | 89 | $newSettings['settings']['strings'] = $oldSettings['settings']['strings']; |
90 | 90 | } |
91 | - glsr(OptionManager::class)->set($newSettings); |
|
91 | + glsr( OptionManager::class )->set( $newSettings ); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | protected function getNewSettings() |
98 | 98 | { |
99 | 99 | return wp_parse_args( |
100 | - Arr::flattenArray(glsr(OptionManager::class)->all()), |
|
101 | - glsr(DefaultsManager::class)->defaults() |
|
100 | + Arr::flattenArray( glsr( OptionManager::class )->all() ), |
|
101 | + glsr( DefaultsManager::class )->defaults() |
|
102 | 102 | ); |
103 | 103 | } |
104 | 104 | |
@@ -107,10 +107,10 @@ discard block |
||
107 | 107 | */ |
108 | 108 | protected function getOldSettings() |
109 | 109 | { |
110 | - $defaults = array_fill_keys(array_keys(static::MAPPED_SETTINGS), ''); |
|
111 | - $settings = Arr::flattenArray((array) get_option('geminilabs_site_reviews-v2', [])); |
|
112 | - if (!empty($settings)) { |
|
113 | - $settings = wp_parse_args($settings, $defaults); |
|
110 | + $defaults = array_fill_keys( array_keys( static::MAPPED_SETTINGS ), '' ); |
|
111 | + $settings = Arr::flattenArray( (array)get_option( 'geminilabs_site_reviews-v2', [] ) ); |
|
112 | + if( !empty($settings) ) { |
|
113 | + $settings = wp_parse_args( $settings, $defaults ); |
|
114 | 114 | } |
115 | 115 | return $settings; |
116 | 116 | } |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | 'webhook' => 'slack', |
127 | 127 | ]; |
128 | 128 | $this->newSettings['settings.general.notifications'] = []; |
129 | - foreach ($notifications as $old => $new) { |
|
130 | - if ($this->oldSettings['settings.general.notification'] != $old) { |
|
129 | + foreach( $notifications as $old => $new ) { |
|
130 | + if( $this->oldSettings['settings.general.notification'] != $old ) { |
|
131 | 131 | continue; |
132 | 132 | } |
133 | 133 | $this->newSettings['settings.general.notifications'][] = $new; |
@@ -144,11 +144,11 @@ discard block |
||
144 | 144 | 'SecretKey' => $this->oldSettings['settings.reviews-form.recaptcha.secret'], |
145 | 145 | 'SiteKey' => $this->oldSettings['settings.reviews-form.recaptcha.key'], |
146 | 146 | ]; |
147 | - if (in_array($this->oldSettings['settings.reviews-form.recaptcha.integration'], ['custom', 'invisible-recaptcha'])) { |
|
147 | + if( in_array( $this->oldSettings['settings.reviews-form.recaptcha.integration'], ['custom', 'invisible-recaptcha'] ) ) { |
|
148 | 148 | $this->newSettings['settings.submissions.recaptcha.integration'] = 'all'; |
149 | 149 | } |
150 | - if ('invisible-recaptcha' == $this->oldSettings['settings.reviews-form.recaptcha.integration']) { |
|
151 | - $recaptcha = wp_parse_args((array) get_site_option('ic-settings', [], false), $recaptcha); |
|
150 | + if( 'invisible-recaptcha' == $this->oldSettings['settings.reviews-form.recaptcha.integration'] ) { |
|
151 | + $recaptcha = wp_parse_args( (array)get_site_option( 'ic-settings', [], false ), $recaptcha ); |
|
152 | 152 | } |
153 | 153 | $this->newSettings['settings.submissions.recaptcha.key'] = $recaptcha['SiteKey']; |
154 | 154 | $this->newSettings['settings.submissions.recaptcha.secret'] = $recaptcha['SecretKey']; |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | */ |
161 | 161 | protected function migrateRequiredSettings() |
162 | 162 | { |
163 | - $this->newSettings['settings.submissions.required'] = array_filter((array) $this->oldSettings['settings.reviews-form.required']); |
|
163 | + $this->newSettings['settings.submissions.required'] = array_filter( (array)$this->oldSettings['settings.reviews-form.required'] ); |
|
164 | 164 | $this->newSettings['settings.submissions.required'][] = 'rating'; |
165 | 165 | $this->newSettings['settings.submissions.required'][] = 'terms'; |
166 | 166 | } |
@@ -12,144 +12,144 @@ |
||
12 | 12 | |
13 | 13 | class Style |
14 | 14 | { |
15 | - /** |
|
16 | - * @var array |
|
17 | - */ |
|
18 | - public $fields; |
|
15 | + /** |
|
16 | + * @var array |
|
17 | + */ |
|
18 | + public $fields; |
|
19 | 19 | |
20 | - /** |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - public $style; |
|
20 | + /** |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + public $style; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @var array |
|
27 | - */ |
|
28 | - public $pagination; |
|
25 | + /** |
|
26 | + * @var array |
|
27 | + */ |
|
28 | + public $pagination; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @var array |
|
32 | - */ |
|
33 | - public $validation; |
|
30 | + /** |
|
31 | + * @var array |
|
32 | + */ |
|
33 | + public $validation; |
|
34 | 34 | |
35 | - public function __construct() |
|
36 | - { |
|
37 | - $this->style = glsr(OptionManager::class)->get('settings.general.style', 'default'); |
|
38 | - $this->setConfig(); |
|
39 | - } |
|
35 | + public function __construct() |
|
36 | + { |
|
37 | + $this->style = glsr(OptionManager::class)->get('settings.general.style', 'default'); |
|
38 | + $this->setConfig(); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param string $view |
|
43 | - * @return string |
|
44 | - */ |
|
45 | - public function filterView($view) |
|
46 | - { |
|
47 | - $styledViews = [ |
|
48 | - 'templates/form/field', |
|
49 | - 'templates/form/response', |
|
50 | - 'templates/form/submit-button', |
|
51 | - 'templates/reviews-form', |
|
52 | - ]; |
|
53 | - if (!preg_match('('.implode('|', $styledViews).')', $view)) { |
|
54 | - return $view; |
|
55 | - } |
|
56 | - $views = $this->generatePossibleViews($view); |
|
57 | - foreach ($views as $possibleView) { |
|
58 | - if (!file_exists(glsr()->file($possibleView))) { |
|
59 | - continue; |
|
60 | - } |
|
61 | - return Str::removePrefix('views/', $possibleView); |
|
62 | - } |
|
63 | - return $view; |
|
64 | - } |
|
41 | + /** |
|
42 | + * @param string $view |
|
43 | + * @return string |
|
44 | + */ |
|
45 | + public function filterView($view) |
|
46 | + { |
|
47 | + $styledViews = [ |
|
48 | + 'templates/form/field', |
|
49 | + 'templates/form/response', |
|
50 | + 'templates/form/submit-button', |
|
51 | + 'templates/reviews-form', |
|
52 | + ]; |
|
53 | + if (!preg_match('('.implode('|', $styledViews).')', $view)) { |
|
54 | + return $view; |
|
55 | + } |
|
56 | + $views = $this->generatePossibleViews($view); |
|
57 | + foreach ($views as $possibleView) { |
|
58 | + if (!file_exists(glsr()->file($possibleView))) { |
|
59 | + continue; |
|
60 | + } |
|
61 | + return Str::removePrefix('views/', $possibleView); |
|
62 | + } |
|
63 | + return $view; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @return string |
|
68 | - */ |
|
69 | - public function get() |
|
70 | - { |
|
71 | - return apply_filters('site-reviews/style', $this->style); |
|
72 | - } |
|
66 | + /** |
|
67 | + * @return string |
|
68 | + */ |
|
69 | + public function get() |
|
70 | + { |
|
71 | + return apply_filters('site-reviews/style', $this->style); |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return array |
|
76 | - */ |
|
77 | - public function setConfig() |
|
78 | - { |
|
79 | - $config = shortcode_atts( |
|
80 | - array_fill_keys(['fields', 'pagination', 'validation'], []), |
|
81 | - glsr()->config('styles/'.$this->style) |
|
82 | - ); |
|
83 | - $this->fields = glsr(StyleFieldsDefaults::class)->restrict($config['fields']); |
|
84 | - $this->pagination = glsr(PaginationDefaults::class)->restrict($config['pagination']); |
|
85 | - $this->validation = glsr(StyleValidationDefaults::class)->restrict($config['validation']); |
|
86 | - } |
|
74 | + /** |
|
75 | + * @return array |
|
76 | + */ |
|
77 | + public function setConfig() |
|
78 | + { |
|
79 | + $config = shortcode_atts( |
|
80 | + array_fill_keys(['fields', 'pagination', 'validation'], []), |
|
81 | + glsr()->config('styles/'.$this->style) |
|
82 | + ); |
|
83 | + $this->fields = glsr(StyleFieldsDefaults::class)->restrict($config['fields']); |
|
84 | + $this->pagination = glsr(PaginationDefaults::class)->restrict($config['pagination']); |
|
85 | + $this->validation = glsr(StyleValidationDefaults::class)->restrict($config['validation']); |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * @return void |
|
90 | - */ |
|
91 | - public function modifyField(Builder $instance) |
|
92 | - { |
|
93 | - if (!$this->isPublicInstance($instance) || empty(array_filter($this->fields))) { |
|
94 | - return; |
|
95 | - } |
|
96 | - call_user_func_array([$this, 'customize'], [$instance]); |
|
97 | - } |
|
88 | + /** |
|
89 | + * @return void |
|
90 | + */ |
|
91 | + public function modifyField(Builder $instance) |
|
92 | + { |
|
93 | + if (!$this->isPublicInstance($instance) || empty(array_filter($this->fields))) { |
|
94 | + return; |
|
95 | + } |
|
96 | + call_user_func_array([$this, 'customize'], [$instance]); |
|
97 | + } |
|
98 | 98 | |
99 | - /** |
|
100 | - * @return array |
|
101 | - */ |
|
102 | - public function paginationArgs(array $args) |
|
103 | - { |
|
104 | - return wp_parse_args($args, $this->pagination); |
|
105 | - } |
|
99 | + /** |
|
100 | + * @return array |
|
101 | + */ |
|
102 | + public function paginationArgs(array $args) |
|
103 | + { |
|
104 | + return wp_parse_args($args, $this->pagination); |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * @return void |
|
109 | - */ |
|
110 | - protected function customize(Builder $instance) |
|
111 | - { |
|
112 | - if (!array_key_exists($instance->tag, $this->fields)) { |
|
113 | - return; |
|
114 | - } |
|
115 | - $args = wp_parse_args($instance->args, array_fill_keys(['class', 'type'], '')); |
|
116 | - $key = $instance->tag.'_'.$args['type']; |
|
117 | - $classes = Arr::get($this->fields, $key, Arr::get($this->fields, $instance->tag)); |
|
118 | - $instance->args['class'] = trim($args['class'].' '.$classes); |
|
119 | - do_action_ref_array('site-reviews/customize/'.$this->style, [$instance]); |
|
120 | - } |
|
107 | + /** |
|
108 | + * @return void |
|
109 | + */ |
|
110 | + protected function customize(Builder $instance) |
|
111 | + { |
|
112 | + if (!array_key_exists($instance->tag, $this->fields)) { |
|
113 | + return; |
|
114 | + } |
|
115 | + $args = wp_parse_args($instance->args, array_fill_keys(['class', 'type'], '')); |
|
116 | + $key = $instance->tag.'_'.$args['type']; |
|
117 | + $classes = Arr::get($this->fields, $key, Arr::get($this->fields, $instance->tag)); |
|
118 | + $instance->args['class'] = trim($args['class'].' '.$classes); |
|
119 | + do_action_ref_array('site-reviews/customize/'.$this->style, [$instance]); |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * @param string $view |
|
124 | - * @return array |
|
125 | - */ |
|
126 | - protected function generatePossibleViews($view) |
|
127 | - { |
|
128 | - $basename = basename($view); |
|
129 | - $basepath = rtrim($view, $basename); |
|
130 | - $customPath = 'views/partials/styles/'.$this->style.'/'; |
|
131 | - $parts = explode('_', $basename); |
|
132 | - $views = [ |
|
133 | - $customPath.$basename, |
|
134 | - $customPath.$parts[0], |
|
135 | - $view, |
|
136 | - $basepath.$parts[0], |
|
137 | - ]; |
|
138 | - return array_filter($views); |
|
139 | - } |
|
122 | + /** |
|
123 | + * @param string $view |
|
124 | + * @return array |
|
125 | + */ |
|
126 | + protected function generatePossibleViews($view) |
|
127 | + { |
|
128 | + $basename = basename($view); |
|
129 | + $basepath = rtrim($view, $basename); |
|
130 | + $customPath = 'views/partials/styles/'.$this->style.'/'; |
|
131 | + $parts = explode('_', $basename); |
|
132 | + $views = [ |
|
133 | + $customPath.$basename, |
|
134 | + $customPath.$parts[0], |
|
135 | + $view, |
|
136 | + $basepath.$parts[0], |
|
137 | + ]; |
|
138 | + return array_filter($views); |
|
139 | + } |
|
140 | 140 | |
141 | - /** |
|
142 | - * @return bool |
|
143 | - */ |
|
144 | - protected function isPublicInstance(Builder $instance) |
|
145 | - { |
|
146 | - $args = wp_parse_args($instance->args, [ |
|
147 | - 'is_public' => false, |
|
148 | - 'is_raw' => false, |
|
149 | - ]); |
|
150 | - if (is_admin() || !$args['is_public'] || $args['is_raw']) { |
|
151 | - return false; |
|
152 | - } |
|
153 | - return true; |
|
154 | - } |
|
141 | + /** |
|
142 | + * @return bool |
|
143 | + */ |
|
144 | + protected function isPublicInstance(Builder $instance) |
|
145 | + { |
|
146 | + $args = wp_parse_args($instance->args, [ |
|
147 | + 'is_public' => false, |
|
148 | + 'is_raw' => false, |
|
149 | + ]); |
|
150 | + if (is_admin() || !$args['is_public'] || $args['is_raw']) { |
|
151 | + return false; |
|
152 | + } |
|
153 | + return true; |
|
154 | + } |
|
155 | 155 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | public function __construct() |
36 | 36 | { |
37 | - $this->style = glsr(OptionManager::class)->get('settings.general.style', 'default'); |
|
37 | + $this->style = glsr( OptionManager::class )->get( 'settings.general.style', 'default' ); |
|
38 | 38 | $this->setConfig(); |
39 | 39 | } |
40 | 40 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param string $view |
43 | 43 | * @return string |
44 | 44 | */ |
45 | - public function filterView($view) |
|
45 | + public function filterView( $view ) |
|
46 | 46 | { |
47 | 47 | $styledViews = [ |
48 | 48 | 'templates/form/field', |
@@ -50,15 +50,15 @@ discard block |
||
50 | 50 | 'templates/form/submit-button', |
51 | 51 | 'templates/reviews-form', |
52 | 52 | ]; |
53 | - if (!preg_match('('.implode('|', $styledViews).')', $view)) { |
|
53 | + if( !preg_match( '('.implode( '|', $styledViews ).')', $view ) ) { |
|
54 | 54 | return $view; |
55 | 55 | } |
56 | - $views = $this->generatePossibleViews($view); |
|
57 | - foreach ($views as $possibleView) { |
|
58 | - if (!file_exists(glsr()->file($possibleView))) { |
|
56 | + $views = $this->generatePossibleViews( $view ); |
|
57 | + foreach( $views as $possibleView ) { |
|
58 | + if( !file_exists( glsr()->file( $possibleView ) ) ) { |
|
59 | 59 | continue; |
60 | 60 | } |
61 | - return Str::removePrefix('views/', $possibleView); |
|
61 | + return Str::removePrefix( 'views/', $possibleView ); |
|
62 | 62 | } |
63 | 63 | return $view; |
64 | 64 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function get() |
70 | 70 | { |
71 | - return apply_filters('site-reviews/style', $this->style); |
|
71 | + return apply_filters( 'site-reviews/style', $this->style ); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -77,77 +77,77 @@ discard block |
||
77 | 77 | public function setConfig() |
78 | 78 | { |
79 | 79 | $config = shortcode_atts( |
80 | - array_fill_keys(['fields', 'pagination', 'validation'], []), |
|
81 | - glsr()->config('styles/'.$this->style) |
|
80 | + array_fill_keys( ['fields', 'pagination', 'validation'], [] ), |
|
81 | + glsr()->config( 'styles/'.$this->style ) |
|
82 | 82 | ); |
83 | - $this->fields = glsr(StyleFieldsDefaults::class)->restrict($config['fields']); |
|
84 | - $this->pagination = glsr(PaginationDefaults::class)->restrict($config['pagination']); |
|
85 | - $this->validation = glsr(StyleValidationDefaults::class)->restrict($config['validation']); |
|
83 | + $this->fields = glsr( StyleFieldsDefaults::class )->restrict( $config['fields'] ); |
|
84 | + $this->pagination = glsr( PaginationDefaults::class )->restrict( $config['pagination'] ); |
|
85 | + $this->validation = glsr( StyleValidationDefaults::class )->restrict( $config['validation'] ); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
89 | 89 | * @return void |
90 | 90 | */ |
91 | - public function modifyField(Builder $instance) |
|
91 | + public function modifyField( Builder $instance ) |
|
92 | 92 | { |
93 | - if (!$this->isPublicInstance($instance) || empty(array_filter($this->fields))) { |
|
93 | + if( !$this->isPublicInstance( $instance ) || empty(array_filter( $this->fields )) ) { |
|
94 | 94 | return; |
95 | 95 | } |
96 | - call_user_func_array([$this, 'customize'], [$instance]); |
|
96 | + call_user_func_array( [$this, 'customize'], [$instance] ); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
100 | 100 | * @return array |
101 | 101 | */ |
102 | - public function paginationArgs(array $args) |
|
102 | + public function paginationArgs( array $args ) |
|
103 | 103 | { |
104 | - return wp_parse_args($args, $this->pagination); |
|
104 | + return wp_parse_args( $args, $this->pagination ); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
108 | 108 | * @return void |
109 | 109 | */ |
110 | - protected function customize(Builder $instance) |
|
110 | + protected function customize( Builder $instance ) |
|
111 | 111 | { |
112 | - if (!array_key_exists($instance->tag, $this->fields)) { |
|
112 | + if( !array_key_exists( $instance->tag, $this->fields ) ) { |
|
113 | 113 | return; |
114 | 114 | } |
115 | - $args = wp_parse_args($instance->args, array_fill_keys(['class', 'type'], '')); |
|
115 | + $args = wp_parse_args( $instance->args, array_fill_keys( ['class', 'type'], '' ) ); |
|
116 | 116 | $key = $instance->tag.'_'.$args['type']; |
117 | - $classes = Arr::get($this->fields, $key, Arr::get($this->fields, $instance->tag)); |
|
118 | - $instance->args['class'] = trim($args['class'].' '.$classes); |
|
119 | - do_action_ref_array('site-reviews/customize/'.$this->style, [$instance]); |
|
117 | + $classes = Arr::get( $this->fields, $key, Arr::get( $this->fields, $instance->tag ) ); |
|
118 | + $instance->args['class'] = trim( $args['class'].' '.$classes ); |
|
119 | + do_action_ref_array( 'site-reviews/customize/'.$this->style, [$instance] ); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
123 | 123 | * @param string $view |
124 | 124 | * @return array |
125 | 125 | */ |
126 | - protected function generatePossibleViews($view) |
|
126 | + protected function generatePossibleViews( $view ) |
|
127 | 127 | { |
128 | - $basename = basename($view); |
|
129 | - $basepath = rtrim($view, $basename); |
|
128 | + $basename = basename( $view ); |
|
129 | + $basepath = rtrim( $view, $basename ); |
|
130 | 130 | $customPath = 'views/partials/styles/'.$this->style.'/'; |
131 | - $parts = explode('_', $basename); |
|
131 | + $parts = explode( '_', $basename ); |
|
132 | 132 | $views = [ |
133 | 133 | $customPath.$basename, |
134 | 134 | $customPath.$parts[0], |
135 | 135 | $view, |
136 | 136 | $basepath.$parts[0], |
137 | 137 | ]; |
138 | - return array_filter($views); |
|
138 | + return array_filter( $views ); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
142 | 142 | * @return bool |
143 | 143 | */ |
144 | - protected function isPublicInstance(Builder $instance) |
|
144 | + protected function isPublicInstance( Builder $instance ) |
|
145 | 145 | { |
146 | - $args = wp_parse_args($instance->args, [ |
|
146 | + $args = wp_parse_args( $instance->args, [ |
|
147 | 147 | 'is_public' => false, |
148 | 148 | 'is_raw' => false, |
149 | - ]); |
|
150 | - if (is_admin() || !$args['is_public'] || $args['is_raw']) { |
|
149 | + ] ); |
|
150 | + if( is_admin() || !$args['is_public'] || $args['is_raw'] ) { |
|
151 | 151 | return false; |
152 | 152 | } |
153 | 153 | return true; |
@@ -12,173 +12,173 @@ |
||
12 | 12 | |
13 | 13 | class Review implements \ArrayAccess |
14 | 14 | { |
15 | - public $assigned_to; |
|
16 | - public $author; |
|
17 | - public $avatar; |
|
18 | - public $content; |
|
19 | - public $custom; |
|
20 | - public $date; |
|
21 | - public $email; |
|
22 | - public $ID; |
|
23 | - public $ip_address; |
|
24 | - public $modified; |
|
25 | - public $pinned; |
|
26 | - public $rating; |
|
27 | - public $response; |
|
28 | - public $review_id; |
|
29 | - public $review_type; |
|
30 | - public $status; |
|
31 | - public $term_ids; |
|
32 | - public $title; |
|
33 | - public $url; |
|
34 | - public $user_id; |
|
15 | + public $assigned_to; |
|
16 | + public $author; |
|
17 | + public $avatar; |
|
18 | + public $content; |
|
19 | + public $custom; |
|
20 | + public $date; |
|
21 | + public $email; |
|
22 | + public $ID; |
|
23 | + public $ip_address; |
|
24 | + public $modified; |
|
25 | + public $pinned; |
|
26 | + public $rating; |
|
27 | + public $response; |
|
28 | + public $review_id; |
|
29 | + public $review_type; |
|
30 | + public $status; |
|
31 | + public $term_ids; |
|
32 | + public $title; |
|
33 | + public $url; |
|
34 | + public $user_id; |
|
35 | 35 | |
36 | - public function __construct(WP_Post $post) |
|
37 | - { |
|
38 | - if (Application::POST_TYPE != $post->post_type) { |
|
39 | - return; |
|
40 | - } |
|
41 | - $this->content = $post->post_content; |
|
42 | - $this->date = $post->post_date; |
|
43 | - $this->ID = intval($post->ID); |
|
44 | - $this->status = $post->post_status; |
|
45 | - $this->title = $post->post_title; |
|
46 | - $this->user_id = intval($post->post_author); |
|
47 | - $this->setProperties($post); |
|
48 | - $this->setTermIds($post); |
|
49 | - } |
|
36 | + public function __construct(WP_Post $post) |
|
37 | + { |
|
38 | + if (Application::POST_TYPE != $post->post_type) { |
|
39 | + return; |
|
40 | + } |
|
41 | + $this->content = $post->post_content; |
|
42 | + $this->date = $post->post_date; |
|
43 | + $this->ID = intval($post->ID); |
|
44 | + $this->status = $post->post_status; |
|
45 | + $this->title = $post->post_title; |
|
46 | + $this->user_id = intval($post->post_author); |
|
47 | + $this->setProperties($post); |
|
48 | + $this->setTermIds($post); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @return mixed |
|
53 | - */ |
|
54 | - public function __get($key) |
|
55 | - { |
|
56 | - return $this->offsetGet($key); |
|
57 | - } |
|
51 | + /** |
|
52 | + * @return mixed |
|
53 | + */ |
|
54 | + public function __get($key) |
|
55 | + { |
|
56 | + return $this->offsetGet($key); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * @return string |
|
61 | - */ |
|
62 | - public function __toString() |
|
63 | - { |
|
64 | - return (string) $this->build(); |
|
65 | - } |
|
59 | + /** |
|
60 | + * @return string |
|
61 | + */ |
|
62 | + public function __toString() |
|
63 | + { |
|
64 | + return (string) $this->build(); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * @return ReviewHtml |
|
69 | - */ |
|
70 | - public function build(array $args = []) |
|
71 | - { |
|
72 | - if (empty($this->ID)) { |
|
73 | - return new ReviewHtml($this); |
|
74 | - } |
|
75 | - $partial = glsr(SiteReviewsPartial::class); |
|
76 | - $partial->args = glsr(SiteReviewsDefaults::class)->merge($args); |
|
77 | - $partial->options = Arr::flattenArray(glsr(OptionManager::class)->all()); |
|
78 | - return $partial->buildReview($this); |
|
79 | - } |
|
67 | + /** |
|
68 | + * @return ReviewHtml |
|
69 | + */ |
|
70 | + public function build(array $args = []) |
|
71 | + { |
|
72 | + if (empty($this->ID)) { |
|
73 | + return new ReviewHtml($this); |
|
74 | + } |
|
75 | + $partial = glsr(SiteReviewsPartial::class); |
|
76 | + $partial->args = glsr(SiteReviewsDefaults::class)->merge($args); |
|
77 | + $partial->options = Arr::flattenArray(glsr(OptionManager::class)->all()); |
|
78 | + return $partial->buildReview($this); |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * @param mixed $key |
|
83 | - * @return bool |
|
84 | - */ |
|
85 | - public function offsetExists($key) |
|
86 | - { |
|
87 | - return property_exists($this, $key) || array_key_exists($key, (array) $this->custom); |
|
88 | - } |
|
81 | + /** |
|
82 | + * @param mixed $key |
|
83 | + * @return bool |
|
84 | + */ |
|
85 | + public function offsetExists($key) |
|
86 | + { |
|
87 | + return property_exists($this, $key) || array_key_exists($key, (array) $this->custom); |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * @param mixed $key |
|
92 | - * @return mixed |
|
93 | - */ |
|
94 | - public function offsetGet($key) |
|
95 | - { |
|
96 | - return property_exists($this, $key) |
|
97 | - ? $this->$key |
|
98 | - : Arr::get($this->custom, $key, null); |
|
99 | - } |
|
90 | + /** |
|
91 | + * @param mixed $key |
|
92 | + * @return mixed |
|
93 | + */ |
|
94 | + public function offsetGet($key) |
|
95 | + { |
|
96 | + return property_exists($this, $key) |
|
97 | + ? $this->$key |
|
98 | + : Arr::get($this->custom, $key, null); |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * @param mixed $key |
|
103 | - * @param mixed $value |
|
104 | - * @return void |
|
105 | - */ |
|
106 | - public function offsetSet($key, $value) |
|
107 | - { |
|
108 | - if (property_exists($this, $key)) { |
|
109 | - $this->$key = $value; |
|
110 | - return; |
|
111 | - } |
|
112 | - if (!is_array($this->custom)) { |
|
113 | - $this->custom = array_filter((array) $this->custom); |
|
114 | - } |
|
115 | - $this->custom[$key] = $value; |
|
116 | - } |
|
101 | + /** |
|
102 | + * @param mixed $key |
|
103 | + * @param mixed $value |
|
104 | + * @return void |
|
105 | + */ |
|
106 | + public function offsetSet($key, $value) |
|
107 | + { |
|
108 | + if (property_exists($this, $key)) { |
|
109 | + $this->$key = $value; |
|
110 | + return; |
|
111 | + } |
|
112 | + if (!is_array($this->custom)) { |
|
113 | + $this->custom = array_filter((array) $this->custom); |
|
114 | + } |
|
115 | + $this->custom[$key] = $value; |
|
116 | + } |
|
117 | 117 | |
118 | - /** |
|
119 | - * @param mixed $key |
|
120 | - * @return void |
|
121 | - */ |
|
122 | - public function offsetUnset($key) |
|
123 | - { |
|
124 | - $this->offsetSet($key, null); |
|
125 | - } |
|
118 | + /** |
|
119 | + * @param mixed $key |
|
120 | + * @return void |
|
121 | + */ |
|
122 | + public function offsetUnset($key) |
|
123 | + { |
|
124 | + $this->offsetSet($key, null); |
|
125 | + } |
|
126 | 126 | |
127 | - /** |
|
128 | - * @return void |
|
129 | - */ |
|
130 | - public function render() |
|
131 | - { |
|
132 | - echo $this->build(); |
|
133 | - } |
|
127 | + /** |
|
128 | + * @return void |
|
129 | + */ |
|
130 | + public function render() |
|
131 | + { |
|
132 | + echo $this->build(); |
|
133 | + } |
|
134 | 134 | |
135 | - /** |
|
136 | - * @return bool |
|
137 | - */ |
|
138 | - protected function isModified(array $properties) |
|
139 | - { |
|
140 | - return $this->date != $properties['date'] |
|
141 | - || $this->content != $properties['content'] |
|
142 | - || $this->title != $properties['title']; |
|
143 | - } |
|
135 | + /** |
|
136 | + * @return bool |
|
137 | + */ |
|
138 | + protected function isModified(array $properties) |
|
139 | + { |
|
140 | + return $this->date != $properties['date'] |
|
141 | + || $this->content != $properties['content'] |
|
142 | + || $this->title != $properties['title']; |
|
143 | + } |
|
144 | 144 | |
145 | - /** |
|
146 | - * @return void |
|
147 | - */ |
|
148 | - protected function setProperties(WP_Post $post) |
|
149 | - { |
|
150 | - $defaults = [ |
|
151 | - 'author' => __('Anonymous', 'site-reviews'), |
|
152 | - 'date' => '', |
|
153 | - 'review_id' => '', |
|
154 | - 'review_type' => 'local', |
|
155 | - ]; |
|
156 | - $meta = array_filter( |
|
157 | - array_map('array_shift', array_filter((array) get_post_meta($post->ID))), |
|
158 | - 'strlen' |
|
159 | - ); |
|
160 | - $meta = array_merge($defaults, Arr::unprefixArrayKeys($meta)); |
|
161 | - $properties = glsr(CreateReviewDefaults::class)->restrict(array_merge($defaults, $meta)); |
|
162 | - $this->modified = $this->isModified($properties); |
|
163 | - array_walk($properties, function ($value, $key) { |
|
164 | - if (!property_exists($this, $key) || isset($this->$key)) { |
|
165 | - return; |
|
166 | - } |
|
167 | - $this->$key = maybe_unserialize($value); |
|
168 | - }); |
|
169 | - } |
|
145 | + /** |
|
146 | + * @return void |
|
147 | + */ |
|
148 | + protected function setProperties(WP_Post $post) |
|
149 | + { |
|
150 | + $defaults = [ |
|
151 | + 'author' => __('Anonymous', 'site-reviews'), |
|
152 | + 'date' => '', |
|
153 | + 'review_id' => '', |
|
154 | + 'review_type' => 'local', |
|
155 | + ]; |
|
156 | + $meta = array_filter( |
|
157 | + array_map('array_shift', array_filter((array) get_post_meta($post->ID))), |
|
158 | + 'strlen' |
|
159 | + ); |
|
160 | + $meta = array_merge($defaults, Arr::unprefixArrayKeys($meta)); |
|
161 | + $properties = glsr(CreateReviewDefaults::class)->restrict(array_merge($defaults, $meta)); |
|
162 | + $this->modified = $this->isModified($properties); |
|
163 | + array_walk($properties, function ($value, $key) { |
|
164 | + if (!property_exists($this, $key) || isset($this->$key)) { |
|
165 | + return; |
|
166 | + } |
|
167 | + $this->$key = maybe_unserialize($value); |
|
168 | + }); |
|
169 | + } |
|
170 | 170 | |
171 | - /** |
|
172 | - * @return void |
|
173 | - */ |
|
174 | - protected function setTermIds(WP_Post $post) |
|
175 | - { |
|
176 | - $this->term_ids = []; |
|
177 | - if (!is_array($terms = get_the_terms($post, Application::TAXONOMY))) { |
|
178 | - return; |
|
179 | - } |
|
180 | - foreach ($terms as $term) { |
|
181 | - $this->term_ids[] = $term->term_id; |
|
182 | - } |
|
183 | - } |
|
171 | + /** |
|
172 | + * @return void |
|
173 | + */ |
|
174 | + protected function setTermIds(WP_Post $post) |
|
175 | + { |
|
176 | + $this->term_ids = []; |
|
177 | + if (!is_array($terms = get_the_terms($post, Application::TAXONOMY))) { |
|
178 | + return; |
|
179 | + } |
|
180 | + foreach ($terms as $term) { |
|
181 | + $this->term_ids[] = $term->term_id; |
|
182 | + } |
|
183 | + } |
|
184 | 184 | } |
@@ -33,27 +33,27 @@ discard block |
||
33 | 33 | public $url; |
34 | 34 | public $user_id; |
35 | 35 | |
36 | - public function __construct(WP_Post $post) |
|
36 | + public function __construct( WP_Post $post ) |
|
37 | 37 | { |
38 | - if (Application::POST_TYPE != $post->post_type) { |
|
38 | + if( Application::POST_TYPE != $post->post_type ) { |
|
39 | 39 | return; |
40 | 40 | } |
41 | 41 | $this->content = $post->post_content; |
42 | 42 | $this->date = $post->post_date; |
43 | - $this->ID = intval($post->ID); |
|
43 | + $this->ID = intval( $post->ID ); |
|
44 | 44 | $this->status = $post->post_status; |
45 | 45 | $this->title = $post->post_title; |
46 | - $this->user_id = intval($post->post_author); |
|
47 | - $this->setProperties($post); |
|
48 | - $this->setTermIds($post); |
|
46 | + $this->user_id = intval( $post->post_author ); |
|
47 | + $this->setProperties( $post ); |
|
48 | + $this->setTermIds( $post ); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @return mixed |
53 | 53 | */ |
54 | - public function __get($key) |
|
54 | + public function __get( $key ) |
|
55 | 55 | { |
56 | - return $this->offsetGet($key); |
|
56 | + return $this->offsetGet( $key ); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -61,41 +61,41 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function __toString() |
63 | 63 | { |
64 | - return (string) $this->build(); |
|
64 | + return (string)$this->build(); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
68 | 68 | * @return ReviewHtml |
69 | 69 | */ |
70 | - public function build(array $args = []) |
|
70 | + public function build( array $args = [] ) |
|
71 | 71 | { |
72 | - if (empty($this->ID)) { |
|
73 | - return new ReviewHtml($this); |
|
72 | + if( empty($this->ID) ) { |
|
73 | + return new ReviewHtml( $this ); |
|
74 | 74 | } |
75 | - $partial = glsr(SiteReviewsPartial::class); |
|
76 | - $partial->args = glsr(SiteReviewsDefaults::class)->merge($args); |
|
77 | - $partial->options = Arr::flattenArray(glsr(OptionManager::class)->all()); |
|
78 | - return $partial->buildReview($this); |
|
75 | + $partial = glsr( SiteReviewsPartial::class ); |
|
76 | + $partial->args = glsr( SiteReviewsDefaults::class )->merge( $args ); |
|
77 | + $partial->options = Arr::flattenArray( glsr( OptionManager::class )->all() ); |
|
78 | + return $partial->buildReview( $this ); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
82 | 82 | * @param mixed $key |
83 | 83 | * @return bool |
84 | 84 | */ |
85 | - public function offsetExists($key) |
|
85 | + public function offsetExists( $key ) |
|
86 | 86 | { |
87 | - return property_exists($this, $key) || array_key_exists($key, (array) $this->custom); |
|
87 | + return property_exists( $this, $key ) || array_key_exists( $key, (array)$this->custom ); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
91 | 91 | * @param mixed $key |
92 | 92 | * @return mixed |
93 | 93 | */ |
94 | - public function offsetGet($key) |
|
94 | + public function offsetGet( $key ) |
|
95 | 95 | { |
96 | - return property_exists($this, $key) |
|
96 | + return property_exists( $this, $key ) |
|
97 | 97 | ? $this->$key |
98 | - : Arr::get($this->custom, $key, null); |
|
98 | + : Arr::get( $this->custom, $key, null ); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | * @param mixed $value |
104 | 104 | * @return void |
105 | 105 | */ |
106 | - public function offsetSet($key, $value) |
|
106 | + public function offsetSet( $key, $value ) |
|
107 | 107 | { |
108 | - if (property_exists($this, $key)) { |
|
108 | + if( property_exists( $this, $key ) ) { |
|
109 | 109 | $this->$key = $value; |
110 | 110 | return; |
111 | 111 | } |
112 | - if (!is_array($this->custom)) { |
|
113 | - $this->custom = array_filter((array) $this->custom); |
|
112 | + if( !is_array( $this->custom ) ) { |
|
113 | + $this->custom = array_filter( (array)$this->custom ); |
|
114 | 114 | } |
115 | 115 | $this->custom[$key] = $value; |
116 | 116 | } |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | * @param mixed $key |
120 | 120 | * @return void |
121 | 121 | */ |
122 | - public function offsetUnset($key) |
|
122 | + public function offsetUnset( $key ) |
|
123 | 123 | { |
124 | - $this->offsetSet($key, null); |
|
124 | + $this->offsetSet( $key, null ); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | /** |
136 | 136 | * @return bool |
137 | 137 | */ |
138 | - protected function isModified(array $properties) |
|
138 | + protected function isModified( array $properties ) |
|
139 | 139 | { |
140 | 140 | return $this->date != $properties['date'] |
141 | 141 | || $this->content != $properties['content'] |
@@ -145,39 +145,39 @@ discard block |
||
145 | 145 | /** |
146 | 146 | * @return void |
147 | 147 | */ |
148 | - protected function setProperties(WP_Post $post) |
|
148 | + protected function setProperties( WP_Post $post ) |
|
149 | 149 | { |
150 | 150 | $defaults = [ |
151 | - 'author' => __('Anonymous', 'site-reviews'), |
|
151 | + 'author' => __( 'Anonymous', 'site-reviews' ), |
|
152 | 152 | 'date' => '', |
153 | 153 | 'review_id' => '', |
154 | 154 | 'review_type' => 'local', |
155 | 155 | ]; |
156 | 156 | $meta = array_filter( |
157 | - array_map('array_shift', array_filter((array) get_post_meta($post->ID))), |
|
157 | + array_map( 'array_shift', array_filter( (array)get_post_meta( $post->ID ) ) ), |
|
158 | 158 | 'strlen' |
159 | 159 | ); |
160 | - $meta = array_merge($defaults, Arr::unprefixArrayKeys($meta)); |
|
161 | - $properties = glsr(CreateReviewDefaults::class)->restrict(array_merge($defaults, $meta)); |
|
162 | - $this->modified = $this->isModified($properties); |
|
163 | - array_walk($properties, function ($value, $key) { |
|
164 | - if (!property_exists($this, $key) || isset($this->$key)) { |
|
160 | + $meta = array_merge( $defaults, Arr::unprefixArrayKeys( $meta ) ); |
|
161 | + $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta ) ); |
|
162 | + $this->modified = $this->isModified( $properties ); |
|
163 | + array_walk( $properties, function( $value, $key ) { |
|
164 | + if( !property_exists( $this, $key ) || isset($this->$key) ) { |
|
165 | 165 | return; |
166 | 166 | } |
167 | - $this->$key = maybe_unserialize($value); |
|
167 | + $this->$key = maybe_unserialize( $value ); |
|
168 | 168 | }); |
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
172 | 172 | * @return void |
173 | 173 | */ |
174 | - protected function setTermIds(WP_Post $post) |
|
174 | + protected function setTermIds( WP_Post $post ) |
|
175 | 175 | { |
176 | 176 | $this->term_ids = []; |
177 | - if (!is_array($terms = get_the_terms($post, Application::TAXONOMY))) { |
|
177 | + if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY ) ) ) { |
|
178 | 178 | return; |
179 | 179 | } |
180 | - foreach ($terms as $term) { |
|
180 | + foreach( $terms as $term ) { |
|
181 | 181 | $this->term_ids[] = $term->term_id; |
182 | 182 | } |
183 | 183 | } |
@@ -9,205 +9,205 @@ |
||
9 | 9 | |
10 | 10 | class Email |
11 | 11 | { |
12 | - /** |
|
13 | - * @var array |
|
14 | - */ |
|
15 | - public $attachments; |
|
16 | - |
|
17 | - /** |
|
18 | - * @var array |
|
19 | - */ |
|
20 | - public $email; |
|
21 | - |
|
22 | - /** |
|
23 | - * @var array |
|
24 | - */ |
|
25 | - public $headers; |
|
26 | - |
|
27 | - /** |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - public $message; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - public $subject; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var string|array |
|
39 | - */ |
|
40 | - public $to; |
|
41 | - |
|
42 | - /** |
|
43 | - * @return Email |
|
44 | - */ |
|
45 | - public function compose(array $email) |
|
46 | - { |
|
47 | - $this->normalize($email); |
|
48 | - $this->attachments = $this->email['attachments']; |
|
49 | - $this->headers = $this->buildHeaders(); |
|
50 | - $this->message = $this->buildHtmlMessage(); |
|
51 | - $this->subject = $this->email['subject']; |
|
52 | - $this->to = $this->email['to']; |
|
53 | - add_action('phpmailer_init', [$this, 'buildPlainTextMessage']); |
|
54 | - return $this; |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * @param string $format |
|
59 | - * @return string|null |
|
60 | - */ |
|
61 | - public function read($format = '') |
|
62 | - { |
|
63 | - if ('plaintext' == $format) { |
|
64 | - $message = $this->stripHtmlTags($this->message); |
|
65 | - return apply_filters('site-reviews/email/message', $message, 'text', $this); |
|
66 | - } |
|
67 | - return $this->message; |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * @return void|bool |
|
72 | - */ |
|
73 | - public function send() |
|
74 | - { |
|
75 | - if (!$this->message || !$this->subject || !$this->to) { |
|
76 | - return; |
|
77 | - } |
|
78 | - add_action('wp_mail_failed', [$this, 'logMailError']); |
|
79 | - $sent = wp_mail( |
|
80 | - $this->to, |
|
81 | - $this->subject, |
|
82 | - $this->message, |
|
83 | - $this->headers, |
|
84 | - $this->attachments |
|
85 | - ); |
|
86 | - remove_action('wp_mail_failed', [$this, 'logMailError']); |
|
87 | - $this->reset(); |
|
88 | - return $sent; |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * @return void |
|
93 | - * @action phpmailer_init |
|
94 | - */ |
|
95 | - public function buildPlainTextMessage(PHPMailer $phpmailer) |
|
96 | - { |
|
97 | - if (empty($this->email)) { |
|
98 | - return; |
|
99 | - } |
|
100 | - if ('text/plain' === $phpmailer->ContentType || !empty($phpmailer->AltBody)) { |
|
101 | - return; |
|
102 | - } |
|
103 | - $message = $this->stripHtmlTags($phpmailer->Body); |
|
104 | - $phpmailer->AltBody = apply_filters('site-reviews/email/message', $message, 'text', $this); |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * @return array |
|
109 | - */ |
|
110 | - protected function buildHeaders() |
|
111 | - { |
|
112 | - $allowed = [ |
|
113 | - 'bcc', 'cc', 'from', 'reply-to', |
|
114 | - ]; |
|
115 | - $headers = array_intersect_key($this->email, array_flip($allowed)); |
|
116 | - $headers = array_filter($headers); |
|
117 | - foreach ($headers as $key => $value) { |
|
118 | - unset($headers[$key]); |
|
119 | - $headers[] = $key.': '.$value; |
|
120 | - } |
|
121 | - $headers[] = 'Content-Type: text/html'; |
|
122 | - return apply_filters('site-reviews/email/headers', $headers, $this); |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * @return string |
|
127 | - */ |
|
128 | - protected function buildHtmlMessage() |
|
129 | - { |
|
130 | - $template = trim(glsr(OptionManager::class)->get('settings.general.notification_message')); |
|
131 | - if (!empty($template)) { |
|
132 | - $message = glsr(Template::class)->interpolate( |
|
133 | - $template, |
|
134 | - ['context' => $this->email['template-tags']], |
|
135 | - $this->email['template'] |
|
136 | - ); |
|
137 | - } elseif ($this->email['template']) { |
|
138 | - $message = glsr(Template::class)->build('templates/'.$this->email['template'], [ |
|
139 | - 'context' => $this->email['template-tags'], |
|
140 | - ]); |
|
141 | - } |
|
142 | - if (!isset($message)) { |
|
143 | - $message = $this->email['message']; |
|
144 | - } |
|
145 | - $message = $this->email['before'].$message.$this->email['after']; |
|
146 | - $message = strip_shortcodes($message); |
|
147 | - $message = wptexturize($message); |
|
148 | - $message = wpautop($message); |
|
149 | - $message = str_replace('<> ', '', $message); |
|
150 | - $message = str_replace(']]>', ']]>', $message); |
|
151 | - $message = glsr(Template::class)->build('partials/email/index', [ |
|
152 | - 'context' => ['message' => $message], |
|
153 | - ]); |
|
154 | - return apply_filters('site-reviews/email/message', stripslashes($message), 'html', $this); |
|
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * @param \WP_Error $error |
|
159 | - * @return void |
|
160 | - */ |
|
161 | - protected function logMailError($error) |
|
162 | - { |
|
163 | - glsr_log()->error('Email was not sent (wp_mail failed)') |
|
164 | - ->debug($this) |
|
165 | - ->debug($error); |
|
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * @return void |
|
170 | - */ |
|
171 | - protected function normalize(array $email = []) |
|
172 | - { |
|
173 | - $email = shortcode_atts(glsr(EmailDefaults::class)->defaults(), $email); |
|
174 | - if (empty($email['reply-to'])) { |
|
175 | - $email['reply-to'] = $email['from']; |
|
176 | - } |
|
177 | - $this->email = apply_filters('site-reviews/email/compose', $email, $this); |
|
178 | - } |
|
179 | - |
|
180 | - /** |
|
181 | - * @return void |
|
182 | - */ |
|
183 | - protected function reset() |
|
184 | - { |
|
185 | - $this->attachments = []; |
|
186 | - $this->email = []; |
|
187 | - $this->headers = []; |
|
188 | - $this->message = null; |
|
189 | - $this->subject = null; |
|
190 | - $this->to = null; |
|
191 | - } |
|
192 | - |
|
193 | - /** |
|
194 | - * @return string |
|
195 | - */ |
|
196 | - protected function stripHtmlTags($string) |
|
197 | - { |
|
198 | - // remove invisible elements |
|
199 | - $string = preg_replace('@<(embed|head|noembed|noscript|object|script|style)[^>]*?>.*?</\\1>@siu', '', $string); |
|
200 | - // replace certain elements with a line-break |
|
201 | - $string = preg_replace('@</(div|h[1-9]|p|pre|tr)@iu', "\r\n\$0", $string); |
|
202 | - // replace other elements with a space |
|
203 | - $string = preg_replace('@</(td|th)@iu', ' $0', $string); |
|
204 | - // add a placeholder for plain-text bullets to list elements |
|
205 | - $string = preg_replace('@<(li)[^>]*?>@siu', '$0-o-^-o-', $string); |
|
206 | - // strip all remaining HTML tags |
|
207 | - $string = wp_strip_all_tags($string); |
|
208 | - $string = wp_specialchars_decode($string, ENT_QUOTES); |
|
209 | - $string = preg_replace('/\v(?:[\v\h]+){2,}/', "\r\n\r\n", $string); |
|
210 | - $string = str_replace('-o-^-o-', ' - ', $string); |
|
211 | - return html_entity_decode($string, ENT_QUOTES, 'UTF-8'); |
|
212 | - } |
|
12 | + /** |
|
13 | + * @var array |
|
14 | + */ |
|
15 | + public $attachments; |
|
16 | + |
|
17 | + /** |
|
18 | + * @var array |
|
19 | + */ |
|
20 | + public $email; |
|
21 | + |
|
22 | + /** |
|
23 | + * @var array |
|
24 | + */ |
|
25 | + public $headers; |
|
26 | + |
|
27 | + /** |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + public $message; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + public $subject; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var string|array |
|
39 | + */ |
|
40 | + public $to; |
|
41 | + |
|
42 | + /** |
|
43 | + * @return Email |
|
44 | + */ |
|
45 | + public function compose(array $email) |
|
46 | + { |
|
47 | + $this->normalize($email); |
|
48 | + $this->attachments = $this->email['attachments']; |
|
49 | + $this->headers = $this->buildHeaders(); |
|
50 | + $this->message = $this->buildHtmlMessage(); |
|
51 | + $this->subject = $this->email['subject']; |
|
52 | + $this->to = $this->email['to']; |
|
53 | + add_action('phpmailer_init', [$this, 'buildPlainTextMessage']); |
|
54 | + return $this; |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * @param string $format |
|
59 | + * @return string|null |
|
60 | + */ |
|
61 | + public function read($format = '') |
|
62 | + { |
|
63 | + if ('plaintext' == $format) { |
|
64 | + $message = $this->stripHtmlTags($this->message); |
|
65 | + return apply_filters('site-reviews/email/message', $message, 'text', $this); |
|
66 | + } |
|
67 | + return $this->message; |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * @return void|bool |
|
72 | + */ |
|
73 | + public function send() |
|
74 | + { |
|
75 | + if (!$this->message || !$this->subject || !$this->to) { |
|
76 | + return; |
|
77 | + } |
|
78 | + add_action('wp_mail_failed', [$this, 'logMailError']); |
|
79 | + $sent = wp_mail( |
|
80 | + $this->to, |
|
81 | + $this->subject, |
|
82 | + $this->message, |
|
83 | + $this->headers, |
|
84 | + $this->attachments |
|
85 | + ); |
|
86 | + remove_action('wp_mail_failed', [$this, 'logMailError']); |
|
87 | + $this->reset(); |
|
88 | + return $sent; |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * @return void |
|
93 | + * @action phpmailer_init |
|
94 | + */ |
|
95 | + public function buildPlainTextMessage(PHPMailer $phpmailer) |
|
96 | + { |
|
97 | + if (empty($this->email)) { |
|
98 | + return; |
|
99 | + } |
|
100 | + if ('text/plain' === $phpmailer->ContentType || !empty($phpmailer->AltBody)) { |
|
101 | + return; |
|
102 | + } |
|
103 | + $message = $this->stripHtmlTags($phpmailer->Body); |
|
104 | + $phpmailer->AltBody = apply_filters('site-reviews/email/message', $message, 'text', $this); |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * @return array |
|
109 | + */ |
|
110 | + protected function buildHeaders() |
|
111 | + { |
|
112 | + $allowed = [ |
|
113 | + 'bcc', 'cc', 'from', 'reply-to', |
|
114 | + ]; |
|
115 | + $headers = array_intersect_key($this->email, array_flip($allowed)); |
|
116 | + $headers = array_filter($headers); |
|
117 | + foreach ($headers as $key => $value) { |
|
118 | + unset($headers[$key]); |
|
119 | + $headers[] = $key.': '.$value; |
|
120 | + } |
|
121 | + $headers[] = 'Content-Type: text/html'; |
|
122 | + return apply_filters('site-reviews/email/headers', $headers, $this); |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * @return string |
|
127 | + */ |
|
128 | + protected function buildHtmlMessage() |
|
129 | + { |
|
130 | + $template = trim(glsr(OptionManager::class)->get('settings.general.notification_message')); |
|
131 | + if (!empty($template)) { |
|
132 | + $message = glsr(Template::class)->interpolate( |
|
133 | + $template, |
|
134 | + ['context' => $this->email['template-tags']], |
|
135 | + $this->email['template'] |
|
136 | + ); |
|
137 | + } elseif ($this->email['template']) { |
|
138 | + $message = glsr(Template::class)->build('templates/'.$this->email['template'], [ |
|
139 | + 'context' => $this->email['template-tags'], |
|
140 | + ]); |
|
141 | + } |
|
142 | + if (!isset($message)) { |
|
143 | + $message = $this->email['message']; |
|
144 | + } |
|
145 | + $message = $this->email['before'].$message.$this->email['after']; |
|
146 | + $message = strip_shortcodes($message); |
|
147 | + $message = wptexturize($message); |
|
148 | + $message = wpautop($message); |
|
149 | + $message = str_replace('<> ', '', $message); |
|
150 | + $message = str_replace(']]>', ']]>', $message); |
|
151 | + $message = glsr(Template::class)->build('partials/email/index', [ |
|
152 | + 'context' => ['message' => $message], |
|
153 | + ]); |
|
154 | + return apply_filters('site-reviews/email/message', stripslashes($message), 'html', $this); |
|
155 | + } |
|
156 | + |
|
157 | + /** |
|
158 | + * @param \WP_Error $error |
|
159 | + * @return void |
|
160 | + */ |
|
161 | + protected function logMailError($error) |
|
162 | + { |
|
163 | + glsr_log()->error('Email was not sent (wp_mail failed)') |
|
164 | + ->debug($this) |
|
165 | + ->debug($error); |
|
166 | + } |
|
167 | + |
|
168 | + /** |
|
169 | + * @return void |
|
170 | + */ |
|
171 | + protected function normalize(array $email = []) |
|
172 | + { |
|
173 | + $email = shortcode_atts(glsr(EmailDefaults::class)->defaults(), $email); |
|
174 | + if (empty($email['reply-to'])) { |
|
175 | + $email['reply-to'] = $email['from']; |
|
176 | + } |
|
177 | + $this->email = apply_filters('site-reviews/email/compose', $email, $this); |
|
178 | + } |
|
179 | + |
|
180 | + /** |
|
181 | + * @return void |
|
182 | + */ |
|
183 | + protected function reset() |
|
184 | + { |
|
185 | + $this->attachments = []; |
|
186 | + $this->email = []; |
|
187 | + $this->headers = []; |
|
188 | + $this->message = null; |
|
189 | + $this->subject = null; |
|
190 | + $this->to = null; |
|
191 | + } |
|
192 | + |
|
193 | + /** |
|
194 | + * @return string |
|
195 | + */ |
|
196 | + protected function stripHtmlTags($string) |
|
197 | + { |
|
198 | + // remove invisible elements |
|
199 | + $string = preg_replace('@<(embed|head|noembed|noscript|object|script|style)[^>]*?>.*?</\\1>@siu', '', $string); |
|
200 | + // replace certain elements with a line-break |
|
201 | + $string = preg_replace('@</(div|h[1-9]|p|pre|tr)@iu', "\r\n\$0", $string); |
|
202 | + // replace other elements with a space |
|
203 | + $string = preg_replace('@</(td|th)@iu', ' $0', $string); |
|
204 | + // add a placeholder for plain-text bullets to list elements |
|
205 | + $string = preg_replace('@<(li)[^>]*?>@siu', '$0-o-^-o-', $string); |
|
206 | + // strip all remaining HTML tags |
|
207 | + $string = wp_strip_all_tags($string); |
|
208 | + $string = wp_specialchars_decode($string, ENT_QUOTES); |
|
209 | + $string = preg_replace('/\v(?:[\v\h]+){2,}/', "\r\n\r\n", $string); |
|
210 | + $string = str_replace('-o-^-o-', ' - ', $string); |
|
211 | + return html_entity_decode($string, ENT_QUOTES, 'UTF-8'); |
|
212 | + } |
|
213 | 213 | } |
@@ -42,15 +42,15 @@ discard block |
||
42 | 42 | /** |
43 | 43 | * @return Email |
44 | 44 | */ |
45 | - public function compose(array $email) |
|
45 | + public function compose( array $email ) |
|
46 | 46 | { |
47 | - $this->normalize($email); |
|
47 | + $this->normalize( $email ); |
|
48 | 48 | $this->attachments = $this->email['attachments']; |
49 | 49 | $this->headers = $this->buildHeaders(); |
50 | 50 | $this->message = $this->buildHtmlMessage(); |
51 | 51 | $this->subject = $this->email['subject']; |
52 | 52 | $this->to = $this->email['to']; |
53 | - add_action('phpmailer_init', [$this, 'buildPlainTextMessage']); |
|
53 | + add_action( 'phpmailer_init', [$this, 'buildPlainTextMessage'] ); |
|
54 | 54 | return $this; |
55 | 55 | } |
56 | 56 | |
@@ -58,11 +58,11 @@ discard block |
||
58 | 58 | * @param string $format |
59 | 59 | * @return string|null |
60 | 60 | */ |
61 | - public function read($format = '') |
|
61 | + public function read( $format = '' ) |
|
62 | 62 | { |
63 | - if ('plaintext' == $format) { |
|
64 | - $message = $this->stripHtmlTags($this->message); |
|
65 | - return apply_filters('site-reviews/email/message', $message, 'text', $this); |
|
63 | + if( 'plaintext' == $format ) { |
|
64 | + $message = $this->stripHtmlTags( $this->message ); |
|
65 | + return apply_filters( 'site-reviews/email/message', $message, 'text', $this ); |
|
66 | 66 | } |
67 | 67 | return $this->message; |
68 | 68 | } |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function send() |
74 | 74 | { |
75 | - if (!$this->message || !$this->subject || !$this->to) { |
|
75 | + if( !$this->message || !$this->subject || !$this->to ) { |
|
76 | 76 | return; |
77 | 77 | } |
78 | - add_action('wp_mail_failed', [$this, 'logMailError']); |
|
78 | + add_action( 'wp_mail_failed', [$this, 'logMailError'] ); |
|
79 | 79 | $sent = wp_mail( |
80 | 80 | $this->to, |
81 | 81 | $this->subject, |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $this->headers, |
84 | 84 | $this->attachments |
85 | 85 | ); |
86 | - remove_action('wp_mail_failed', [$this, 'logMailError']); |
|
86 | + remove_action( 'wp_mail_failed', [$this, 'logMailError'] ); |
|
87 | 87 | $this->reset(); |
88 | 88 | return $sent; |
89 | 89 | } |
@@ -92,16 +92,16 @@ discard block |
||
92 | 92 | * @return void |
93 | 93 | * @action phpmailer_init |
94 | 94 | */ |
95 | - public function buildPlainTextMessage(PHPMailer $phpmailer) |
|
95 | + public function buildPlainTextMessage( PHPMailer $phpmailer ) |
|
96 | 96 | { |
97 | - if (empty($this->email)) { |
|
97 | + if( empty($this->email) ) { |
|
98 | 98 | return; |
99 | 99 | } |
100 | - if ('text/plain' === $phpmailer->ContentType || !empty($phpmailer->AltBody)) { |
|
100 | + if( 'text/plain' === $phpmailer->ContentType || !empty($phpmailer->AltBody) ) { |
|
101 | 101 | return; |
102 | 102 | } |
103 | - $message = $this->stripHtmlTags($phpmailer->Body); |
|
104 | - $phpmailer->AltBody = apply_filters('site-reviews/email/message', $message, 'text', $this); |
|
103 | + $message = $this->stripHtmlTags( $phpmailer->Body ); |
|
104 | + $phpmailer->AltBody = apply_filters( 'site-reviews/email/message', $message, 'text', $this ); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -112,14 +112,14 @@ discard block |
||
112 | 112 | $allowed = [ |
113 | 113 | 'bcc', 'cc', 'from', 'reply-to', |
114 | 114 | ]; |
115 | - $headers = array_intersect_key($this->email, array_flip($allowed)); |
|
116 | - $headers = array_filter($headers); |
|
117 | - foreach ($headers as $key => $value) { |
|
115 | + $headers = array_intersect_key( $this->email, array_flip( $allowed ) ); |
|
116 | + $headers = array_filter( $headers ); |
|
117 | + foreach( $headers as $key => $value ) { |
|
118 | 118 | unset($headers[$key]); |
119 | 119 | $headers[] = $key.': '.$value; |
120 | 120 | } |
121 | 121 | $headers[] = 'Content-Type: text/html'; |
122 | - return apply_filters('site-reviews/email/headers', $headers, $this); |
|
122 | + return apply_filters( 'site-reviews/email/headers', $headers, $this ); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -127,54 +127,54 @@ discard block |
||
127 | 127 | */ |
128 | 128 | protected function buildHtmlMessage() |
129 | 129 | { |
130 | - $template = trim(glsr(OptionManager::class)->get('settings.general.notification_message')); |
|
131 | - if (!empty($template)) { |
|
132 | - $message = glsr(Template::class)->interpolate( |
|
130 | + $template = trim( glsr( OptionManager::class )->get( 'settings.general.notification_message' ) ); |
|
131 | + if( !empty($template) ) { |
|
132 | + $message = glsr( Template::class )->interpolate( |
|
133 | 133 | $template, |
134 | 134 | ['context' => $this->email['template-tags']], |
135 | 135 | $this->email['template'] |
136 | 136 | ); |
137 | - } elseif ($this->email['template']) { |
|
138 | - $message = glsr(Template::class)->build('templates/'.$this->email['template'], [ |
|
137 | + } elseif( $this->email['template'] ) { |
|
138 | + $message = glsr( Template::class )->build( 'templates/'.$this->email['template'], [ |
|
139 | 139 | 'context' => $this->email['template-tags'], |
140 | - ]); |
|
140 | + ] ); |
|
141 | 141 | } |
142 | - if (!isset($message)) { |
|
142 | + if( !isset($message) ) { |
|
143 | 143 | $message = $this->email['message']; |
144 | 144 | } |
145 | 145 | $message = $this->email['before'].$message.$this->email['after']; |
146 | - $message = strip_shortcodes($message); |
|
147 | - $message = wptexturize($message); |
|
148 | - $message = wpautop($message); |
|
149 | - $message = str_replace('<> ', '', $message); |
|
150 | - $message = str_replace(']]>', ']]>', $message); |
|
151 | - $message = glsr(Template::class)->build('partials/email/index', [ |
|
146 | + $message = strip_shortcodes( $message ); |
|
147 | + $message = wptexturize( $message ); |
|
148 | + $message = wpautop( $message ); |
|
149 | + $message = str_replace( '<> ', '', $message ); |
|
150 | + $message = str_replace( ']]>', ']]>', $message ); |
|
151 | + $message = glsr( Template::class )->build( 'partials/email/index', [ |
|
152 | 152 | 'context' => ['message' => $message], |
153 | - ]); |
|
154 | - return apply_filters('site-reviews/email/message', stripslashes($message), 'html', $this); |
|
153 | + ] ); |
|
154 | + return apply_filters( 'site-reviews/email/message', stripslashes( $message ), 'html', $this ); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
158 | 158 | * @param \WP_Error $error |
159 | 159 | * @return void |
160 | 160 | */ |
161 | - protected function logMailError($error) |
|
161 | + protected function logMailError( $error ) |
|
162 | 162 | { |
163 | - glsr_log()->error('Email was not sent (wp_mail failed)') |
|
164 | - ->debug($this) |
|
165 | - ->debug($error); |
|
163 | + glsr_log()->error( 'Email was not sent (wp_mail failed)' ) |
|
164 | + ->debug( $this ) |
|
165 | + ->debug( $error ); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
169 | 169 | * @return void |
170 | 170 | */ |
171 | - protected function normalize(array $email = []) |
|
171 | + protected function normalize( array $email = [] ) |
|
172 | 172 | { |
173 | - $email = shortcode_atts(glsr(EmailDefaults::class)->defaults(), $email); |
|
174 | - if (empty($email['reply-to'])) { |
|
173 | + $email = shortcode_atts( glsr( EmailDefaults::class )->defaults(), $email ); |
|
174 | + if( empty($email['reply-to']) ) { |
|
175 | 175 | $email['reply-to'] = $email['from']; |
176 | 176 | } |
177 | - $this->email = apply_filters('site-reviews/email/compose', $email, $this); |
|
177 | + $this->email = apply_filters( 'site-reviews/email/compose', $email, $this ); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
@@ -193,21 +193,21 @@ discard block |
||
193 | 193 | /** |
194 | 194 | * @return string |
195 | 195 | */ |
196 | - protected function stripHtmlTags($string) |
|
196 | + protected function stripHtmlTags( $string ) |
|
197 | 197 | { |
198 | 198 | // remove invisible elements |
199 | - $string = preg_replace('@<(embed|head|noembed|noscript|object|script|style)[^>]*?>.*?</\\1>@siu', '', $string); |
|
199 | + $string = preg_replace( '@<(embed|head|noembed|noscript|object|script|style)[^>]*?>.*?</\\1>@siu', '', $string ); |
|
200 | 200 | // replace certain elements with a line-break |
201 | - $string = preg_replace('@</(div|h[1-9]|p|pre|tr)@iu', "\r\n\$0", $string); |
|
201 | + $string = preg_replace( '@</(div|h[1-9]|p|pre|tr)@iu', "\r\n\$0", $string ); |
|
202 | 202 | // replace other elements with a space |
203 | - $string = preg_replace('@</(td|th)@iu', ' $0', $string); |
|
203 | + $string = preg_replace( '@</(td|th)@iu', ' $0', $string ); |
|
204 | 204 | // add a placeholder for plain-text bullets to list elements |
205 | - $string = preg_replace('@<(li)[^>]*?>@siu', '$0-o-^-o-', $string); |
|
205 | + $string = preg_replace( '@<(li)[^>]*?>@siu', '$0-o-^-o-', $string ); |
|
206 | 206 | // strip all remaining HTML tags |
207 | - $string = wp_strip_all_tags($string); |
|
208 | - $string = wp_specialchars_decode($string, ENT_QUOTES); |
|
209 | - $string = preg_replace('/\v(?:[\v\h]+){2,}/', "\r\n\r\n", $string); |
|
210 | - $string = str_replace('-o-^-o-', ' - ', $string); |
|
211 | - return html_entity_decode($string, ENT_QUOTES, 'UTF-8'); |
|
207 | + $string = wp_strip_all_tags( $string ); |
|
208 | + $string = wp_specialchars_decode( $string, ENT_QUOTES ); |
|
209 | + $string = preg_replace( '/\v(?:[\v\h]+){2,}/', "\r\n\r\n", $string ); |
|
210 | + $string = str_replace( '-o-^-o-', ' - ', $string ); |
|
211 | + return html_entity_decode( $string, ENT_QUOTES, 'UTF-8' ); |
|
212 | 212 | } |
213 | 213 | } |
@@ -134,7 +134,8 @@ |
||
134 | 134 | ['context' => $this->email['template-tags']], |
135 | 135 | $this->email['template'] |
136 | 136 | ); |
137 | - } elseif ($this->email['template']) { |
|
137 | + } |
|
138 | + elseif ($this->email['template']) { |
|
138 | 139 | $message = glsr(Template::class)->build('templates/'.$this->email['template'], [ |
139 | 140 | 'context' => $this->email['template-tags'], |
140 | 141 | ]); |
@@ -1,552 +1,552 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | return [ |
4 | - 'settings.general.style' => [ |
|
5 | - 'default' => 'default', |
|
6 | - 'description' => __('Site Reviews relies on the CSS of your theme to style the submission form. If your theme does not provide proper CSS rules for form elements and you are using a WordPress plugin/theme or CSS Framework listed here, please try selecting it, otherwise choose "Site Reviews (default)".', 'site-reviews'), |
|
7 | - 'label' => __('Plugin Style', 'site-reviews'), |
|
8 | - 'options' => [ |
|
9 | - 'bootstrap_4' => 'CSS Framework: Bootstrap 4', |
|
10 | - 'bootstrap_4_custom' => 'CSS Framework: Bootstrap 4 (Custom Forms)', |
|
11 | - 'contact_form_7' => 'Plugin: Contact Form 7 (v5)', |
|
12 | - 'ninja_forms' => 'Plugin: Ninja Forms (v3)', |
|
13 | - 'wpforms' => 'Plugin: WPForms Lite (v1)', |
|
14 | - 'default' => __('Site Reviews (default)', 'site-reviews'), |
|
15 | - 'minimal' => __('Site Reviews (minimal)', 'site-reviews'), |
|
16 | - 'divi' => 'Theme: Divi (v3)', |
|
17 | - 'materialize' => 'Theme: Materialize', |
|
18 | - 'twentyfifteen' => 'Theme: Twenty Fifteen', |
|
19 | - 'twentyseventeen' => 'Theme: Twenty Seventeen', |
|
20 | - 'twentynineteen' => 'Theme: Twenty Nineteen', |
|
21 | - ], |
|
22 | - 'type' => 'select', |
|
23 | - ], |
|
24 | - 'settings.general.require.approval' => [ |
|
25 | - 'default' => 'no', |
|
26 | - 'description' => __('Set the status of new review submissions to "unapproved".', 'site-reviews'), |
|
27 | - 'label' => __('Require Approval', 'site-reviews'), |
|
28 | - 'type' => 'yes_no', |
|
29 | - ], |
|
30 | - 'settings.general.require.login' => [ |
|
31 | - 'default' => 'no', |
|
32 | - 'description' => __('Only allow review submissions from registered users.', 'site-reviews'), |
|
33 | - 'label' => __('Require Login', 'site-reviews'), |
|
34 | - 'type' => 'yes_no', |
|
35 | - ], |
|
36 | - 'settings.general.require.login_register' => [ |
|
37 | - 'default' => 'no', |
|
38 | - 'depends_on' => [ |
|
39 | - 'settings.general.require.login' => 'yes', |
|
40 | - ], |
|
41 | - 'description' => sprintf(__('Show a link for a new user to register. The %s Membership option must be enabled in General Settings for this to work.', 'site-reviews'), |
|
42 | - '<a href="'.admin_url('options-general.php#users_can_register').'">'.__('Anyone can register', 'site-reviews').'</a>' |
|
43 | - ), |
|
44 | - 'label' => __('Show Registration Link', 'site-reviews'), |
|
45 | - 'type' => 'yes_no', |
|
46 | - ], |
|
47 | - 'settings.general.multilingual' => [ |
|
48 | - 'default' => '', |
|
49 | - 'description' => __('Integrate with a multilingual plugin to calculate ratings for all languages of a post.', 'site-reviews'), |
|
50 | - 'label' => __('Multilingual', 'site-reviews'), |
|
51 | - 'options' => [ |
|
52 | - '' => __('No Integration', 'site-reviews'), |
|
53 | - 'polylang' => __('Integrate with Polylang', 'site-reviews'), |
|
54 | - 'wpml' => __('Integrate with WPML', 'site-reviews'), |
|
55 | - ], |
|
56 | - 'type' => 'select', |
|
57 | - ], |
|
58 | - 'settings.general.rebusify' => [ |
|
59 | - 'default' => 'no', |
|
60 | - 'description' => sprintf(__('Integrate with the %s and validate your reviews on the blockchain to increase online reputation, trust, and transparency.', 'site-reviews'), |
|
61 | - '<a href="https://rebusify.com/plans?ref=105" target="_blank">Rebusify Confidence System</a>' |
|
62 | - ), |
|
63 | - 'label' => __('Blockchain Validation', 'site-reviews'), |
|
64 | - 'type' => 'yes_no', |
|
65 | - ], |
|
66 | - 'settings.general.rebusify_email' => [ |
|
67 | - 'default' => '', |
|
68 | - 'depends_on' => [ |
|
69 | - 'settings.general.rebusify' => ['yes'], |
|
70 | - ], |
|
71 | - 'description' => __('Enter your Rebusify account email here.', 'site-reviews'), |
|
72 | - 'label' => __('Rebusify Email', 'site-reviews'), |
|
73 | - 'type' => 'text', |
|
74 | - ], |
|
75 | - 'settings.general.rebusify_serial' => [ |
|
76 | - 'default' => '', |
|
77 | - 'depends_on' => [ |
|
78 | - 'settings.general.rebusify' => ['yes'], |
|
79 | - ], |
|
80 | - 'description' => __('Enter your Rebusify account serial key here.', 'site-reviews'), |
|
81 | - 'label' => __('Rebusify Serial Key', 'site-reviews'), |
|
82 | - 'type' => 'password', |
|
83 | - ], |
|
84 | - 'settings.general.notifications' => [ |
|
85 | - 'default' => [], |
|
86 | - 'label' => __('Notifications', 'site-reviews'), |
|
87 | - 'options' => [ |
|
88 | - 'admin' => __('Send to administrator', 'site-reviews').' <code>'.(string) get_option('admin_email').'</code>', |
|
89 | - 'author' => __('Send to author of the page that the review is assigned to', 'site-reviews'), |
|
90 | - 'custom' => __('Send to one or more email addresses', 'site-reviews'), |
|
91 | - 'slack' => __('Send to <a href="https://slack.com/">Slack</a>', 'site-reviews'), |
|
92 | - ], |
|
93 | - 'type' => 'checkbox', |
|
94 | - ], |
|
95 | - 'settings.general.notification_email' => [ |
|
96 | - 'default' => '', |
|
97 | - 'depends_on' => [ |
|
98 | - 'settings.general.notifications' => ['custom'], |
|
99 | - ], |
|
100 | - 'label' => __('Send Notification Emails To', 'site-reviews'), |
|
101 | - 'placeholder' => __('Separate multiple emails with a comma', 'site-reviews'), |
|
102 | - 'type' => 'text', |
|
103 | - ], |
|
104 | - 'settings.general.notification_slack' => [ |
|
105 | - 'default' => '', |
|
106 | - 'depends_on' => [ |
|
107 | - 'settings.general.notifications' => ['slack'], |
|
108 | - ], |
|
109 | - 'description' => sprintf(__('To send notifications to Slack, create a new %s and then paste the provided Webhook URL in the field above.', 'site-reviews'), |
|
110 | - '<a href="https://api.slack.com/incoming-webhooks">'.__('Incoming WebHook', 'site-reviews').'</a>' |
|
111 | - ), |
|
112 | - 'label' => __('Slack Webhook URL', 'site-reviews'), |
|
113 | - 'type' => 'text', |
|
114 | - ], |
|
115 | - 'settings.general.notification_message' => [ |
|
116 | - 'default' => glsr('Modules\Html\Template')->build('templates/email-notification'), |
|
117 | - 'depends_on' => [ |
|
118 | - 'settings.general.notifications' => ['admin', 'author', 'custom', 'slack'], |
|
119 | - ], |
|
120 | - 'description' => __( |
|
121 | - 'To restore the default text, save an empty template. '. |
|
122 | - 'If you are sending notifications to Slack then this template will only be used as a fallback in the event that <a href="https://api.slack.com/docs/attachments">Message Attachments</a> have been disabled. Available template tags:'. |
|
123 | - '<br><code>{review_rating}</code> The review rating number (1-5)'. |
|
124 | - '<br><code>{review_title}</code> The review title'. |
|
125 | - '<br><code>{review_content}</code> The review content'. |
|
126 | - '<br><code>{review_author}</code> The review author'. |
|
127 | - '<br><code>{review_email}</code> The email of the review author'. |
|
128 | - '<br><code>{review_ip}</code> The IP address of the review author'. |
|
129 | - '<br><code>{review_link}</code> The link to edit/view a review', |
|
130 | - 'site-reviews' |
|
131 | - ), |
|
132 | - 'label' => __('Notification Template', 'site-reviews'), |
|
133 | - 'rows' => 10, |
|
134 | - 'type' => 'code', |
|
135 | - ], |
|
136 | - 'settings.reviews.date.format' => [ |
|
137 | - 'default' => '', |
|
138 | - 'description' => sprintf(__('The default date format is the one set in your %s.', 'site-reviews'), |
|
139 | - '<a href="'.admin_url('options-general.php#date_format_custom').'">'.__('WordPress settings', 'site-reviews').'</a>' |
|
140 | - ), |
|
141 | - 'label' => __('Date Format', 'site-reviews'), |
|
142 | - 'options' => [ |
|
143 | - '' => __('Use the default date format', 'site-reviews'), |
|
144 | - 'relative' => __('Use a relative date format', 'site-reviews'), |
|
145 | - 'custom' => __('Use a custom date format', 'site-reviews'), |
|
146 | - ], |
|
147 | - 'type' => 'select', |
|
148 | - ], |
|
149 | - 'settings.reviews.date.custom' => [ |
|
150 | - 'default' => get_option('date_format'), |
|
151 | - 'depends_on' => [ |
|
152 | - 'settings.reviews.date.format' => 'custom', |
|
153 | - ], |
|
154 | - 'description' => __('Enter a custom date format (<a href="https://codex.wordpress.org/Formatting_Date_and_Time">documentation on date and time formatting</a>).', 'site-reviews'), |
|
155 | - 'label' => __('Custom Date Format', 'site-reviews'), |
|
156 | - 'type' => 'text', |
|
157 | - ], |
|
158 | - 'settings.reviews.name.format' => [ |
|
159 | - 'default' => '', |
|
160 | - 'description' => __('Choose how names are shown in your reviews.', 'site-reviews'), |
|
161 | - 'label' => __('Name Format', 'site-reviews'), |
|
162 | - 'options' => [ |
|
163 | - '' => __('Use the name as given', 'site-reviews'), |
|
164 | - 'first' => __('Use the first name only', 'site-reviews'), |
|
165 | - 'first_initial' => __('Convert first name to an initial', 'site-reviews'), |
|
166 | - 'last_initial' => __('Convert last name to an initial', 'site-reviews'), |
|
167 | - 'initials' => __('Convert to all initials', 'site-reviews'), |
|
168 | - ], |
|
169 | - 'type' => 'select', |
|
170 | - ], |
|
171 | - 'settings.reviews.name.initial' => [ |
|
172 | - 'default' => '', |
|
173 | - 'depends_on' => [ |
|
174 | - 'settings.reviews.name.format' => ['first_initial', 'last_initial', 'initials'], |
|
175 | - ], |
|
176 | - 'description' => __('Choose how the initial is displayed.', 'site-reviews'), |
|
177 | - 'label' => __('Initial Format', 'site-reviews'), |
|
178 | - 'options' => [ |
|
179 | - '' => __('Initial with a space', 'site-reviews'), |
|
180 | - 'period' => __('Initial with a period', 'site-reviews'), |
|
181 | - 'period_space' => __('Initial with a period and a space', 'site-reviews'), |
|
182 | - ], |
|
183 | - 'type' => 'select', |
|
184 | - ], |
|
185 | - 'settings.reviews.assigned_links' => [ |
|
186 | - 'default' => 'no', |
|
187 | - 'description' => __('Display a link to the assigned post of a review.', 'site-reviews'), |
|
188 | - 'label' => __('Enable Assigned Links', 'site-reviews'), |
|
189 | - 'type' => 'yes_no', |
|
190 | - ], |
|
191 | - 'settings.reviews.avatars' => [ |
|
192 | - 'default' => 'no', |
|
193 | - 'description' => __('Display reviewer avatars. These are generated from the email address of the reviewer using <a href="https://gravatar.com">Gravatar</a>.', 'site-reviews'), |
|
194 | - 'label' => __('Enable Avatars', 'site-reviews'), |
|
195 | - 'type' => 'yes_no', |
|
196 | - ], |
|
197 | - 'settings.reviews.avatars_regenerate' => [ |
|
198 | - 'default' => 'no', |
|
199 | - 'depends_on' => [ |
|
200 | - 'settings.reviews.avatars' => 'yes', |
|
201 | - ], |
|
202 | - 'description' => __('Regenerate the avatar whenever a local review is shown?', 'site-reviews'), |
|
203 | - 'label' => __('Regenerate Avatars', 'site-reviews'), |
|
204 | - 'type' => 'yes_no', |
|
205 | - ], |
|
206 | - 'settings.reviews.avatars_size' => [ |
|
207 | - 'default' => 40, |
|
208 | - 'depends_on' => [ |
|
209 | - 'settings.reviews.avatars' => 'yes', |
|
210 | - ], |
|
211 | - 'description' => __('Set the avatar size in pixels.', 'site-reviews'), |
|
212 | - 'label' => __('Avatar Size', 'site-reviews'), |
|
213 | - 'type' => 'number', |
|
214 | - ], |
|
215 | - 'settings.reviews.excerpts' => [ |
|
216 | - 'default' => 'yes', |
|
217 | - 'description' => __('Display an excerpt instead of the full review.', 'site-reviews'), |
|
218 | - 'label' => __('Enable Excerpts', 'site-reviews'), |
|
219 | - 'type' => 'yes_no', |
|
220 | - ], |
|
221 | - 'settings.reviews.excerpts_length' => [ |
|
222 | - 'default' => 55, |
|
223 | - 'depends_on' => [ |
|
224 | - 'settings.reviews.excerpts' => 'yes', |
|
225 | - ], |
|
226 | - 'description' => __('Set the excerpt word length.', 'site-reviews'), |
|
227 | - 'label' => __('Excerpt Length', 'site-reviews'), |
|
228 | - 'type' => 'number', |
|
229 | - ], |
|
230 | - 'settings.reviews.fallback' => [ |
|
231 | - 'default' => 'yes', |
|
232 | - 'description' => sprintf(__('Display the fallback text when there are no reviews to display. This can be changed on the %s page. You may also override this by using the "fallback" option on the shortcode. The default fallback text is: %s', 'site-reviews'), |
|
233 | - '<a href="'.admin_url('edit.php?post_type=site-review&page=settings#!translations').'">'.__('Translations', 'site-reviews').'</a>', |
|
234 | - '<code>'.__('There are no reviews yet. Be the first one to write one.', 'site-reviews').'</code>' |
|
235 | - ), |
|
236 | - 'label' => __('Enable Fallback Text', 'site-reviews'), |
|
237 | - 'type' => 'yes_no', |
|
238 | - ], |
|
239 | - 'settings.schema.type.default' => [ |
|
240 | - 'default' => 'LocalBusiness', |
|
241 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_type</code>', |
|
242 | - 'label' => __('Default Schema Type', 'site-reviews'), |
|
243 | - 'options' => [ |
|
244 | - 'LocalBusiness' => __('Local Business', 'site-reviews'), |
|
245 | - 'Product' => __('Product', 'site-reviews'), |
|
246 | - 'custom' => __('Custom', 'site-reviews'), |
|
247 | - ], |
|
248 | - 'type' => 'select', |
|
249 | - ], |
|
250 | - 'settings.schema.type.custom' => [ |
|
251 | - 'default' => '', |
|
252 | - 'depends_on' => [ |
|
253 | - 'settings.schema.type.default' => 'custom', |
|
254 | - ], |
|
255 | - 'description' => '<a href="https://schema.org/docs/schemas.html">'.__('View more information on schema types here', 'site-reviews').'</a>', |
|
256 | - 'label' => __('Custom Schema Type', 'site-reviews'), |
|
257 | - 'type' => 'text', |
|
258 | - ], |
|
259 | - 'settings.schema.name.default' => [ |
|
260 | - 'default' => 'post', |
|
261 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_name</code>', |
|
262 | - 'label' => __('Default Name', 'site-reviews'), |
|
263 | - 'options' => [ |
|
264 | - 'post' => __('Use the assigned or current page title', 'site-reviews'), |
|
265 | - 'custom' => __('Enter a custom title', 'site-reviews'), |
|
266 | - ], |
|
267 | - 'type' => 'select', |
|
268 | - ], |
|
269 | - 'settings.schema.name.custom' => [ |
|
270 | - 'default' => '', |
|
271 | - 'depends_on' => [ |
|
272 | - 'settings.schema.name.default' => 'custom', |
|
273 | - ], |
|
274 | - 'label' => __('Custom Name', 'site-reviews'), |
|
275 | - 'type' => 'text', |
|
276 | - ], |
|
277 | - 'settings.schema.description.default' => [ |
|
278 | - 'default' => 'post', |
|
279 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_description</code>', |
|
280 | - 'label' => __('Default Description', 'site-reviews'), |
|
281 | - 'options' => [ |
|
282 | - 'post' => __('Use the assigned or current page excerpt', 'site-reviews'), |
|
283 | - 'custom' => __('Enter a custom description', 'site-reviews'), |
|
284 | - ], |
|
285 | - 'type' => 'select', |
|
286 | - ], |
|
287 | - 'settings.schema.description.custom' => [ |
|
288 | - 'default' => '', |
|
289 | - 'depends_on' => [ |
|
290 | - 'settings.schema.description.default' => 'custom', |
|
291 | - ], |
|
292 | - 'label' => __('Custom Description', 'site-reviews'), |
|
293 | - 'type' => 'text', |
|
294 | - ], |
|
295 | - 'settings.schema.url.default' => [ |
|
296 | - 'default' => 'post', |
|
297 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_url</code>', |
|
298 | - 'label' => __('Default URL', 'site-reviews'), |
|
299 | - 'options' => [ |
|
300 | - 'post' => __('Use the assigned or current page URL', 'site-reviews'), |
|
301 | - 'custom' => __('Enter a custom URL', 'site-reviews'), |
|
302 | - ], |
|
303 | - 'type' => 'select', |
|
304 | - ], |
|
305 | - 'settings.schema.url.custom' => [ |
|
306 | - 'default' => '', |
|
307 | - 'depends_on' => [ |
|
308 | - 'settings.schema.url.default' => 'custom', |
|
309 | - ], |
|
310 | - 'label' => __('Custom URL', 'site-reviews'), |
|
311 | - 'type' => 'text', |
|
312 | - ], |
|
313 | - 'settings.schema.image.default' => [ |
|
314 | - 'default' => 'post', |
|
315 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_image</code>', |
|
316 | - 'label' => __('Default Image', 'site-reviews'), |
|
317 | - 'options' => [ |
|
318 | - 'post' => __('Use the featured image of the assigned or current page', 'site-reviews'), |
|
319 | - 'custom' => __('Enter a custom image URL', 'site-reviews'), |
|
320 | - ], |
|
321 | - 'type' => 'select', |
|
322 | - ], |
|
323 | - 'settings.schema.image.custom' => [ |
|
324 | - 'default' => '', |
|
325 | - 'depends_on' => [ |
|
326 | - 'settings.schema.image.default' => 'custom', |
|
327 | - ], |
|
328 | - 'label' => __('Custom Image URL', 'site-reviews'), |
|
329 | - 'type' => 'text', |
|
330 | - ], |
|
331 | - 'settings.schema.address' => [ |
|
332 | - 'default' => '', |
|
333 | - 'depends_on' => [ |
|
334 | - 'settings.schema.type.default' => 'LocalBusiness', |
|
335 | - ], |
|
336 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_address</code>', |
|
337 | - 'label' => __('Address', 'site-reviews'), |
|
338 | - 'placeholder' => '60 29th Street #343, San Francisco, CA 94110, US', |
|
339 | - 'type' => 'text', |
|
340 | - ], |
|
341 | - 'settings.schema.telephone' => [ |
|
342 | - 'default' => '', |
|
343 | - 'depends_on' => [ |
|
344 | - 'settings.schema.type.default' => 'LocalBusiness', |
|
345 | - ], |
|
346 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_telephone</code>', |
|
347 | - 'label' => __('Telephone Number', 'site-reviews'), |
|
348 | - 'placeholder' => '+1 (877) 273-3049', |
|
349 | - 'type' => 'text', |
|
350 | - ], |
|
351 | - 'settings.schema.pricerange' => [ |
|
352 | - 'default' => '', |
|
353 | - 'depends_on' => [ |
|
354 | - 'settings.schema.type.default' => 'LocalBusiness', |
|
355 | - ], |
|
356 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricerange</code>', |
|
357 | - 'label' => __('Price Range', 'site-reviews'), |
|
358 | - 'placeholder' => '$$-$$$', |
|
359 | - 'type' => 'text', |
|
360 | - ], |
|
361 | - 'settings.schema.offertype' => [ |
|
362 | - 'default' => 'AggregateOffer', |
|
363 | - 'depends_on' => [ |
|
364 | - 'settings.schema.type.default' => 'Product', |
|
365 | - ], |
|
366 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_offertype</code>', |
|
367 | - 'label' => __('Offer Type', 'site-reviews'), |
|
368 | - 'options' => [ |
|
369 | - 'AggregateOffer' => __('AggregateOffer', 'site-reviews'), |
|
370 | - 'Offer' => __('Offer', 'site-reviews'), |
|
371 | - ], |
|
372 | - 'type' => 'select', |
|
373 | - ], |
|
374 | - 'settings.schema.price' => [ |
|
375 | - 'default' => '', |
|
376 | - 'depends_on' => [ |
|
377 | - 'settings.schema.type.default' => 'Product', |
|
378 | - 'settings.schema.offertype' => 'Offer', |
|
379 | - ], |
|
380 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_price</code>', |
|
381 | - 'label' => __('Price', 'site-reviews'), |
|
382 | - 'placeholder' => '50.00', |
|
383 | - 'type' => 'text', |
|
384 | - ], |
|
385 | - 'settings.schema.lowprice' => [ |
|
386 | - 'default' => '', |
|
387 | - 'depends_on' => [ |
|
388 | - 'settings.schema.type.default' => 'Product', |
|
389 | - 'settings.schema.offertype' => 'AggregateOffer', |
|
390 | - ], |
|
391 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_lowprice</code>', |
|
392 | - 'label' => __('Low Price', 'site-reviews'), |
|
393 | - 'placeholder' => '10.00', |
|
394 | - 'type' => 'text', |
|
395 | - ], |
|
396 | - 'settings.schema.highprice' => [ |
|
397 | - 'default' => '', |
|
398 | - 'depends_on' => [ |
|
399 | - 'settings.schema.type.default' => 'Product', |
|
400 | - 'settings.schema.offertype' => 'AggregateOffer', |
|
401 | - ], |
|
402 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_highprice</code>', |
|
403 | - 'label' => __('High Price', 'site-reviews'), |
|
404 | - 'placeholder' => '100.00', |
|
405 | - 'type' => 'text', |
|
406 | - ], |
|
407 | - 'settings.schema.pricecurrency' => [ |
|
408 | - 'default' => '', |
|
409 | - 'depends_on' => [ |
|
410 | - 'settings.schema.type.default' => 'Product', |
|
411 | - ], |
|
412 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricecurrency</code>', |
|
413 | - 'label' => __('Price Currency', 'site-reviews'), |
|
414 | - 'placeholder' => 'USD', |
|
415 | - 'type' => 'text', |
|
416 | - ], |
|
417 | - 'settings.submissions.required' => [ |
|
418 | - 'default' => ['content', 'email', 'name', 'rating', 'terms', 'title'], |
|
419 | - 'description' => __('Choose which fields should be required in the submission form.', 'site-reviews'), |
|
420 | - 'label' => __('Required Fields', 'site-reviews'), |
|
421 | - 'options' => [ |
|
422 | - 'rating' => __('Rating', 'site-reviews'), |
|
423 | - 'title' => __('Title', 'site-reviews'), |
|
424 | - 'content' => __('Review', 'site-reviews'), |
|
425 | - 'name' => __('Name', 'site-reviews'), |
|
426 | - 'email' => __('Email', 'site-reviews'), |
|
427 | - 'terms' => __('Terms', 'site-reviews'), |
|
428 | - ], |
|
429 | - 'type' => 'checkbox', |
|
430 | - ], |
|
431 | - 'settings.submissions.limit' => [ |
|
432 | - 'default' => '', |
|
433 | - 'description' => __('Limits the number of reviews that can be submitted to one-per-person. If you are assigning reviews, then the limit will be applied to the assigned page or category.', 'site-reviews'), |
|
434 | - 'label' => __('Limit Reviews', 'site-reviews'), |
|
435 | - 'options' => [ |
|
436 | - '' => __('No Limit', 'site-reviews'), |
|
437 | - 'email' => __('By Email Address', 'site-reviews'), |
|
438 | - 'ip_address' => __('By IP Address', 'site-reviews'), |
|
439 | - 'username' => __('By Username (will only work for registered users)', 'site-reviews'), |
|
440 | - ], |
|
441 | - 'type' => 'select', |
|
442 | - ], |
|
443 | - 'settings.submissions.limit_whitelist.email' => [ |
|
444 | - 'default' => '', |
|
445 | - 'depends_on' => [ |
|
446 | - 'settings.submissions.limit' => ['email'], |
|
447 | - ], |
|
448 | - 'description' => __('One Email per line. All emails in the whitelist will be excluded from the review submission limit.', 'site-reviews'), |
|
449 | - 'label' => __('Email Whitelist', 'site-reviews'), |
|
450 | - 'rows' => 5, |
|
451 | - 'type' => 'code', |
|
452 | - ], |
|
453 | - 'settings.submissions.limit_whitelist.ip_address' => [ |
|
454 | - 'default' => '', |
|
455 | - 'depends_on' => [ |
|
456 | - 'settings.submissions.limit' => ['ip_address'], |
|
457 | - ], |
|
458 | - 'description' => __('One IP Address per line. All IP Addresses in the whitelist will be excluded from the review submission limit..', 'site-reviews'), |
|
459 | - 'label' => __('IP Address Whitelist', 'site-reviews'), |
|
460 | - 'rows' => 5, |
|
461 | - 'type' => 'code', |
|
462 | - ], |
|
463 | - 'settings.submissions.limit_whitelist.username' => [ |
|
464 | - 'default' => '', |
|
465 | - 'depends_on' => [ |
|
466 | - 'settings.submissions.limit' => ['username'], |
|
467 | - ], |
|
468 | - 'description' => __('One Username per line. All registered users with a Username in the whitelist will be excluded from the review submission limit.', 'site-reviews'), |
|
469 | - 'label' => __('Username Whitelist', 'site-reviews'), |
|
470 | - 'rows' => 5, |
|
471 | - 'type' => 'code', |
|
472 | - ], |
|
473 | - 'settings.submissions.recaptcha.integration' => [ |
|
474 | - 'default' => '', |
|
475 | - 'description' => __('Invisible reCAPTCHA is a free anti-spam service from Google. To use it, you will need to <a href="https://www.google.com/recaptcha/admin" target="_blank">sign up</a> for an API key pair for your site.', 'site-reviews'), |
|
476 | - 'label' => __('Invisible reCAPTCHA', 'site-reviews'), |
|
477 | - 'options' => [ |
|
478 | - '' => 'Do not use reCAPTCHA', |
|
479 | - 'all' => 'Use reCAPTCHA', |
|
480 | - 'guest' => 'Use reCAPTCHA only for guest users', |
|
481 | - ], |
|
482 | - 'type' => 'select', |
|
483 | - ], |
|
484 | - 'settings.submissions.recaptcha.key' => [ |
|
485 | - 'default' => '', |
|
486 | - 'depends_on' => [ |
|
487 | - 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
488 | - ], |
|
489 | - 'label' => __('Site Key', 'site-reviews'), |
|
490 | - 'type' => 'text', |
|
491 | - ], |
|
492 | - 'settings.submissions.recaptcha.secret' => [ |
|
493 | - 'default' => '', |
|
494 | - 'depends_on' => [ |
|
495 | - 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
496 | - ], |
|
497 | - 'label' => __('Site Secret', 'site-reviews'), |
|
498 | - 'type' => 'text', |
|
499 | - ], |
|
500 | - 'settings.submissions.recaptcha.position' => [ |
|
501 | - 'default' => 'bottomleft', |
|
502 | - 'depends_on' => [ |
|
503 | - 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
504 | - ], |
|
505 | - 'description' => __('This option may not work consistently if another plugin is loading reCAPTCHA on the same page as Site Reviews.', 'site-reviews'), |
|
506 | - 'label' => __('Badge Position', 'site-reviews'), |
|
507 | - 'options' => [ |
|
508 | - 'bottomleft' => 'Bottom Left', |
|
509 | - 'bottomright' => 'Bottom Right', |
|
510 | - 'inline' => 'Inline', |
|
511 | - ], |
|
512 | - 'type' => 'select', |
|
513 | - ], |
|
514 | - 'settings.submissions.akismet' => [ |
|
515 | - 'default' => 'no', |
|
516 | - 'description' => __('The <a href="https://akismet.com" target="_blank">Akismet plugin</a> integration provides spam-filtering for your reviews. In order for this setting to have any affect, you will need to first install and activate the Akismet plugin and set up a WordPress.com API key.', 'site-reviews'), |
|
517 | - 'label' => __('Enable Akismet Integration', 'site-reviews'), |
|
518 | - 'type' => 'yes_no', |
|
519 | - ], |
|
520 | - 'settings.submissions.blacklist.integration' => [ |
|
521 | - 'default' => '', |
|
522 | - 'description' => sprintf(__('Choose which Blacklist you would prefer to use for reviews. The %s can be found in the WordPress Discussion Settings page.', 'site-reviews'), |
|
523 | - '<a href="'.admin_url('options-discussion.php#users_can_register').'">'.__('Comment Blacklist', 'site-reviews').'</a>' |
|
524 | - ), |
|
525 | - 'label' => __('Blacklist', 'site-reviews'), |
|
526 | - 'options' => [ |
|
527 | - '' => 'Use the Site Reviews Blacklist', |
|
528 | - 'comments' => 'Use the WordPress Comment Blacklist', |
|
529 | - ], |
|
530 | - 'type' => 'select', |
|
531 | - ], |
|
532 | - 'settings.submissions.blacklist.entries' => [ |
|
533 | - 'default' => '', |
|
534 | - 'depends_on' => [ |
|
535 | - 'settings.submissions.blacklist.integration' => [''], |
|
536 | - ], |
|
537 | - 'description' => __('One entry or IP address per line. When a review contains any of these entries in its title, content, name, email, or IP address, it will be rejected. It is case-insensitive and will match partial words, so "press" will match "WordPress".', 'site-reviews'), |
|
538 | - 'label' => __('Review Blacklist', 'site-reviews'), |
|
539 | - 'rows' => 10, |
|
540 | - 'type' => 'code', |
|
541 | - ], |
|
542 | - 'settings.submissions.blacklist.action' => [ |
|
543 | - 'default' => 'unapprove', |
|
544 | - 'description' => __('Choose the action that should be taken when a review is blacklisted.', 'site-reviews'), |
|
545 | - 'label' => __('Blacklist Action', 'site-reviews'), |
|
546 | - 'options' => [ |
|
547 | - 'unapprove' => __('Require approval', 'site-reviews'), |
|
548 | - 'reject' => __('Reject submission', 'site-reviews'), |
|
549 | - ], |
|
550 | - 'type' => 'select', |
|
551 | - ], |
|
4 | + 'settings.general.style' => [ |
|
5 | + 'default' => 'default', |
|
6 | + 'description' => __('Site Reviews relies on the CSS of your theme to style the submission form. If your theme does not provide proper CSS rules for form elements and you are using a WordPress plugin/theme or CSS Framework listed here, please try selecting it, otherwise choose "Site Reviews (default)".', 'site-reviews'), |
|
7 | + 'label' => __('Plugin Style', 'site-reviews'), |
|
8 | + 'options' => [ |
|
9 | + 'bootstrap_4' => 'CSS Framework: Bootstrap 4', |
|
10 | + 'bootstrap_4_custom' => 'CSS Framework: Bootstrap 4 (Custom Forms)', |
|
11 | + 'contact_form_7' => 'Plugin: Contact Form 7 (v5)', |
|
12 | + 'ninja_forms' => 'Plugin: Ninja Forms (v3)', |
|
13 | + 'wpforms' => 'Plugin: WPForms Lite (v1)', |
|
14 | + 'default' => __('Site Reviews (default)', 'site-reviews'), |
|
15 | + 'minimal' => __('Site Reviews (minimal)', 'site-reviews'), |
|
16 | + 'divi' => 'Theme: Divi (v3)', |
|
17 | + 'materialize' => 'Theme: Materialize', |
|
18 | + 'twentyfifteen' => 'Theme: Twenty Fifteen', |
|
19 | + 'twentyseventeen' => 'Theme: Twenty Seventeen', |
|
20 | + 'twentynineteen' => 'Theme: Twenty Nineteen', |
|
21 | + ], |
|
22 | + 'type' => 'select', |
|
23 | + ], |
|
24 | + 'settings.general.require.approval' => [ |
|
25 | + 'default' => 'no', |
|
26 | + 'description' => __('Set the status of new review submissions to "unapproved".', 'site-reviews'), |
|
27 | + 'label' => __('Require Approval', 'site-reviews'), |
|
28 | + 'type' => 'yes_no', |
|
29 | + ], |
|
30 | + 'settings.general.require.login' => [ |
|
31 | + 'default' => 'no', |
|
32 | + 'description' => __('Only allow review submissions from registered users.', 'site-reviews'), |
|
33 | + 'label' => __('Require Login', 'site-reviews'), |
|
34 | + 'type' => 'yes_no', |
|
35 | + ], |
|
36 | + 'settings.general.require.login_register' => [ |
|
37 | + 'default' => 'no', |
|
38 | + 'depends_on' => [ |
|
39 | + 'settings.general.require.login' => 'yes', |
|
40 | + ], |
|
41 | + 'description' => sprintf(__('Show a link for a new user to register. The %s Membership option must be enabled in General Settings for this to work.', 'site-reviews'), |
|
42 | + '<a href="'.admin_url('options-general.php#users_can_register').'">'.__('Anyone can register', 'site-reviews').'</a>' |
|
43 | + ), |
|
44 | + 'label' => __('Show Registration Link', 'site-reviews'), |
|
45 | + 'type' => 'yes_no', |
|
46 | + ], |
|
47 | + 'settings.general.multilingual' => [ |
|
48 | + 'default' => '', |
|
49 | + 'description' => __('Integrate with a multilingual plugin to calculate ratings for all languages of a post.', 'site-reviews'), |
|
50 | + 'label' => __('Multilingual', 'site-reviews'), |
|
51 | + 'options' => [ |
|
52 | + '' => __('No Integration', 'site-reviews'), |
|
53 | + 'polylang' => __('Integrate with Polylang', 'site-reviews'), |
|
54 | + 'wpml' => __('Integrate with WPML', 'site-reviews'), |
|
55 | + ], |
|
56 | + 'type' => 'select', |
|
57 | + ], |
|
58 | + 'settings.general.rebusify' => [ |
|
59 | + 'default' => 'no', |
|
60 | + 'description' => sprintf(__('Integrate with the %s and validate your reviews on the blockchain to increase online reputation, trust, and transparency.', 'site-reviews'), |
|
61 | + '<a href="https://rebusify.com/plans?ref=105" target="_blank">Rebusify Confidence System</a>' |
|
62 | + ), |
|
63 | + 'label' => __('Blockchain Validation', 'site-reviews'), |
|
64 | + 'type' => 'yes_no', |
|
65 | + ], |
|
66 | + 'settings.general.rebusify_email' => [ |
|
67 | + 'default' => '', |
|
68 | + 'depends_on' => [ |
|
69 | + 'settings.general.rebusify' => ['yes'], |
|
70 | + ], |
|
71 | + 'description' => __('Enter your Rebusify account email here.', 'site-reviews'), |
|
72 | + 'label' => __('Rebusify Email', 'site-reviews'), |
|
73 | + 'type' => 'text', |
|
74 | + ], |
|
75 | + 'settings.general.rebusify_serial' => [ |
|
76 | + 'default' => '', |
|
77 | + 'depends_on' => [ |
|
78 | + 'settings.general.rebusify' => ['yes'], |
|
79 | + ], |
|
80 | + 'description' => __('Enter your Rebusify account serial key here.', 'site-reviews'), |
|
81 | + 'label' => __('Rebusify Serial Key', 'site-reviews'), |
|
82 | + 'type' => 'password', |
|
83 | + ], |
|
84 | + 'settings.general.notifications' => [ |
|
85 | + 'default' => [], |
|
86 | + 'label' => __('Notifications', 'site-reviews'), |
|
87 | + 'options' => [ |
|
88 | + 'admin' => __('Send to administrator', 'site-reviews').' <code>'.(string) get_option('admin_email').'</code>', |
|
89 | + 'author' => __('Send to author of the page that the review is assigned to', 'site-reviews'), |
|
90 | + 'custom' => __('Send to one or more email addresses', 'site-reviews'), |
|
91 | + 'slack' => __('Send to <a href="https://slack.com/">Slack</a>', 'site-reviews'), |
|
92 | + ], |
|
93 | + 'type' => 'checkbox', |
|
94 | + ], |
|
95 | + 'settings.general.notification_email' => [ |
|
96 | + 'default' => '', |
|
97 | + 'depends_on' => [ |
|
98 | + 'settings.general.notifications' => ['custom'], |
|
99 | + ], |
|
100 | + 'label' => __('Send Notification Emails To', 'site-reviews'), |
|
101 | + 'placeholder' => __('Separate multiple emails with a comma', 'site-reviews'), |
|
102 | + 'type' => 'text', |
|
103 | + ], |
|
104 | + 'settings.general.notification_slack' => [ |
|
105 | + 'default' => '', |
|
106 | + 'depends_on' => [ |
|
107 | + 'settings.general.notifications' => ['slack'], |
|
108 | + ], |
|
109 | + 'description' => sprintf(__('To send notifications to Slack, create a new %s and then paste the provided Webhook URL in the field above.', 'site-reviews'), |
|
110 | + '<a href="https://api.slack.com/incoming-webhooks">'.__('Incoming WebHook', 'site-reviews').'</a>' |
|
111 | + ), |
|
112 | + 'label' => __('Slack Webhook URL', 'site-reviews'), |
|
113 | + 'type' => 'text', |
|
114 | + ], |
|
115 | + 'settings.general.notification_message' => [ |
|
116 | + 'default' => glsr('Modules\Html\Template')->build('templates/email-notification'), |
|
117 | + 'depends_on' => [ |
|
118 | + 'settings.general.notifications' => ['admin', 'author', 'custom', 'slack'], |
|
119 | + ], |
|
120 | + 'description' => __( |
|
121 | + 'To restore the default text, save an empty template. '. |
|
122 | + 'If you are sending notifications to Slack then this template will only be used as a fallback in the event that <a href="https://api.slack.com/docs/attachments">Message Attachments</a> have been disabled. Available template tags:'. |
|
123 | + '<br><code>{review_rating}</code> The review rating number (1-5)'. |
|
124 | + '<br><code>{review_title}</code> The review title'. |
|
125 | + '<br><code>{review_content}</code> The review content'. |
|
126 | + '<br><code>{review_author}</code> The review author'. |
|
127 | + '<br><code>{review_email}</code> The email of the review author'. |
|
128 | + '<br><code>{review_ip}</code> The IP address of the review author'. |
|
129 | + '<br><code>{review_link}</code> The link to edit/view a review', |
|
130 | + 'site-reviews' |
|
131 | + ), |
|
132 | + 'label' => __('Notification Template', 'site-reviews'), |
|
133 | + 'rows' => 10, |
|
134 | + 'type' => 'code', |
|
135 | + ], |
|
136 | + 'settings.reviews.date.format' => [ |
|
137 | + 'default' => '', |
|
138 | + 'description' => sprintf(__('The default date format is the one set in your %s.', 'site-reviews'), |
|
139 | + '<a href="'.admin_url('options-general.php#date_format_custom').'">'.__('WordPress settings', 'site-reviews').'</a>' |
|
140 | + ), |
|
141 | + 'label' => __('Date Format', 'site-reviews'), |
|
142 | + 'options' => [ |
|
143 | + '' => __('Use the default date format', 'site-reviews'), |
|
144 | + 'relative' => __('Use a relative date format', 'site-reviews'), |
|
145 | + 'custom' => __('Use a custom date format', 'site-reviews'), |
|
146 | + ], |
|
147 | + 'type' => 'select', |
|
148 | + ], |
|
149 | + 'settings.reviews.date.custom' => [ |
|
150 | + 'default' => get_option('date_format'), |
|
151 | + 'depends_on' => [ |
|
152 | + 'settings.reviews.date.format' => 'custom', |
|
153 | + ], |
|
154 | + 'description' => __('Enter a custom date format (<a href="https://codex.wordpress.org/Formatting_Date_and_Time">documentation on date and time formatting</a>).', 'site-reviews'), |
|
155 | + 'label' => __('Custom Date Format', 'site-reviews'), |
|
156 | + 'type' => 'text', |
|
157 | + ], |
|
158 | + 'settings.reviews.name.format' => [ |
|
159 | + 'default' => '', |
|
160 | + 'description' => __('Choose how names are shown in your reviews.', 'site-reviews'), |
|
161 | + 'label' => __('Name Format', 'site-reviews'), |
|
162 | + 'options' => [ |
|
163 | + '' => __('Use the name as given', 'site-reviews'), |
|
164 | + 'first' => __('Use the first name only', 'site-reviews'), |
|
165 | + 'first_initial' => __('Convert first name to an initial', 'site-reviews'), |
|
166 | + 'last_initial' => __('Convert last name to an initial', 'site-reviews'), |
|
167 | + 'initials' => __('Convert to all initials', 'site-reviews'), |
|
168 | + ], |
|
169 | + 'type' => 'select', |
|
170 | + ], |
|
171 | + 'settings.reviews.name.initial' => [ |
|
172 | + 'default' => '', |
|
173 | + 'depends_on' => [ |
|
174 | + 'settings.reviews.name.format' => ['first_initial', 'last_initial', 'initials'], |
|
175 | + ], |
|
176 | + 'description' => __('Choose how the initial is displayed.', 'site-reviews'), |
|
177 | + 'label' => __('Initial Format', 'site-reviews'), |
|
178 | + 'options' => [ |
|
179 | + '' => __('Initial with a space', 'site-reviews'), |
|
180 | + 'period' => __('Initial with a period', 'site-reviews'), |
|
181 | + 'period_space' => __('Initial with a period and a space', 'site-reviews'), |
|
182 | + ], |
|
183 | + 'type' => 'select', |
|
184 | + ], |
|
185 | + 'settings.reviews.assigned_links' => [ |
|
186 | + 'default' => 'no', |
|
187 | + 'description' => __('Display a link to the assigned post of a review.', 'site-reviews'), |
|
188 | + 'label' => __('Enable Assigned Links', 'site-reviews'), |
|
189 | + 'type' => 'yes_no', |
|
190 | + ], |
|
191 | + 'settings.reviews.avatars' => [ |
|
192 | + 'default' => 'no', |
|
193 | + 'description' => __('Display reviewer avatars. These are generated from the email address of the reviewer using <a href="https://gravatar.com">Gravatar</a>.', 'site-reviews'), |
|
194 | + 'label' => __('Enable Avatars', 'site-reviews'), |
|
195 | + 'type' => 'yes_no', |
|
196 | + ], |
|
197 | + 'settings.reviews.avatars_regenerate' => [ |
|
198 | + 'default' => 'no', |
|
199 | + 'depends_on' => [ |
|
200 | + 'settings.reviews.avatars' => 'yes', |
|
201 | + ], |
|
202 | + 'description' => __('Regenerate the avatar whenever a local review is shown?', 'site-reviews'), |
|
203 | + 'label' => __('Regenerate Avatars', 'site-reviews'), |
|
204 | + 'type' => 'yes_no', |
|
205 | + ], |
|
206 | + 'settings.reviews.avatars_size' => [ |
|
207 | + 'default' => 40, |
|
208 | + 'depends_on' => [ |
|
209 | + 'settings.reviews.avatars' => 'yes', |
|
210 | + ], |
|
211 | + 'description' => __('Set the avatar size in pixels.', 'site-reviews'), |
|
212 | + 'label' => __('Avatar Size', 'site-reviews'), |
|
213 | + 'type' => 'number', |
|
214 | + ], |
|
215 | + 'settings.reviews.excerpts' => [ |
|
216 | + 'default' => 'yes', |
|
217 | + 'description' => __('Display an excerpt instead of the full review.', 'site-reviews'), |
|
218 | + 'label' => __('Enable Excerpts', 'site-reviews'), |
|
219 | + 'type' => 'yes_no', |
|
220 | + ], |
|
221 | + 'settings.reviews.excerpts_length' => [ |
|
222 | + 'default' => 55, |
|
223 | + 'depends_on' => [ |
|
224 | + 'settings.reviews.excerpts' => 'yes', |
|
225 | + ], |
|
226 | + 'description' => __('Set the excerpt word length.', 'site-reviews'), |
|
227 | + 'label' => __('Excerpt Length', 'site-reviews'), |
|
228 | + 'type' => 'number', |
|
229 | + ], |
|
230 | + 'settings.reviews.fallback' => [ |
|
231 | + 'default' => 'yes', |
|
232 | + 'description' => sprintf(__('Display the fallback text when there are no reviews to display. This can be changed on the %s page. You may also override this by using the "fallback" option on the shortcode. The default fallback text is: %s', 'site-reviews'), |
|
233 | + '<a href="'.admin_url('edit.php?post_type=site-review&page=settings#!translations').'">'.__('Translations', 'site-reviews').'</a>', |
|
234 | + '<code>'.__('There are no reviews yet. Be the first one to write one.', 'site-reviews').'</code>' |
|
235 | + ), |
|
236 | + 'label' => __('Enable Fallback Text', 'site-reviews'), |
|
237 | + 'type' => 'yes_no', |
|
238 | + ], |
|
239 | + 'settings.schema.type.default' => [ |
|
240 | + 'default' => 'LocalBusiness', |
|
241 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_type</code>', |
|
242 | + 'label' => __('Default Schema Type', 'site-reviews'), |
|
243 | + 'options' => [ |
|
244 | + 'LocalBusiness' => __('Local Business', 'site-reviews'), |
|
245 | + 'Product' => __('Product', 'site-reviews'), |
|
246 | + 'custom' => __('Custom', 'site-reviews'), |
|
247 | + ], |
|
248 | + 'type' => 'select', |
|
249 | + ], |
|
250 | + 'settings.schema.type.custom' => [ |
|
251 | + 'default' => '', |
|
252 | + 'depends_on' => [ |
|
253 | + 'settings.schema.type.default' => 'custom', |
|
254 | + ], |
|
255 | + 'description' => '<a href="https://schema.org/docs/schemas.html">'.__('View more information on schema types here', 'site-reviews').'</a>', |
|
256 | + 'label' => __('Custom Schema Type', 'site-reviews'), |
|
257 | + 'type' => 'text', |
|
258 | + ], |
|
259 | + 'settings.schema.name.default' => [ |
|
260 | + 'default' => 'post', |
|
261 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_name</code>', |
|
262 | + 'label' => __('Default Name', 'site-reviews'), |
|
263 | + 'options' => [ |
|
264 | + 'post' => __('Use the assigned or current page title', 'site-reviews'), |
|
265 | + 'custom' => __('Enter a custom title', 'site-reviews'), |
|
266 | + ], |
|
267 | + 'type' => 'select', |
|
268 | + ], |
|
269 | + 'settings.schema.name.custom' => [ |
|
270 | + 'default' => '', |
|
271 | + 'depends_on' => [ |
|
272 | + 'settings.schema.name.default' => 'custom', |
|
273 | + ], |
|
274 | + 'label' => __('Custom Name', 'site-reviews'), |
|
275 | + 'type' => 'text', |
|
276 | + ], |
|
277 | + 'settings.schema.description.default' => [ |
|
278 | + 'default' => 'post', |
|
279 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_description</code>', |
|
280 | + 'label' => __('Default Description', 'site-reviews'), |
|
281 | + 'options' => [ |
|
282 | + 'post' => __('Use the assigned or current page excerpt', 'site-reviews'), |
|
283 | + 'custom' => __('Enter a custom description', 'site-reviews'), |
|
284 | + ], |
|
285 | + 'type' => 'select', |
|
286 | + ], |
|
287 | + 'settings.schema.description.custom' => [ |
|
288 | + 'default' => '', |
|
289 | + 'depends_on' => [ |
|
290 | + 'settings.schema.description.default' => 'custom', |
|
291 | + ], |
|
292 | + 'label' => __('Custom Description', 'site-reviews'), |
|
293 | + 'type' => 'text', |
|
294 | + ], |
|
295 | + 'settings.schema.url.default' => [ |
|
296 | + 'default' => 'post', |
|
297 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_url</code>', |
|
298 | + 'label' => __('Default URL', 'site-reviews'), |
|
299 | + 'options' => [ |
|
300 | + 'post' => __('Use the assigned or current page URL', 'site-reviews'), |
|
301 | + 'custom' => __('Enter a custom URL', 'site-reviews'), |
|
302 | + ], |
|
303 | + 'type' => 'select', |
|
304 | + ], |
|
305 | + 'settings.schema.url.custom' => [ |
|
306 | + 'default' => '', |
|
307 | + 'depends_on' => [ |
|
308 | + 'settings.schema.url.default' => 'custom', |
|
309 | + ], |
|
310 | + 'label' => __('Custom URL', 'site-reviews'), |
|
311 | + 'type' => 'text', |
|
312 | + ], |
|
313 | + 'settings.schema.image.default' => [ |
|
314 | + 'default' => 'post', |
|
315 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_image</code>', |
|
316 | + 'label' => __('Default Image', 'site-reviews'), |
|
317 | + 'options' => [ |
|
318 | + 'post' => __('Use the featured image of the assigned or current page', 'site-reviews'), |
|
319 | + 'custom' => __('Enter a custom image URL', 'site-reviews'), |
|
320 | + ], |
|
321 | + 'type' => 'select', |
|
322 | + ], |
|
323 | + 'settings.schema.image.custom' => [ |
|
324 | + 'default' => '', |
|
325 | + 'depends_on' => [ |
|
326 | + 'settings.schema.image.default' => 'custom', |
|
327 | + ], |
|
328 | + 'label' => __('Custom Image URL', 'site-reviews'), |
|
329 | + 'type' => 'text', |
|
330 | + ], |
|
331 | + 'settings.schema.address' => [ |
|
332 | + 'default' => '', |
|
333 | + 'depends_on' => [ |
|
334 | + 'settings.schema.type.default' => 'LocalBusiness', |
|
335 | + ], |
|
336 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_address</code>', |
|
337 | + 'label' => __('Address', 'site-reviews'), |
|
338 | + 'placeholder' => '60 29th Street #343, San Francisco, CA 94110, US', |
|
339 | + 'type' => 'text', |
|
340 | + ], |
|
341 | + 'settings.schema.telephone' => [ |
|
342 | + 'default' => '', |
|
343 | + 'depends_on' => [ |
|
344 | + 'settings.schema.type.default' => 'LocalBusiness', |
|
345 | + ], |
|
346 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_telephone</code>', |
|
347 | + 'label' => __('Telephone Number', 'site-reviews'), |
|
348 | + 'placeholder' => '+1 (877) 273-3049', |
|
349 | + 'type' => 'text', |
|
350 | + ], |
|
351 | + 'settings.schema.pricerange' => [ |
|
352 | + 'default' => '', |
|
353 | + 'depends_on' => [ |
|
354 | + 'settings.schema.type.default' => 'LocalBusiness', |
|
355 | + ], |
|
356 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricerange</code>', |
|
357 | + 'label' => __('Price Range', 'site-reviews'), |
|
358 | + 'placeholder' => '$$-$$$', |
|
359 | + 'type' => 'text', |
|
360 | + ], |
|
361 | + 'settings.schema.offertype' => [ |
|
362 | + 'default' => 'AggregateOffer', |
|
363 | + 'depends_on' => [ |
|
364 | + 'settings.schema.type.default' => 'Product', |
|
365 | + ], |
|
366 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_offertype</code>', |
|
367 | + 'label' => __('Offer Type', 'site-reviews'), |
|
368 | + 'options' => [ |
|
369 | + 'AggregateOffer' => __('AggregateOffer', 'site-reviews'), |
|
370 | + 'Offer' => __('Offer', 'site-reviews'), |
|
371 | + ], |
|
372 | + 'type' => 'select', |
|
373 | + ], |
|
374 | + 'settings.schema.price' => [ |
|
375 | + 'default' => '', |
|
376 | + 'depends_on' => [ |
|
377 | + 'settings.schema.type.default' => 'Product', |
|
378 | + 'settings.schema.offertype' => 'Offer', |
|
379 | + ], |
|
380 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_price</code>', |
|
381 | + 'label' => __('Price', 'site-reviews'), |
|
382 | + 'placeholder' => '50.00', |
|
383 | + 'type' => 'text', |
|
384 | + ], |
|
385 | + 'settings.schema.lowprice' => [ |
|
386 | + 'default' => '', |
|
387 | + 'depends_on' => [ |
|
388 | + 'settings.schema.type.default' => 'Product', |
|
389 | + 'settings.schema.offertype' => 'AggregateOffer', |
|
390 | + ], |
|
391 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_lowprice</code>', |
|
392 | + 'label' => __('Low Price', 'site-reviews'), |
|
393 | + 'placeholder' => '10.00', |
|
394 | + 'type' => 'text', |
|
395 | + ], |
|
396 | + 'settings.schema.highprice' => [ |
|
397 | + 'default' => '', |
|
398 | + 'depends_on' => [ |
|
399 | + 'settings.schema.type.default' => 'Product', |
|
400 | + 'settings.schema.offertype' => 'AggregateOffer', |
|
401 | + ], |
|
402 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_highprice</code>', |
|
403 | + 'label' => __('High Price', 'site-reviews'), |
|
404 | + 'placeholder' => '100.00', |
|
405 | + 'type' => 'text', |
|
406 | + ], |
|
407 | + 'settings.schema.pricecurrency' => [ |
|
408 | + 'default' => '', |
|
409 | + 'depends_on' => [ |
|
410 | + 'settings.schema.type.default' => 'Product', |
|
411 | + ], |
|
412 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricecurrency</code>', |
|
413 | + 'label' => __('Price Currency', 'site-reviews'), |
|
414 | + 'placeholder' => 'USD', |
|
415 | + 'type' => 'text', |
|
416 | + ], |
|
417 | + 'settings.submissions.required' => [ |
|
418 | + 'default' => ['content', 'email', 'name', 'rating', 'terms', 'title'], |
|
419 | + 'description' => __('Choose which fields should be required in the submission form.', 'site-reviews'), |
|
420 | + 'label' => __('Required Fields', 'site-reviews'), |
|
421 | + 'options' => [ |
|
422 | + 'rating' => __('Rating', 'site-reviews'), |
|
423 | + 'title' => __('Title', 'site-reviews'), |
|
424 | + 'content' => __('Review', 'site-reviews'), |
|
425 | + 'name' => __('Name', 'site-reviews'), |
|
426 | + 'email' => __('Email', 'site-reviews'), |
|
427 | + 'terms' => __('Terms', 'site-reviews'), |
|
428 | + ], |
|
429 | + 'type' => 'checkbox', |
|
430 | + ], |
|
431 | + 'settings.submissions.limit' => [ |
|
432 | + 'default' => '', |
|
433 | + 'description' => __('Limits the number of reviews that can be submitted to one-per-person. If you are assigning reviews, then the limit will be applied to the assigned page or category.', 'site-reviews'), |
|
434 | + 'label' => __('Limit Reviews', 'site-reviews'), |
|
435 | + 'options' => [ |
|
436 | + '' => __('No Limit', 'site-reviews'), |
|
437 | + 'email' => __('By Email Address', 'site-reviews'), |
|
438 | + 'ip_address' => __('By IP Address', 'site-reviews'), |
|
439 | + 'username' => __('By Username (will only work for registered users)', 'site-reviews'), |
|
440 | + ], |
|
441 | + 'type' => 'select', |
|
442 | + ], |
|
443 | + 'settings.submissions.limit_whitelist.email' => [ |
|
444 | + 'default' => '', |
|
445 | + 'depends_on' => [ |
|
446 | + 'settings.submissions.limit' => ['email'], |
|
447 | + ], |
|
448 | + 'description' => __('One Email per line. All emails in the whitelist will be excluded from the review submission limit.', 'site-reviews'), |
|
449 | + 'label' => __('Email Whitelist', 'site-reviews'), |
|
450 | + 'rows' => 5, |
|
451 | + 'type' => 'code', |
|
452 | + ], |
|
453 | + 'settings.submissions.limit_whitelist.ip_address' => [ |
|
454 | + 'default' => '', |
|
455 | + 'depends_on' => [ |
|
456 | + 'settings.submissions.limit' => ['ip_address'], |
|
457 | + ], |
|
458 | + 'description' => __('One IP Address per line. All IP Addresses in the whitelist will be excluded from the review submission limit..', 'site-reviews'), |
|
459 | + 'label' => __('IP Address Whitelist', 'site-reviews'), |
|
460 | + 'rows' => 5, |
|
461 | + 'type' => 'code', |
|
462 | + ], |
|
463 | + 'settings.submissions.limit_whitelist.username' => [ |
|
464 | + 'default' => '', |
|
465 | + 'depends_on' => [ |
|
466 | + 'settings.submissions.limit' => ['username'], |
|
467 | + ], |
|
468 | + 'description' => __('One Username per line. All registered users with a Username in the whitelist will be excluded from the review submission limit.', 'site-reviews'), |
|
469 | + 'label' => __('Username Whitelist', 'site-reviews'), |
|
470 | + 'rows' => 5, |
|
471 | + 'type' => 'code', |
|
472 | + ], |
|
473 | + 'settings.submissions.recaptcha.integration' => [ |
|
474 | + 'default' => '', |
|
475 | + 'description' => __('Invisible reCAPTCHA is a free anti-spam service from Google. To use it, you will need to <a href="https://www.google.com/recaptcha/admin" target="_blank">sign up</a> for an API key pair for your site.', 'site-reviews'), |
|
476 | + 'label' => __('Invisible reCAPTCHA', 'site-reviews'), |
|
477 | + 'options' => [ |
|
478 | + '' => 'Do not use reCAPTCHA', |
|
479 | + 'all' => 'Use reCAPTCHA', |
|
480 | + 'guest' => 'Use reCAPTCHA only for guest users', |
|
481 | + ], |
|
482 | + 'type' => 'select', |
|
483 | + ], |
|
484 | + 'settings.submissions.recaptcha.key' => [ |
|
485 | + 'default' => '', |
|
486 | + 'depends_on' => [ |
|
487 | + 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
488 | + ], |
|
489 | + 'label' => __('Site Key', 'site-reviews'), |
|
490 | + 'type' => 'text', |
|
491 | + ], |
|
492 | + 'settings.submissions.recaptcha.secret' => [ |
|
493 | + 'default' => '', |
|
494 | + 'depends_on' => [ |
|
495 | + 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
496 | + ], |
|
497 | + 'label' => __('Site Secret', 'site-reviews'), |
|
498 | + 'type' => 'text', |
|
499 | + ], |
|
500 | + 'settings.submissions.recaptcha.position' => [ |
|
501 | + 'default' => 'bottomleft', |
|
502 | + 'depends_on' => [ |
|
503 | + 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
504 | + ], |
|
505 | + 'description' => __('This option may not work consistently if another plugin is loading reCAPTCHA on the same page as Site Reviews.', 'site-reviews'), |
|
506 | + 'label' => __('Badge Position', 'site-reviews'), |
|
507 | + 'options' => [ |
|
508 | + 'bottomleft' => 'Bottom Left', |
|
509 | + 'bottomright' => 'Bottom Right', |
|
510 | + 'inline' => 'Inline', |
|
511 | + ], |
|
512 | + 'type' => 'select', |
|
513 | + ], |
|
514 | + 'settings.submissions.akismet' => [ |
|
515 | + 'default' => 'no', |
|
516 | + 'description' => __('The <a href="https://akismet.com" target="_blank">Akismet plugin</a> integration provides spam-filtering for your reviews. In order for this setting to have any affect, you will need to first install and activate the Akismet plugin and set up a WordPress.com API key.', 'site-reviews'), |
|
517 | + 'label' => __('Enable Akismet Integration', 'site-reviews'), |
|
518 | + 'type' => 'yes_no', |
|
519 | + ], |
|
520 | + 'settings.submissions.blacklist.integration' => [ |
|
521 | + 'default' => '', |
|
522 | + 'description' => sprintf(__('Choose which Blacklist you would prefer to use for reviews. The %s can be found in the WordPress Discussion Settings page.', 'site-reviews'), |
|
523 | + '<a href="'.admin_url('options-discussion.php#users_can_register').'">'.__('Comment Blacklist', 'site-reviews').'</a>' |
|
524 | + ), |
|
525 | + 'label' => __('Blacklist', 'site-reviews'), |
|
526 | + 'options' => [ |
|
527 | + '' => 'Use the Site Reviews Blacklist', |
|
528 | + 'comments' => 'Use the WordPress Comment Blacklist', |
|
529 | + ], |
|
530 | + 'type' => 'select', |
|
531 | + ], |
|
532 | + 'settings.submissions.blacklist.entries' => [ |
|
533 | + 'default' => '', |
|
534 | + 'depends_on' => [ |
|
535 | + 'settings.submissions.blacklist.integration' => [''], |
|
536 | + ], |
|
537 | + 'description' => __('One entry or IP address per line. When a review contains any of these entries in its title, content, name, email, or IP address, it will be rejected. It is case-insensitive and will match partial words, so "press" will match "WordPress".', 'site-reviews'), |
|
538 | + 'label' => __('Review Blacklist', 'site-reviews'), |
|
539 | + 'rows' => 10, |
|
540 | + 'type' => 'code', |
|
541 | + ], |
|
542 | + 'settings.submissions.blacklist.action' => [ |
|
543 | + 'default' => 'unapprove', |
|
544 | + 'description' => __('Choose the action that should be taken when a review is blacklisted.', 'site-reviews'), |
|
545 | + 'label' => __('Blacklist Action', 'site-reviews'), |
|
546 | + 'options' => [ |
|
547 | + 'unapprove' => __('Require approval', 'site-reviews'), |
|
548 | + 'reject' => __('Reject submission', 'site-reviews'), |
|
549 | + ], |
|
550 | + 'type' => 'select', |
|
551 | + ], |
|
552 | 552 | ]; |
@@ -3,16 +3,16 @@ discard block |
||
3 | 3 | return [ |
4 | 4 | 'settings.general.style' => [ |
5 | 5 | 'default' => 'default', |
6 | - 'description' => __('Site Reviews relies on the CSS of your theme to style the submission form. If your theme does not provide proper CSS rules for form elements and you are using a WordPress plugin/theme or CSS Framework listed here, please try selecting it, otherwise choose "Site Reviews (default)".', 'site-reviews'), |
|
7 | - 'label' => __('Plugin Style', 'site-reviews'), |
|
6 | + 'description' => __( 'Site Reviews relies on the CSS of your theme to style the submission form. If your theme does not provide proper CSS rules for form elements and you are using a WordPress plugin/theme or CSS Framework listed here, please try selecting it, otherwise choose "Site Reviews (default)".', 'site-reviews' ), |
|
7 | + 'label' => __( 'Plugin Style', 'site-reviews' ), |
|
8 | 8 | 'options' => [ |
9 | 9 | 'bootstrap_4' => 'CSS Framework: Bootstrap 4', |
10 | 10 | 'bootstrap_4_custom' => 'CSS Framework: Bootstrap 4 (Custom Forms)', |
11 | 11 | 'contact_form_7' => 'Plugin: Contact Form 7 (v5)', |
12 | 12 | 'ninja_forms' => 'Plugin: Ninja Forms (v3)', |
13 | 13 | 'wpforms' => 'Plugin: WPForms Lite (v1)', |
14 | - 'default' => __('Site Reviews (default)', 'site-reviews'), |
|
15 | - 'minimal' => __('Site Reviews (minimal)', 'site-reviews'), |
|
14 | + 'default' => __( 'Site Reviews (default)', 'site-reviews' ), |
|
15 | + 'minimal' => __( 'Site Reviews (minimal)', 'site-reviews' ), |
|
16 | 16 | 'divi' => 'Theme: Divi (v3)', |
17 | 17 | 'materialize' => 'Theme: Materialize', |
18 | 18 | 'twentyfifteen' => 'Theme: Twenty Fifteen', |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | ], |
24 | 24 | 'settings.general.require.approval' => [ |
25 | 25 | 'default' => 'no', |
26 | - 'description' => __('Set the status of new review submissions to "unapproved".', 'site-reviews'), |
|
27 | - 'label' => __('Require Approval', 'site-reviews'), |
|
26 | + 'description' => __( 'Set the status of new review submissions to "unapproved".', 'site-reviews' ), |
|
27 | + 'label' => __( 'Require Approval', 'site-reviews' ), |
|
28 | 28 | 'type' => 'yes_no', |
29 | 29 | ], |
30 | 30 | 'settings.general.require.login' => [ |
31 | 31 | 'default' => 'no', |
32 | - 'description' => __('Only allow review submissions from registered users.', 'site-reviews'), |
|
33 | - 'label' => __('Require Login', 'site-reviews'), |
|
32 | + 'description' => __( 'Only allow review submissions from registered users.', 'site-reviews' ), |
|
33 | + 'label' => __( 'Require Login', 'site-reviews' ), |
|
34 | 34 | 'type' => 'yes_no', |
35 | 35 | ], |
36 | 36 | 'settings.general.require.login_register' => [ |
@@ -38,29 +38,29 @@ discard block |
||
38 | 38 | 'depends_on' => [ |
39 | 39 | 'settings.general.require.login' => 'yes', |
40 | 40 | ], |
41 | - 'description' => sprintf(__('Show a link for a new user to register. The %s Membership option must be enabled in General Settings for this to work.', 'site-reviews'), |
|
42 | - '<a href="'.admin_url('options-general.php#users_can_register').'">'.__('Anyone can register', 'site-reviews').'</a>' |
|
41 | + 'description' => sprintf( __( 'Show a link for a new user to register. The %s Membership option must be enabled in General Settings for this to work.', 'site-reviews' ), |
|
42 | + '<a href="'.admin_url( 'options-general.php#users_can_register' ).'">'.__( 'Anyone can register', 'site-reviews' ).'</a>' |
|
43 | 43 | ), |
44 | - 'label' => __('Show Registration Link', 'site-reviews'), |
|
44 | + 'label' => __( 'Show Registration Link', 'site-reviews' ), |
|
45 | 45 | 'type' => 'yes_no', |
46 | 46 | ], |
47 | 47 | 'settings.general.multilingual' => [ |
48 | 48 | 'default' => '', |
49 | - 'description' => __('Integrate with a multilingual plugin to calculate ratings for all languages of a post.', 'site-reviews'), |
|
50 | - 'label' => __('Multilingual', 'site-reviews'), |
|
49 | + 'description' => __( 'Integrate with a multilingual plugin to calculate ratings for all languages of a post.', 'site-reviews' ), |
|
50 | + 'label' => __( 'Multilingual', 'site-reviews' ), |
|
51 | 51 | 'options' => [ |
52 | - '' => __('No Integration', 'site-reviews'), |
|
53 | - 'polylang' => __('Integrate with Polylang', 'site-reviews'), |
|
54 | - 'wpml' => __('Integrate with WPML', 'site-reviews'), |
|
52 | + '' => __( 'No Integration', 'site-reviews' ), |
|
53 | + 'polylang' => __( 'Integrate with Polylang', 'site-reviews' ), |
|
54 | + 'wpml' => __( 'Integrate with WPML', 'site-reviews' ), |
|
55 | 55 | ], |
56 | 56 | 'type' => 'select', |
57 | 57 | ], |
58 | 58 | 'settings.general.rebusify' => [ |
59 | 59 | 'default' => 'no', |
60 | - 'description' => sprintf(__('Integrate with the %s and validate your reviews on the blockchain to increase online reputation, trust, and transparency.', 'site-reviews'), |
|
60 | + 'description' => sprintf( __( 'Integrate with the %s and validate your reviews on the blockchain to increase online reputation, trust, and transparency.', 'site-reviews' ), |
|
61 | 61 | '<a href="https://rebusify.com/plans?ref=105" target="_blank">Rebusify Confidence System</a>' |
62 | 62 | ), |
63 | - 'label' => __('Blockchain Validation', 'site-reviews'), |
|
63 | + 'label' => __( 'Blockchain Validation', 'site-reviews' ), |
|
64 | 64 | 'type' => 'yes_no', |
65 | 65 | ], |
66 | 66 | 'settings.general.rebusify_email' => [ |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | 'depends_on' => [ |
69 | 69 | 'settings.general.rebusify' => ['yes'], |
70 | 70 | ], |
71 | - 'description' => __('Enter your Rebusify account email here.', 'site-reviews'), |
|
72 | - 'label' => __('Rebusify Email', 'site-reviews'), |
|
71 | + 'description' => __( 'Enter your Rebusify account email here.', 'site-reviews' ), |
|
72 | + 'label' => __( 'Rebusify Email', 'site-reviews' ), |
|
73 | 73 | 'type' => 'text', |
74 | 74 | ], |
75 | 75 | 'settings.general.rebusify_serial' => [ |
@@ -77,18 +77,18 @@ discard block |
||
77 | 77 | 'depends_on' => [ |
78 | 78 | 'settings.general.rebusify' => ['yes'], |
79 | 79 | ], |
80 | - 'description' => __('Enter your Rebusify account serial key here.', 'site-reviews'), |
|
81 | - 'label' => __('Rebusify Serial Key', 'site-reviews'), |
|
80 | + 'description' => __( 'Enter your Rebusify account serial key here.', 'site-reviews' ), |
|
81 | + 'label' => __( 'Rebusify Serial Key', 'site-reviews' ), |
|
82 | 82 | 'type' => 'password', |
83 | 83 | ], |
84 | 84 | 'settings.general.notifications' => [ |
85 | 85 | 'default' => [], |
86 | - 'label' => __('Notifications', 'site-reviews'), |
|
86 | + 'label' => __( 'Notifications', 'site-reviews' ), |
|
87 | 87 | 'options' => [ |
88 | - 'admin' => __('Send to administrator', 'site-reviews').' <code>'.(string) get_option('admin_email').'</code>', |
|
89 | - 'author' => __('Send to author of the page that the review is assigned to', 'site-reviews'), |
|
90 | - 'custom' => __('Send to one or more email addresses', 'site-reviews'), |
|
91 | - 'slack' => __('Send to <a href="https://slack.com/">Slack</a>', 'site-reviews'), |
|
88 | + 'admin' => __( 'Send to administrator', 'site-reviews' ).' <code>'.(string)get_option( 'admin_email' ).'</code>', |
|
89 | + 'author' => __( 'Send to author of the page that the review is assigned to', 'site-reviews' ), |
|
90 | + 'custom' => __( 'Send to one or more email addresses', 'site-reviews' ), |
|
91 | + 'slack' => __( 'Send to <a href="https://slack.com/">Slack</a>', 'site-reviews' ), |
|
92 | 92 | ], |
93 | 93 | 'type' => 'checkbox', |
94 | 94 | ], |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | 'depends_on' => [ |
98 | 98 | 'settings.general.notifications' => ['custom'], |
99 | 99 | ], |
100 | - 'label' => __('Send Notification Emails To', 'site-reviews'), |
|
101 | - 'placeholder' => __('Separate multiple emails with a comma', 'site-reviews'), |
|
100 | + 'label' => __( 'Send Notification Emails To', 'site-reviews' ), |
|
101 | + 'placeholder' => __( 'Separate multiple emails with a comma', 'site-reviews' ), |
|
102 | 102 | 'type' => 'text', |
103 | 103 | ], |
104 | 104 | 'settings.general.notification_slack' => [ |
@@ -106,14 +106,14 @@ discard block |
||
106 | 106 | 'depends_on' => [ |
107 | 107 | 'settings.general.notifications' => ['slack'], |
108 | 108 | ], |
109 | - 'description' => sprintf(__('To send notifications to Slack, create a new %s and then paste the provided Webhook URL in the field above.', 'site-reviews'), |
|
110 | - '<a href="https://api.slack.com/incoming-webhooks">'.__('Incoming WebHook', 'site-reviews').'</a>' |
|
109 | + 'description' => sprintf( __( 'To send notifications to Slack, create a new %s and then paste the provided Webhook URL in the field above.', 'site-reviews' ), |
|
110 | + '<a href="https://api.slack.com/incoming-webhooks">'.__( 'Incoming WebHook', 'site-reviews' ).'</a>' |
|
111 | 111 | ), |
112 | - 'label' => __('Slack Webhook URL', 'site-reviews'), |
|
112 | + 'label' => __( 'Slack Webhook URL', 'site-reviews' ), |
|
113 | 113 | 'type' => 'text', |
114 | 114 | ], |
115 | 115 | 'settings.general.notification_message' => [ |
116 | - 'default' => glsr('Modules\Html\Template')->build('templates/email-notification'), |
|
116 | + 'default' => glsr( 'Modules\Html\Template' )->build( 'templates/email-notification' ), |
|
117 | 117 | 'depends_on' => [ |
118 | 118 | 'settings.general.notifications' => ['admin', 'author', 'custom', 'slack'], |
119 | 119 | ], |
@@ -129,42 +129,42 @@ discard block |
||
129 | 129 | '<br><code>{review_link}</code> The link to edit/view a review', |
130 | 130 | 'site-reviews' |
131 | 131 | ), |
132 | - 'label' => __('Notification Template', 'site-reviews'), |
|
132 | + 'label' => __( 'Notification Template', 'site-reviews' ), |
|
133 | 133 | 'rows' => 10, |
134 | 134 | 'type' => 'code', |
135 | 135 | ], |
136 | 136 | 'settings.reviews.date.format' => [ |
137 | 137 | 'default' => '', |
138 | - 'description' => sprintf(__('The default date format is the one set in your %s.', 'site-reviews'), |
|
139 | - '<a href="'.admin_url('options-general.php#date_format_custom').'">'.__('WordPress settings', 'site-reviews').'</a>' |
|
138 | + 'description' => sprintf( __( 'The default date format is the one set in your %s.', 'site-reviews' ), |
|
139 | + '<a href="'.admin_url( 'options-general.php#date_format_custom' ).'">'.__( 'WordPress settings', 'site-reviews' ).'</a>' |
|
140 | 140 | ), |
141 | - 'label' => __('Date Format', 'site-reviews'), |
|
141 | + 'label' => __( 'Date Format', 'site-reviews' ), |
|
142 | 142 | 'options' => [ |
143 | - '' => __('Use the default date format', 'site-reviews'), |
|
144 | - 'relative' => __('Use a relative date format', 'site-reviews'), |
|
145 | - 'custom' => __('Use a custom date format', 'site-reviews'), |
|
143 | + '' => __( 'Use the default date format', 'site-reviews' ), |
|
144 | + 'relative' => __( 'Use a relative date format', 'site-reviews' ), |
|
145 | + 'custom' => __( 'Use a custom date format', 'site-reviews' ), |
|
146 | 146 | ], |
147 | 147 | 'type' => 'select', |
148 | 148 | ], |
149 | 149 | 'settings.reviews.date.custom' => [ |
150 | - 'default' => get_option('date_format'), |
|
150 | + 'default' => get_option( 'date_format' ), |
|
151 | 151 | 'depends_on' => [ |
152 | 152 | 'settings.reviews.date.format' => 'custom', |
153 | 153 | ], |
154 | - 'description' => __('Enter a custom date format (<a href="https://codex.wordpress.org/Formatting_Date_and_Time">documentation on date and time formatting</a>).', 'site-reviews'), |
|
155 | - 'label' => __('Custom Date Format', 'site-reviews'), |
|
154 | + 'description' => __( 'Enter a custom date format (<a href="https://codex.wordpress.org/Formatting_Date_and_Time">documentation on date and time formatting</a>).', 'site-reviews' ), |
|
155 | + 'label' => __( 'Custom Date Format', 'site-reviews' ), |
|
156 | 156 | 'type' => 'text', |
157 | 157 | ], |
158 | 158 | 'settings.reviews.name.format' => [ |
159 | 159 | 'default' => '', |
160 | - 'description' => __('Choose how names are shown in your reviews.', 'site-reviews'), |
|
161 | - 'label' => __('Name Format', 'site-reviews'), |
|
160 | + 'description' => __( 'Choose how names are shown in your reviews.', 'site-reviews' ), |
|
161 | + 'label' => __( 'Name Format', 'site-reviews' ), |
|
162 | 162 | 'options' => [ |
163 | - '' => __('Use the name as given', 'site-reviews'), |
|
164 | - 'first' => __('Use the first name only', 'site-reviews'), |
|
165 | - 'first_initial' => __('Convert first name to an initial', 'site-reviews'), |
|
166 | - 'last_initial' => __('Convert last name to an initial', 'site-reviews'), |
|
167 | - 'initials' => __('Convert to all initials', 'site-reviews'), |
|
163 | + '' => __( 'Use the name as given', 'site-reviews' ), |
|
164 | + 'first' => __( 'Use the first name only', 'site-reviews' ), |
|
165 | + 'first_initial' => __( 'Convert first name to an initial', 'site-reviews' ), |
|
166 | + 'last_initial' => __( 'Convert last name to an initial', 'site-reviews' ), |
|
167 | + 'initials' => __( 'Convert to all initials', 'site-reviews' ), |
|
168 | 168 | ], |
169 | 169 | 'type' => 'select', |
170 | 170 | ], |
@@ -173,25 +173,25 @@ discard block |
||
173 | 173 | 'depends_on' => [ |
174 | 174 | 'settings.reviews.name.format' => ['first_initial', 'last_initial', 'initials'], |
175 | 175 | ], |
176 | - 'description' => __('Choose how the initial is displayed.', 'site-reviews'), |
|
177 | - 'label' => __('Initial Format', 'site-reviews'), |
|
176 | + 'description' => __( 'Choose how the initial is displayed.', 'site-reviews' ), |
|
177 | + 'label' => __( 'Initial Format', 'site-reviews' ), |
|
178 | 178 | 'options' => [ |
179 | - '' => __('Initial with a space', 'site-reviews'), |
|
180 | - 'period' => __('Initial with a period', 'site-reviews'), |
|
181 | - 'period_space' => __('Initial with a period and a space', 'site-reviews'), |
|
179 | + '' => __( 'Initial with a space', 'site-reviews' ), |
|
180 | + 'period' => __( 'Initial with a period', 'site-reviews' ), |
|
181 | + 'period_space' => __( 'Initial with a period and a space', 'site-reviews' ), |
|
182 | 182 | ], |
183 | 183 | 'type' => 'select', |
184 | 184 | ], |
185 | 185 | 'settings.reviews.assigned_links' => [ |
186 | 186 | 'default' => 'no', |
187 | - 'description' => __('Display a link to the assigned post of a review.', 'site-reviews'), |
|
188 | - 'label' => __('Enable Assigned Links', 'site-reviews'), |
|
187 | + 'description' => __( 'Display a link to the assigned post of a review.', 'site-reviews' ), |
|
188 | + 'label' => __( 'Enable Assigned Links', 'site-reviews' ), |
|
189 | 189 | 'type' => 'yes_no', |
190 | 190 | ], |
191 | 191 | 'settings.reviews.avatars' => [ |
192 | 192 | 'default' => 'no', |
193 | - 'description' => __('Display reviewer avatars. These are generated from the email address of the reviewer using <a href="https://gravatar.com">Gravatar</a>.', 'site-reviews'), |
|
194 | - 'label' => __('Enable Avatars', 'site-reviews'), |
|
193 | + 'description' => __( 'Display reviewer avatars. These are generated from the email address of the reviewer using <a href="https://gravatar.com">Gravatar</a>.', 'site-reviews' ), |
|
194 | + 'label' => __( 'Enable Avatars', 'site-reviews' ), |
|
195 | 195 | 'type' => 'yes_no', |
196 | 196 | ], |
197 | 197 | 'settings.reviews.avatars_regenerate' => [ |
@@ -199,8 +199,8 @@ discard block |
||
199 | 199 | 'depends_on' => [ |
200 | 200 | 'settings.reviews.avatars' => 'yes', |
201 | 201 | ], |
202 | - 'description' => __('Regenerate the avatar whenever a local review is shown?', 'site-reviews'), |
|
203 | - 'label' => __('Regenerate Avatars', 'site-reviews'), |
|
202 | + 'description' => __( 'Regenerate the avatar whenever a local review is shown?', 'site-reviews' ), |
|
203 | + 'label' => __( 'Regenerate Avatars', 'site-reviews' ), |
|
204 | 204 | 'type' => 'yes_no', |
205 | 205 | ], |
206 | 206 | 'settings.reviews.avatars_size' => [ |
@@ -208,14 +208,14 @@ discard block |
||
208 | 208 | 'depends_on' => [ |
209 | 209 | 'settings.reviews.avatars' => 'yes', |
210 | 210 | ], |
211 | - 'description' => __('Set the avatar size in pixels.', 'site-reviews'), |
|
212 | - 'label' => __('Avatar Size', 'site-reviews'), |
|
211 | + 'description' => __( 'Set the avatar size in pixels.', 'site-reviews' ), |
|
212 | + 'label' => __( 'Avatar Size', 'site-reviews' ), |
|
213 | 213 | 'type' => 'number', |
214 | 214 | ], |
215 | 215 | 'settings.reviews.excerpts' => [ |
216 | 216 | 'default' => 'yes', |
217 | - 'description' => __('Display an excerpt instead of the full review.', 'site-reviews'), |
|
218 | - 'label' => __('Enable Excerpts', 'site-reviews'), |
|
217 | + 'description' => __( 'Display an excerpt instead of the full review.', 'site-reviews' ), |
|
218 | + 'label' => __( 'Enable Excerpts', 'site-reviews' ), |
|
219 | 219 | 'type' => 'yes_no', |
220 | 220 | ], |
221 | 221 | 'settings.reviews.excerpts_length' => [ |
@@ -223,27 +223,27 @@ discard block |
||
223 | 223 | 'depends_on' => [ |
224 | 224 | 'settings.reviews.excerpts' => 'yes', |
225 | 225 | ], |
226 | - 'description' => __('Set the excerpt word length.', 'site-reviews'), |
|
227 | - 'label' => __('Excerpt Length', 'site-reviews'), |
|
226 | + 'description' => __( 'Set the excerpt word length.', 'site-reviews' ), |
|
227 | + 'label' => __( 'Excerpt Length', 'site-reviews' ), |
|
228 | 228 | 'type' => 'number', |
229 | 229 | ], |
230 | 230 | 'settings.reviews.fallback' => [ |
231 | 231 | 'default' => 'yes', |
232 | - 'description' => sprintf(__('Display the fallback text when there are no reviews to display. This can be changed on the %s page. You may also override this by using the "fallback" option on the shortcode. The default fallback text is: %s', 'site-reviews'), |
|
233 | - '<a href="'.admin_url('edit.php?post_type=site-review&page=settings#!translations').'">'.__('Translations', 'site-reviews').'</a>', |
|
234 | - '<code>'.__('There are no reviews yet. Be the first one to write one.', 'site-reviews').'</code>' |
|
232 | + 'description' => sprintf( __( 'Display the fallback text when there are no reviews to display. This can be changed on the %s page. You may also override this by using the "fallback" option on the shortcode. The default fallback text is: %s', 'site-reviews' ), |
|
233 | + '<a href="'.admin_url( 'edit.php?post_type=site-review&page=settings#!translations' ).'">'.__( 'Translations', 'site-reviews' ).'</a>', |
|
234 | + '<code>'.__( 'There are no reviews yet. Be the first one to write one.', 'site-reviews' ).'</code>' |
|
235 | 235 | ), |
236 | - 'label' => __('Enable Fallback Text', 'site-reviews'), |
|
236 | + 'label' => __( 'Enable Fallback Text', 'site-reviews' ), |
|
237 | 237 | 'type' => 'yes_no', |
238 | 238 | ], |
239 | 239 | 'settings.schema.type.default' => [ |
240 | 240 | 'default' => 'LocalBusiness', |
241 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_type</code>', |
|
242 | - 'label' => __('Default Schema Type', 'site-reviews'), |
|
241 | + 'description' => __( 'Custom Field name', 'site-reviews' ).': <code>schema_type</code>', |
|
242 | + 'label' => __( 'Default Schema Type', 'site-reviews' ), |
|
243 | 243 | 'options' => [ |
244 | - 'LocalBusiness' => __('Local Business', 'site-reviews'), |
|
245 | - 'Product' => __('Product', 'site-reviews'), |
|
246 | - 'custom' => __('Custom', 'site-reviews'), |
|
244 | + 'LocalBusiness' => __( 'Local Business', 'site-reviews' ), |
|
245 | + 'Product' => __( 'Product', 'site-reviews' ), |
|
246 | + 'custom' => __( 'Custom', 'site-reviews' ), |
|
247 | 247 | ], |
248 | 248 | 'type' => 'select', |
249 | 249 | ], |
@@ -252,17 +252,17 @@ discard block |
||
252 | 252 | 'depends_on' => [ |
253 | 253 | 'settings.schema.type.default' => 'custom', |
254 | 254 | ], |
255 | - 'description' => '<a href="https://schema.org/docs/schemas.html">'.__('View more information on schema types here', 'site-reviews').'</a>', |
|
256 | - 'label' => __('Custom Schema Type', 'site-reviews'), |
|
255 | + 'description' => '<a href="https://schema.org/docs/schemas.html">'.__( 'View more information on schema types here', 'site-reviews' ).'</a>', |
|
256 | + 'label' => __( 'Custom Schema Type', 'site-reviews' ), |
|
257 | 257 | 'type' => 'text', |
258 | 258 | ], |
259 | 259 | 'settings.schema.name.default' => [ |
260 | 260 | 'default' => 'post', |
261 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_name</code>', |
|
262 | - 'label' => __('Default Name', 'site-reviews'), |
|
261 | + 'description' => __( 'Custom Field name', 'site-reviews' ).': <code>schema_name</code>', |
|
262 | + 'label' => __( 'Default Name', 'site-reviews' ), |
|
263 | 263 | 'options' => [ |
264 | - 'post' => __('Use the assigned or current page title', 'site-reviews'), |
|
265 | - 'custom' => __('Enter a custom title', 'site-reviews'), |
|
264 | + 'post' => __( 'Use the assigned or current page title', 'site-reviews' ), |
|
265 | + 'custom' => __( 'Enter a custom title', 'site-reviews' ), |
|
266 | 266 | ], |
267 | 267 | 'type' => 'select', |
268 | 268 | ], |
@@ -271,16 +271,16 @@ discard block |
||
271 | 271 | 'depends_on' => [ |
272 | 272 | 'settings.schema.name.default' => 'custom', |
273 | 273 | ], |
274 | - 'label' => __('Custom Name', 'site-reviews'), |
|
274 | + 'label' => __( 'Custom Name', 'site-reviews' ), |
|
275 | 275 | 'type' => 'text', |
276 | 276 | ], |
277 | 277 | 'settings.schema.description.default' => [ |
278 | 278 | 'default' => 'post', |
279 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_description</code>', |
|
280 | - 'label' => __('Default Description', 'site-reviews'), |
|
279 | + 'description' => __( 'Custom Field name', 'site-reviews' ).': <code>schema_description</code>', |
|
280 | + 'label' => __( 'Default Description', 'site-reviews' ), |
|
281 | 281 | 'options' => [ |
282 | - 'post' => __('Use the assigned or current page excerpt', 'site-reviews'), |
|
283 | - 'custom' => __('Enter a custom description', 'site-reviews'), |
|
282 | + 'post' => __( 'Use the assigned or current page excerpt', 'site-reviews' ), |
|
283 | + 'custom' => __( 'Enter a custom description', 'site-reviews' ), |
|
284 | 284 | ], |
285 | 285 | 'type' => 'select', |
286 | 286 | ], |
@@ -289,16 +289,16 @@ discard block |
||
289 | 289 | 'depends_on' => [ |
290 | 290 | 'settings.schema.description.default' => 'custom', |
291 | 291 | ], |
292 | - 'label' => __('Custom Description', 'site-reviews'), |
|
292 | + 'label' => __( 'Custom Description', 'site-reviews' ), |
|
293 | 293 | 'type' => 'text', |
294 | 294 | ], |
295 | 295 | 'settings.schema.url.default' => [ |
296 | 296 | 'default' => 'post', |
297 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_url</code>', |
|
298 | - 'label' => __('Default URL', 'site-reviews'), |
|
297 | + 'description' => __( 'Custom Field name', 'site-reviews' ).': <code>schema_url</code>', |
|
298 | + 'label' => __( 'Default URL', 'site-reviews' ), |
|
299 | 299 | 'options' => [ |
300 | - 'post' => __('Use the assigned or current page URL', 'site-reviews'), |
|
301 | - 'custom' => __('Enter a custom URL', 'site-reviews'), |
|
300 | + 'post' => __( 'Use the assigned or current page URL', 'site-reviews' ), |
|
301 | + 'custom' => __( 'Enter a custom URL', 'site-reviews' ), |
|
302 | 302 | ], |
303 | 303 | 'type' => 'select', |
304 | 304 | ], |
@@ -307,16 +307,16 @@ discard block |
||
307 | 307 | 'depends_on' => [ |
308 | 308 | 'settings.schema.url.default' => 'custom', |
309 | 309 | ], |
310 | - 'label' => __('Custom URL', 'site-reviews'), |
|
310 | + 'label' => __( 'Custom URL', 'site-reviews' ), |
|
311 | 311 | 'type' => 'text', |
312 | 312 | ], |
313 | 313 | 'settings.schema.image.default' => [ |
314 | 314 | 'default' => 'post', |
315 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_image</code>', |
|
316 | - 'label' => __('Default Image', 'site-reviews'), |
|
315 | + 'description' => __( 'Custom Field name', 'site-reviews' ).': <code>schema_image</code>', |
|
316 | + 'label' => __( 'Default Image', 'site-reviews' ), |
|
317 | 317 | 'options' => [ |
318 | - 'post' => __('Use the featured image of the assigned or current page', 'site-reviews'), |
|
319 | - 'custom' => __('Enter a custom image URL', 'site-reviews'), |
|
318 | + 'post' => __( 'Use the featured image of the assigned or current page', 'site-reviews' ), |
|
319 | + 'custom' => __( 'Enter a custom image URL', 'site-reviews' ), |
|
320 | 320 | ], |
321 | 321 | 'type' => 'select', |
322 | 322 | ], |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | 'depends_on' => [ |
326 | 326 | 'settings.schema.image.default' => 'custom', |
327 | 327 | ], |
328 | - 'label' => __('Custom Image URL', 'site-reviews'), |
|
328 | + 'label' => __( 'Custom Image URL', 'site-reviews' ), |
|
329 | 329 | 'type' => 'text', |
330 | 330 | ], |
331 | 331 | 'settings.schema.address' => [ |
@@ -333,8 +333,8 @@ discard block |
||
333 | 333 | 'depends_on' => [ |
334 | 334 | 'settings.schema.type.default' => 'LocalBusiness', |
335 | 335 | ], |
336 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_address</code>', |
|
337 | - 'label' => __('Address', 'site-reviews'), |
|
336 | + 'description' => __( 'Custom Field name', 'site-reviews' ).': <code>schema_address</code>', |
|
337 | + 'label' => __( 'Address', 'site-reviews' ), |
|
338 | 338 | 'placeholder' => '60 29th Street #343, San Francisco, CA 94110, US', |
339 | 339 | 'type' => 'text', |
340 | 340 | ], |
@@ -343,8 +343,8 @@ discard block |
||
343 | 343 | 'depends_on' => [ |
344 | 344 | 'settings.schema.type.default' => 'LocalBusiness', |
345 | 345 | ], |
346 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_telephone</code>', |
|
347 | - 'label' => __('Telephone Number', 'site-reviews'), |
|
346 | + 'description' => __( 'Custom Field name', 'site-reviews' ).': <code>schema_telephone</code>', |
|
347 | + 'label' => __( 'Telephone Number', 'site-reviews' ), |
|
348 | 348 | 'placeholder' => '+1 (877) 273-3049', |
349 | 349 | 'type' => 'text', |
350 | 350 | ], |
@@ -353,8 +353,8 @@ discard block |
||
353 | 353 | 'depends_on' => [ |
354 | 354 | 'settings.schema.type.default' => 'LocalBusiness', |
355 | 355 | ], |
356 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricerange</code>', |
|
357 | - 'label' => __('Price Range', 'site-reviews'), |
|
356 | + 'description' => __( 'Custom Field name', 'site-reviews' ).': <code>schema_pricerange</code>', |
|
357 | + 'label' => __( 'Price Range', 'site-reviews' ), |
|
358 | 358 | 'placeholder' => '$$-$$$', |
359 | 359 | 'type' => 'text', |
360 | 360 | ], |
@@ -363,11 +363,11 @@ discard block |
||
363 | 363 | 'depends_on' => [ |
364 | 364 | 'settings.schema.type.default' => 'Product', |
365 | 365 | ], |
366 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_offertype</code>', |
|
367 | - 'label' => __('Offer Type', 'site-reviews'), |
|
366 | + 'description' => __( 'Custom Field name', 'site-reviews' ).': <code>schema_offertype</code>', |
|
367 | + 'label' => __( 'Offer Type', 'site-reviews' ), |
|
368 | 368 | 'options' => [ |
369 | - 'AggregateOffer' => __('AggregateOffer', 'site-reviews'), |
|
370 | - 'Offer' => __('Offer', 'site-reviews'), |
|
369 | + 'AggregateOffer' => __( 'AggregateOffer', 'site-reviews' ), |
|
370 | + 'Offer' => __( 'Offer', 'site-reviews' ), |
|
371 | 371 | ], |
372 | 372 | 'type' => 'select', |
373 | 373 | ], |
@@ -377,8 +377,8 @@ discard block |
||
377 | 377 | 'settings.schema.type.default' => 'Product', |
378 | 378 | 'settings.schema.offertype' => 'Offer', |
379 | 379 | ], |
380 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_price</code>', |
|
381 | - 'label' => __('Price', 'site-reviews'), |
|
380 | + 'description' => __( 'Custom Field name', 'site-reviews' ).': <code>schema_price</code>', |
|
381 | + 'label' => __( 'Price', 'site-reviews' ), |
|
382 | 382 | 'placeholder' => '50.00', |
383 | 383 | 'type' => 'text', |
384 | 384 | ], |
@@ -388,8 +388,8 @@ discard block |
||
388 | 388 | 'settings.schema.type.default' => 'Product', |
389 | 389 | 'settings.schema.offertype' => 'AggregateOffer', |
390 | 390 | ], |
391 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_lowprice</code>', |
|
392 | - 'label' => __('Low Price', 'site-reviews'), |
|
391 | + 'description' => __( 'Custom Field name', 'site-reviews' ).': <code>schema_lowprice</code>', |
|
392 | + 'label' => __( 'Low Price', 'site-reviews' ), |
|
393 | 393 | 'placeholder' => '10.00', |
394 | 394 | 'type' => 'text', |
395 | 395 | ], |
@@ -399,8 +399,8 @@ discard block |
||
399 | 399 | 'settings.schema.type.default' => 'Product', |
400 | 400 | 'settings.schema.offertype' => 'AggregateOffer', |
401 | 401 | ], |
402 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_highprice</code>', |
|
403 | - 'label' => __('High Price', 'site-reviews'), |
|
402 | + 'description' => __( 'Custom Field name', 'site-reviews' ).': <code>schema_highprice</code>', |
|
403 | + 'label' => __( 'High Price', 'site-reviews' ), |
|
404 | 404 | 'placeholder' => '100.00', |
405 | 405 | 'type' => 'text', |
406 | 406 | ], |
@@ -409,34 +409,34 @@ discard block |
||
409 | 409 | 'depends_on' => [ |
410 | 410 | 'settings.schema.type.default' => 'Product', |
411 | 411 | ], |
412 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricecurrency</code>', |
|
413 | - 'label' => __('Price Currency', 'site-reviews'), |
|
412 | + 'description' => __( 'Custom Field name', 'site-reviews' ).': <code>schema_pricecurrency</code>', |
|
413 | + 'label' => __( 'Price Currency', 'site-reviews' ), |
|
414 | 414 | 'placeholder' => 'USD', |
415 | 415 | 'type' => 'text', |
416 | 416 | ], |
417 | 417 | 'settings.submissions.required' => [ |
418 | 418 | 'default' => ['content', 'email', 'name', 'rating', 'terms', 'title'], |
419 | - 'description' => __('Choose which fields should be required in the submission form.', 'site-reviews'), |
|
420 | - 'label' => __('Required Fields', 'site-reviews'), |
|
419 | + 'description' => __( 'Choose which fields should be required in the submission form.', 'site-reviews' ), |
|
420 | + 'label' => __( 'Required Fields', 'site-reviews' ), |
|
421 | 421 | 'options' => [ |
422 | - 'rating' => __('Rating', 'site-reviews'), |
|
423 | - 'title' => __('Title', 'site-reviews'), |
|
424 | - 'content' => __('Review', 'site-reviews'), |
|
425 | - 'name' => __('Name', 'site-reviews'), |
|
426 | - 'email' => __('Email', 'site-reviews'), |
|
427 | - 'terms' => __('Terms', 'site-reviews'), |
|
422 | + 'rating' => __( 'Rating', 'site-reviews' ), |
|
423 | + 'title' => __( 'Title', 'site-reviews' ), |
|
424 | + 'content' => __( 'Review', 'site-reviews' ), |
|
425 | + 'name' => __( 'Name', 'site-reviews' ), |
|
426 | + 'email' => __( 'Email', 'site-reviews' ), |
|
427 | + 'terms' => __( 'Terms', 'site-reviews' ), |
|
428 | 428 | ], |
429 | 429 | 'type' => 'checkbox', |
430 | 430 | ], |
431 | 431 | 'settings.submissions.limit' => [ |
432 | 432 | 'default' => '', |
433 | - 'description' => __('Limits the number of reviews that can be submitted to one-per-person. If you are assigning reviews, then the limit will be applied to the assigned page or category.', 'site-reviews'), |
|
434 | - 'label' => __('Limit Reviews', 'site-reviews'), |
|
433 | + 'description' => __( 'Limits the number of reviews that can be submitted to one-per-person. If you are assigning reviews, then the limit will be applied to the assigned page or category.', 'site-reviews' ), |
|
434 | + 'label' => __( 'Limit Reviews', 'site-reviews' ), |
|
435 | 435 | 'options' => [ |
436 | - '' => __('No Limit', 'site-reviews'), |
|
437 | - 'email' => __('By Email Address', 'site-reviews'), |
|
438 | - 'ip_address' => __('By IP Address', 'site-reviews'), |
|
439 | - 'username' => __('By Username (will only work for registered users)', 'site-reviews'), |
|
436 | + '' => __( 'No Limit', 'site-reviews' ), |
|
437 | + 'email' => __( 'By Email Address', 'site-reviews' ), |
|
438 | + 'ip_address' => __( 'By IP Address', 'site-reviews' ), |
|
439 | + 'username' => __( 'By Username (will only work for registered users)', 'site-reviews' ), |
|
440 | 440 | ], |
441 | 441 | 'type' => 'select', |
442 | 442 | ], |
@@ -445,8 +445,8 @@ discard block |
||
445 | 445 | 'depends_on' => [ |
446 | 446 | 'settings.submissions.limit' => ['email'], |
447 | 447 | ], |
448 | - 'description' => __('One Email per line. All emails in the whitelist will be excluded from the review submission limit.', 'site-reviews'), |
|
449 | - 'label' => __('Email Whitelist', 'site-reviews'), |
|
448 | + 'description' => __( 'One Email per line. All emails in the whitelist will be excluded from the review submission limit.', 'site-reviews' ), |
|
449 | + 'label' => __( 'Email Whitelist', 'site-reviews' ), |
|
450 | 450 | 'rows' => 5, |
451 | 451 | 'type' => 'code', |
452 | 452 | ], |
@@ -455,8 +455,8 @@ discard block |
||
455 | 455 | 'depends_on' => [ |
456 | 456 | 'settings.submissions.limit' => ['ip_address'], |
457 | 457 | ], |
458 | - 'description' => __('One IP Address per line. All IP Addresses in the whitelist will be excluded from the review submission limit..', 'site-reviews'), |
|
459 | - 'label' => __('IP Address Whitelist', 'site-reviews'), |
|
458 | + 'description' => __( 'One IP Address per line. All IP Addresses in the whitelist will be excluded from the review submission limit..', 'site-reviews' ), |
|
459 | + 'label' => __( 'IP Address Whitelist', 'site-reviews' ), |
|
460 | 460 | 'rows' => 5, |
461 | 461 | 'type' => 'code', |
462 | 462 | ], |
@@ -465,15 +465,15 @@ discard block |
||
465 | 465 | 'depends_on' => [ |
466 | 466 | 'settings.submissions.limit' => ['username'], |
467 | 467 | ], |
468 | - 'description' => __('One Username per line. All registered users with a Username in the whitelist will be excluded from the review submission limit.', 'site-reviews'), |
|
469 | - 'label' => __('Username Whitelist', 'site-reviews'), |
|
468 | + 'description' => __( 'One Username per line. All registered users with a Username in the whitelist will be excluded from the review submission limit.', 'site-reviews' ), |
|
469 | + 'label' => __( 'Username Whitelist', 'site-reviews' ), |
|
470 | 470 | 'rows' => 5, |
471 | 471 | 'type' => 'code', |
472 | 472 | ], |
473 | 473 | 'settings.submissions.recaptcha.integration' => [ |
474 | 474 | 'default' => '', |
475 | - 'description' => __('Invisible reCAPTCHA is a free anti-spam service from Google. To use it, you will need to <a href="https://www.google.com/recaptcha/admin" target="_blank">sign up</a> for an API key pair for your site.', 'site-reviews'), |
|
476 | - 'label' => __('Invisible reCAPTCHA', 'site-reviews'), |
|
475 | + 'description' => __( 'Invisible reCAPTCHA is a free anti-spam service from Google. To use it, you will need to <a href="https://www.google.com/recaptcha/admin" target="_blank">sign up</a> for an API key pair for your site.', 'site-reviews' ), |
|
476 | + 'label' => __( 'Invisible reCAPTCHA', 'site-reviews' ), |
|
477 | 477 | 'options' => [ |
478 | 478 | '' => 'Do not use reCAPTCHA', |
479 | 479 | 'all' => 'Use reCAPTCHA', |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | 'depends_on' => [ |
487 | 487 | 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
488 | 488 | ], |
489 | - 'label' => __('Site Key', 'site-reviews'), |
|
489 | + 'label' => __( 'Site Key', 'site-reviews' ), |
|
490 | 490 | 'type' => 'text', |
491 | 491 | ], |
492 | 492 | 'settings.submissions.recaptcha.secret' => [ |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | 'depends_on' => [ |
495 | 495 | 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
496 | 496 | ], |
497 | - 'label' => __('Site Secret', 'site-reviews'), |
|
497 | + 'label' => __( 'Site Secret', 'site-reviews' ), |
|
498 | 498 | 'type' => 'text', |
499 | 499 | ], |
500 | 500 | 'settings.submissions.recaptcha.position' => [ |
@@ -502,8 +502,8 @@ discard block |
||
502 | 502 | 'depends_on' => [ |
503 | 503 | 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
504 | 504 | ], |
505 | - 'description' => __('This option may not work consistently if another plugin is loading reCAPTCHA on the same page as Site Reviews.', 'site-reviews'), |
|
506 | - 'label' => __('Badge Position', 'site-reviews'), |
|
505 | + 'description' => __( 'This option may not work consistently if another plugin is loading reCAPTCHA on the same page as Site Reviews.', 'site-reviews' ), |
|
506 | + 'label' => __( 'Badge Position', 'site-reviews' ), |
|
507 | 507 | 'options' => [ |
508 | 508 | 'bottomleft' => 'Bottom Left', |
509 | 509 | 'bottomright' => 'Bottom Right', |
@@ -513,16 +513,16 @@ discard block |
||
513 | 513 | ], |
514 | 514 | 'settings.submissions.akismet' => [ |
515 | 515 | 'default' => 'no', |
516 | - 'description' => __('The <a href="https://akismet.com" target="_blank">Akismet plugin</a> integration provides spam-filtering for your reviews. In order for this setting to have any affect, you will need to first install and activate the Akismet plugin and set up a WordPress.com API key.', 'site-reviews'), |
|
517 | - 'label' => __('Enable Akismet Integration', 'site-reviews'), |
|
516 | + 'description' => __( 'The <a href="https://akismet.com" target="_blank">Akismet plugin</a> integration provides spam-filtering for your reviews. In order for this setting to have any affect, you will need to first install and activate the Akismet plugin and set up a WordPress.com API key.', 'site-reviews' ), |
|
517 | + 'label' => __( 'Enable Akismet Integration', 'site-reviews' ), |
|
518 | 518 | 'type' => 'yes_no', |
519 | 519 | ], |
520 | 520 | 'settings.submissions.blacklist.integration' => [ |
521 | 521 | 'default' => '', |
522 | - 'description' => sprintf(__('Choose which Blacklist you would prefer to use for reviews. The %s can be found in the WordPress Discussion Settings page.', 'site-reviews'), |
|
523 | - '<a href="'.admin_url('options-discussion.php#users_can_register').'">'.__('Comment Blacklist', 'site-reviews').'</a>' |
|
522 | + 'description' => sprintf( __( 'Choose which Blacklist you would prefer to use for reviews. The %s can be found in the WordPress Discussion Settings page.', 'site-reviews' ), |
|
523 | + '<a href="'.admin_url( 'options-discussion.php#users_can_register' ).'">'.__( 'Comment Blacklist', 'site-reviews' ).'</a>' |
|
524 | 524 | ), |
525 | - 'label' => __('Blacklist', 'site-reviews'), |
|
525 | + 'label' => __( 'Blacklist', 'site-reviews' ), |
|
526 | 526 | 'options' => [ |
527 | 527 | '' => 'Use the Site Reviews Blacklist', |
528 | 528 | 'comments' => 'Use the WordPress Comment Blacklist', |
@@ -534,18 +534,18 @@ discard block |
||
534 | 534 | 'depends_on' => [ |
535 | 535 | 'settings.submissions.blacklist.integration' => [''], |
536 | 536 | ], |
537 | - 'description' => __('One entry or IP address per line. When a review contains any of these entries in its title, content, name, email, or IP address, it will be rejected. It is case-insensitive and will match partial words, so "press" will match "WordPress".', 'site-reviews'), |
|
538 | - 'label' => __('Review Blacklist', 'site-reviews'), |
|
537 | + 'description' => __( 'One entry or IP address per line. When a review contains any of these entries in its title, content, name, email, or IP address, it will be rejected. It is case-insensitive and will match partial words, so "press" will match "WordPress".', 'site-reviews' ), |
|
538 | + 'label' => __( 'Review Blacklist', 'site-reviews' ), |
|
539 | 539 | 'rows' => 10, |
540 | 540 | 'type' => 'code', |
541 | 541 | ], |
542 | 542 | 'settings.submissions.blacklist.action' => [ |
543 | 543 | 'default' => 'unapprove', |
544 | - 'description' => __('Choose the action that should be taken when a review is blacklisted.', 'site-reviews'), |
|
545 | - 'label' => __('Blacklist Action', 'site-reviews'), |
|
544 | + 'description' => __( 'Choose the action that should be taken when a review is blacklisted.', 'site-reviews' ), |
|
545 | + 'label' => __( 'Blacklist Action', 'site-reviews' ), |
|
546 | 546 | 'options' => [ |
547 | - 'unapprove' => __('Require approval', 'site-reviews'), |
|
548 | - 'reject' => __('Reject submission', 'site-reviews'), |
|
547 | + 'unapprove' => __( 'Require approval', 'site-reviews' ), |
|
548 | + 'reject' => __( 'Reject submission', 'site-reviews' ), |
|
549 | 549 | ], |
550 | 550 | 'type' => 'select', |
551 | 551 | ], |