@@ -9,25 +9,25 @@ discard block |
||
9 | 9 | * @return mixed |
10 | 10 | */ |
11 | 11 | add_filter('plugins_loaded', function () { |
12 | - $hooks = array( |
|
13 | - 'glsr_calculate_ratings' => 1, |
|
14 | - 'glsr_create_review' => 2, |
|
15 | - 'glsr_debug' => 10, |
|
16 | - 'glsr_get' => 4, |
|
17 | - 'glsr_get_option' => 4, |
|
18 | - 'glsr_get_options' => 1, |
|
19 | - 'glsr_get_review' => 2, |
|
20 | - 'glsr_get_reviews' => 2, |
|
21 | - 'glsr_log' => 3, |
|
22 | - 'glsr_star_rating' => 2, |
|
23 | - ); |
|
24 | - foreach ($hooks as $function => $acceptedArgs) { |
|
25 | - add_filter($function, function () use ($function) { |
|
26 | - $args = func_get_args(); |
|
27 | - array_shift($args); // remove the fallback value |
|
28 | - return call_user_func_array($function, $args); |
|
29 | - }, 10, $acceptedArgs); |
|
30 | - } |
|
12 | + $hooks = array( |
|
13 | + 'glsr_calculate_ratings' => 1, |
|
14 | + 'glsr_create_review' => 2, |
|
15 | + 'glsr_debug' => 10, |
|
16 | + 'glsr_get' => 4, |
|
17 | + 'glsr_get_option' => 4, |
|
18 | + 'glsr_get_options' => 1, |
|
19 | + 'glsr_get_review' => 2, |
|
20 | + 'glsr_get_reviews' => 2, |
|
21 | + 'glsr_log' => 3, |
|
22 | + 'glsr_star_rating' => 2, |
|
23 | + ); |
|
24 | + foreach ($hooks as $function => $acceptedArgs) { |
|
25 | + add_filter($function, function () use ($function) { |
|
26 | + $args = func_get_args(); |
|
27 | + array_shift($args); // remove the fallback value |
|
28 | + return call_user_func_array($function, $args); |
|
29 | + }, 10, $acceptedArgs); |
|
30 | + } |
|
31 | 31 | }); |
32 | 32 | |
33 | 33 | /** |
@@ -35,10 +35,10 @@ discard block |
||
35 | 35 | */ |
36 | 36 | function glsr($alias = null) |
37 | 37 | { |
38 | - $app = \GeminiLabs\SiteReviews\Application::load(); |
|
39 | - return !is_null($alias) |
|
40 | - ? $app->make($alias) |
|
41 | - : $app; |
|
38 | + $app = \GeminiLabs\SiteReviews\Application::load(); |
|
39 | + return !is_null($alias) |
|
40 | + ? $app->make($alias) |
|
41 | + : $app; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -48,15 +48,15 @@ discard block |
||
48 | 48 | */ |
49 | 49 | function glsr_array_column(array $array, $column) |
50 | 50 | { |
51 | - $result = array(); |
|
52 | - foreach ($array as $subarray) { |
|
53 | - $subarray = (array) $subarray; |
|
54 | - if (!isset($subarray[$column])) { |
|
55 | - continue; |
|
56 | - } |
|
57 | - $result[] = $subarray[$column]; |
|
58 | - } |
|
59 | - return $result; |
|
51 | + $result = array(); |
|
52 | + foreach ($array as $subarray) { |
|
53 | + $subarray = (array) $subarray; |
|
54 | + if (!isset($subarray[$column])) { |
|
55 | + continue; |
|
56 | + } |
|
57 | + $result[] = $subarray[$column]; |
|
58 | + } |
|
59 | + return $result; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | */ |
65 | 65 | function glsr_calculate_ratings() |
66 | 66 | { |
67 | - glsr('Database\CountsManager')->updateAll(); |
|
68 | - glsr_log()->notice(__('Recalculated rating counts.', 'site-reviews')); |
|
67 | + glsr('Database\CountsManager')->updateAll(); |
|
68 | + glsr_log()->notice(__('Recalculated rating counts.', 'site-reviews')); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | */ |
74 | 74 | function glsr_create_review($reviewValues = array()) |
75 | 75 | { |
76 | - $review = new \GeminiLabs\SiteReviews\Commands\CreateReview( |
|
77 | - \GeminiLabs\SiteReviews\Helpers\Arr::consolidate($reviewValues) |
|
78 | - ); |
|
79 | - return glsr('Database\ReviewManager')->create($review); |
|
76 | + $review = new \GeminiLabs\SiteReviews\Commands\CreateReview( |
|
77 | + \GeminiLabs\SiteReviews\Helpers\Arr::consolidate($reviewValues) |
|
78 | + ); |
|
79 | + return glsr('Database\ReviewManager')->create($review); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,12 +84,12 @@ discard block |
||
84 | 84 | */ |
85 | 85 | function glsr_current_screen() |
86 | 86 | { |
87 | - if (function_exists('get_current_screen')) { |
|
88 | - $screen = get_current_screen(); |
|
89 | - } |
|
90 | - return empty($screen) |
|
91 | - ? (object) array_fill_keys(['base', 'id', 'post_type'], null) |
|
92 | - : $screen; |
|
87 | + if (function_exists('get_current_screen')) { |
|
88 | + $screen = get_current_screen(); |
|
89 | + } |
|
90 | + return empty($screen) |
|
91 | + ? (object) array_fill_keys(['base', 'id', 'post_type'], null) |
|
92 | + : $screen; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -98,16 +98,16 @@ discard block |
||
98 | 98 | */ |
99 | 99 | function glsr_debug(...$vars) |
100 | 100 | { |
101 | - if (1 == count($vars)) { |
|
102 | - $value = htmlspecialchars(print_r($vars[0], true), ENT_QUOTES, 'UTF-8'); |
|
103 | - printf('<div class="glsr-debug"><pre>%s</pre></div>', $value); |
|
104 | - } else { |
|
105 | - echo '<div class="glsr-debug-group">'; |
|
106 | - foreach ($vars as $var) { |
|
107 | - glsr_debug($var); |
|
108 | - } |
|
109 | - echo '</div>'; |
|
110 | - } |
|
101 | + if (1 == count($vars)) { |
|
102 | + $value = htmlspecialchars(print_r($vars[0], true), ENT_QUOTES, 'UTF-8'); |
|
103 | + printf('<div class="glsr-debug"><pre>%s</pre></div>', $value); |
|
104 | + } else { |
|
105 | + echo '<div class="glsr-debug-group">'; |
|
106 | + foreach ($vars as $var) { |
|
107 | + glsr_debug($var); |
|
108 | + } |
|
109 | + echo '</div>'; |
|
110 | + } |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | function glsr_get($array, $path = '', $fallback = '') |
120 | 120 | { |
121 | - return \GeminiLabs\SiteReviews\Helpers\Arr::get($array, $path, $fallback); |
|
121 | + return \GeminiLabs\SiteReviews\Helpers\Arr::get($array, $path, $fallback); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | */ |
130 | 130 | function glsr_get_option($path = '', $fallback = '', $cast = '') |
131 | 131 | { |
132 | - return is_string($path) |
|
133 | - ? glsr('Database\OptionManager')->get(\GeminiLabs\SiteReviews\Helpers\Str::prefix('settings.', $path), $fallback, $cast) |
|
134 | - : $fallback; |
|
132 | + return is_string($path) |
|
133 | + ? glsr('Database\OptionManager')->get(\GeminiLabs\SiteReviews\Helpers\Str::prefix('settings.', $path), $fallback, $cast) |
|
134 | + : $fallback; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | function glsr_get_options() |
141 | 141 | { |
142 | - return glsr('Database\OptionManager')->get('settings'); |
|
142 | + return glsr('Database\OptionManager')->get('settings'); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -148,13 +148,13 @@ discard block |
||
148 | 148 | */ |
149 | 149 | function glsr_get_review($post) |
150 | 150 | { |
151 | - if (is_numeric($post)) { |
|
152 | - $post = get_post($post); |
|
153 | - } |
|
154 | - if (!($post instanceof WP_Post)) { |
|
155 | - $post = new WP_Post((object) []); |
|
156 | - } |
|
157 | - return glsr('Database\ReviewManager')->single($post); |
|
151 | + if (is_numeric($post)) { |
|
152 | + $post = get_post($post); |
|
153 | + } |
|
154 | + if (!($post instanceof WP_Post)) { |
|
155 | + $post = new WP_Post((object) []); |
|
156 | + } |
|
157 | + return glsr('Database\ReviewManager')->single($post); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | */ |
163 | 163 | function glsr_get_reviews($args = array()) |
164 | 164 | { |
165 | - return glsr('Database\ReviewManager')->get(\GeminiLabs\SiteReviews\Helpers\Arr::consolidate($args)); |
|
165 | + return glsr('Database\ReviewManager')->get(\GeminiLabs\SiteReviews\Helpers\Arr::consolidate($args)); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -170,12 +170,12 @@ discard block |
||
170 | 170 | */ |
171 | 171 | function glsr_log() |
172 | 172 | { |
173 | - $args = func_get_args(); |
|
174 | - $console = glsr('Modules\Console'); |
|
175 | - if ($value = \GeminiLabs\SiteReviews\Helpers\Arr::get($args, '0')) { |
|
176 | - return $console->debug($value, \GeminiLabs\SiteReviews\Helpers\Arr::get($args, '1', [])); |
|
177 | - } |
|
178 | - return $console; |
|
173 | + $args = func_get_args(); |
|
174 | + $console = glsr('Modules\Console'); |
|
175 | + if ($value = \GeminiLabs\SiteReviews\Helpers\Arr::get($args, '0')) { |
|
176 | + return $console->debug($value, \GeminiLabs\SiteReviews\Helpers\Arr::get($args, '1', [])); |
|
177 | + } |
|
178 | + return $console; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -183,5 +183,5 @@ discard block |
||
183 | 183 | */ |
184 | 184 | function glsr_star_rating($rating) |
185 | 185 | { |
186 | - return glsr('Modules\Html\Partial')->build('star-rating', ['rating' => $rating]); |
|
186 | + return glsr('Modules\Html\Partial')->build('star-rating', ['rating' => $rating]); |
|
187 | 187 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -defined('WPINC') || die; |
|
3 | +defined( 'WPINC' ) || die; |
|
4 | 4 | |
5 | 5 | /* |
6 | 6 | * Alternate method of using the functions without having to use `function_exists()` |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @param mixed ... |
9 | 9 | * @return mixed |
10 | 10 | */ |
11 | -add_filter('plugins_loaded', function () { |
|
11 | +add_filter( 'plugins_loaded', function() { |
|
12 | 12 | $hooks = array( |
13 | 13 | 'glsr_calculate_ratings' => 1, |
14 | 14 | 'glsr_create_review' => 2, |
@@ -21,23 +21,23 @@ discard block |
||
21 | 21 | 'glsr_log' => 3, |
22 | 22 | 'glsr_star_rating' => 2, |
23 | 23 | ); |
24 | - foreach ($hooks as $function => $acceptedArgs) { |
|
25 | - add_filter($function, function () use ($function) { |
|
24 | + foreach( $hooks as $function => $acceptedArgs ) { |
|
25 | + add_filter( $function, function() use ($function) { |
|
26 | 26 | $args = func_get_args(); |
27 | - array_shift($args); // remove the fallback value |
|
28 | - return call_user_func_array($function, $args); |
|
29 | - }, 10, $acceptedArgs); |
|
27 | + array_shift( $args ); // remove the fallback value |
|
28 | + return call_user_func_array( $function, $args ); |
|
29 | + }, 10, $acceptedArgs ); |
|
30 | 30 | } |
31 | 31 | }); |
32 | 32 | |
33 | 33 | /** |
34 | 34 | * @return mixed |
35 | 35 | */ |
36 | -function glsr($alias = null) |
|
36 | +function glsr( $alias = null ) |
|
37 | 37 | { |
38 | 38 | $app = \GeminiLabs\SiteReviews\Application::load(); |
39 | - return !is_null($alias) |
|
40 | - ? $app->make($alias) |
|
39 | + return !is_null( $alias ) |
|
40 | + ? $app->make( $alias ) |
|
41 | 41 | : $app; |
42 | 42 | } |
43 | 43 | |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | * @param $column string |
47 | 47 | * @return array |
48 | 48 | */ |
49 | -function glsr_array_column(array $array, $column) |
|
49 | +function glsr_array_column( array $array, $column ) |
|
50 | 50 | { |
51 | 51 | $result = array(); |
52 | - foreach ($array as $subarray) { |
|
53 | - $subarray = (array) $subarray; |
|
54 | - if (!isset($subarray[$column])) { |
|
52 | + foreach( $array as $subarray ) { |
|
53 | + $subarray = (array)$subarray; |
|
54 | + if( !isset($subarray[$column]) ) { |
|
55 | 55 | continue; |
56 | 56 | } |
57 | 57 | $result[] = $subarray[$column]; |
@@ -64,19 +64,19 @@ discard block |
||
64 | 64 | */ |
65 | 65 | function glsr_calculate_ratings() |
66 | 66 | { |
67 | - glsr('Database\CountsManager')->updateAll(); |
|
68 | - glsr_log()->notice(__('Recalculated rating counts.', 'site-reviews')); |
|
67 | + glsr( 'Database\CountsManager' )->updateAll(); |
|
68 | + glsr_log()->notice( __( 'Recalculated rating counts.', 'site-reviews' ) ); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
72 | 72 | * @return \GeminiLabs\SiteReviews\Review|false |
73 | 73 | */ |
74 | -function glsr_create_review($reviewValues = array()) |
|
74 | +function glsr_create_review( $reviewValues = array() ) |
|
75 | 75 | { |
76 | 76 | $review = new \GeminiLabs\SiteReviews\Commands\CreateReview( |
77 | - \GeminiLabs\SiteReviews\Helpers\Arr::consolidate($reviewValues) |
|
77 | + \GeminiLabs\SiteReviews\Helpers\Arr::consolidate( $reviewValues ) |
|
78 | 78 | ); |
79 | - return glsr('Database\ReviewManager')->create($review); |
|
79 | + return glsr( 'Database\ReviewManager' )->create( $review ); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,11 +84,11 @@ discard block |
||
84 | 84 | */ |
85 | 85 | function glsr_current_screen() |
86 | 86 | { |
87 | - if (function_exists('get_current_screen')) { |
|
87 | + if( function_exists( 'get_current_screen' ) ) { |
|
88 | 88 | $screen = get_current_screen(); |
89 | 89 | } |
90 | 90 | return empty($screen) |
91 | - ? (object) array_fill_keys(['base', 'id', 'post_type'], null) |
|
91 | + ? (object)array_fill_keys( ['base', 'id', 'post_type'], null ) |
|
92 | 92 | : $screen; |
93 | 93 | } |
94 | 94 | |
@@ -96,15 +96,15 @@ discard block |
||
96 | 96 | * @param mixed ...$vars |
97 | 97 | * @return void |
98 | 98 | */ |
99 | -function glsr_debug(...$vars) |
|
99 | +function glsr_debug( ...$vars ) |
|
100 | 100 | { |
101 | - if (1 == count($vars)) { |
|
102 | - $value = htmlspecialchars(print_r($vars[0], true), ENT_QUOTES, 'UTF-8'); |
|
103 | - printf('<div class="glsr-debug"><pre>%s</pre></div>', $value); |
|
101 | + if( 1 == count( $vars ) ) { |
|
102 | + $value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' ); |
|
103 | + printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value ); |
|
104 | 104 | } else { |
105 | 105 | echo '<div class="glsr-debug-group">'; |
106 | - foreach ($vars as $var) { |
|
107 | - glsr_debug($var); |
|
106 | + foreach( $vars as $var ) { |
|
107 | + glsr_debug( $var ); |
|
108 | 108 | } |
109 | 109 | echo '</div>'; |
110 | 110 | } |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | * @param mixed $fallback |
117 | 117 | * @return mixed |
118 | 118 | */ |
119 | -function glsr_get($array, $path = '', $fallback = '') |
|
119 | +function glsr_get( $array, $path = '', $fallback = '' ) |
|
120 | 120 | { |
121 | - return \GeminiLabs\SiteReviews\Helpers\Arr::get($array, $path, $fallback); |
|
121 | + return \GeminiLabs\SiteReviews\Helpers\Arr::get( $array, $path, $fallback ); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -127,10 +127,10 @@ discard block |
||
127 | 127 | * @param string $cast |
128 | 128 | * @return string|array |
129 | 129 | */ |
130 | -function glsr_get_option($path = '', $fallback = '', $cast = '') |
|
130 | +function glsr_get_option( $path = '', $fallback = '', $cast = '' ) |
|
131 | 131 | { |
132 | - return is_string($path) |
|
133 | - ? glsr('Database\OptionManager')->get(\GeminiLabs\SiteReviews\Helpers\Str::prefix('settings.', $path), $fallback, $cast) |
|
132 | + return is_string( $path ) |
|
133 | + ? glsr( 'Database\OptionManager' )->get( \GeminiLabs\SiteReviews\Helpers\Str::prefix( 'settings.', $path ), $fallback, $cast ) |
|
134 | 134 | : $fallback; |
135 | 135 | } |
136 | 136 | |
@@ -139,30 +139,30 @@ discard block |
||
139 | 139 | */ |
140 | 140 | function glsr_get_options() |
141 | 141 | { |
142 | - return glsr('Database\OptionManager')->get('settings'); |
|
142 | + return glsr( 'Database\OptionManager' )->get( 'settings' ); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
146 | 146 | * @param \WP_Post|int $post |
147 | 147 | * @return \GeminiLabs\SiteReviews\Review |
148 | 148 | */ |
149 | -function glsr_get_review($post) |
|
149 | +function glsr_get_review( $post ) |
|
150 | 150 | { |
151 | - if (is_numeric($post)) { |
|
152 | - $post = get_post($post); |
|
151 | + if( is_numeric( $post ) ) { |
|
152 | + $post = get_post( $post ); |
|
153 | 153 | } |
154 | - if (!($post instanceof WP_Post)) { |
|
155 | - $post = new WP_Post((object) []); |
|
154 | + if( !($post instanceof WP_Post) ) { |
|
155 | + $post = new WP_Post( (object)[] ); |
|
156 | 156 | } |
157 | - return glsr('Database\ReviewManager')->single($post); |
|
157 | + return glsr( 'Database\ReviewManager' )->single( $post ); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
161 | 161 | * @return array |
162 | 162 | */ |
163 | -function glsr_get_reviews($args = array()) |
|
163 | +function glsr_get_reviews( $args = array() ) |
|
164 | 164 | { |
165 | - return glsr('Database\ReviewManager')->get(\GeminiLabs\SiteReviews\Helpers\Arr::consolidate($args)); |
|
165 | + return glsr( 'Database\ReviewManager' )->get( \GeminiLabs\SiteReviews\Helpers\Arr::consolidate( $args ) ); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | function glsr_log() |
172 | 172 | { |
173 | 173 | $args = func_get_args(); |
174 | - $console = glsr('Modules\Console'); |
|
175 | - if ($value = \GeminiLabs\SiteReviews\Helpers\Arr::get($args, '0')) { |
|
176 | - return $console->debug($value, \GeminiLabs\SiteReviews\Helpers\Arr::get($args, '1', [])); |
|
174 | + $console = glsr( 'Modules\Console' ); |
|
175 | + if( $value = \GeminiLabs\SiteReviews\Helpers\Arr::get( $args, '0' ) ) { |
|
176 | + return $console->debug( $value, \GeminiLabs\SiteReviews\Helpers\Arr::get( $args, '1', [] ) ); |
|
177 | 177 | } |
178 | 178 | return $console; |
179 | 179 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | /** |
182 | 182 | * @return string |
183 | 183 | */ |
184 | -function glsr_star_rating($rating) |
|
184 | +function glsr_star_rating( $rating ) |
|
185 | 185 | { |
186 | - return glsr('Modules\Html\Partial')->build('star-rating', ['rating' => $rating]); |
|
186 | + return glsr( 'Modules\Html\Partial' )->build( 'star-rating', ['rating' => $rating] ); |
|
187 | 187 | } |
@@ -1,22 +1,22 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | return [ |
4 | - 'fields' => [ |
|
5 | - 'input' => 'input', |
|
6 | - 'input_checkbox' => 'input', |
|
7 | - 'input_radio' => 'input', |
|
8 | - 'label' => 'et_pb_contact_form_label', |
|
9 | - 'select' => 'et_pb_contact_select input', |
|
10 | - 'textarea' => 'et_pb_contact_message input', |
|
11 | - ], |
|
12 | - 'validation' => [ |
|
13 | - 'field_error_class' => 'et_contact_error', |
|
14 | - 'input_error_class' => 'et_contact_error', |
|
15 | - // 'input_valid_class' => 'glsr-is-valid', |
|
16 | - // 'message_error_class' => 'glsr-has-errors', |
|
17 | - // 'message_initial_class' => 'glsr-is-visible', |
|
18 | - // 'message_success_class' => 'glsr-has-success', |
|
19 | - // 'message_tag' => 'div', |
|
20 | - // 'message_tag_class' => 'glsr-form-message', |
|
21 | - ], |
|
4 | + 'fields' => [ |
|
5 | + 'input' => 'input', |
|
6 | + 'input_checkbox' => 'input', |
|
7 | + 'input_radio' => 'input', |
|
8 | + 'label' => 'et_pb_contact_form_label', |
|
9 | + 'select' => 'et_pb_contact_select input', |
|
10 | + 'textarea' => 'et_pb_contact_message input', |
|
11 | + ], |
|
12 | + 'validation' => [ |
|
13 | + 'field_error_class' => 'et_contact_error', |
|
14 | + 'input_error_class' => 'et_contact_error', |
|
15 | + // 'input_valid_class' => 'glsr-is-valid', |
|
16 | + // 'message_error_class' => 'glsr-has-errors', |
|
17 | + // 'message_initial_class' => 'glsr-is-visible', |
|
18 | + // 'message_success_class' => 'glsr-has-success', |
|
19 | + // 'message_tag' => 'div', |
|
20 | + // 'message_tag_class' => 'glsr-form-message', |
|
21 | + ], |
|
22 | 22 | ]; |
@@ -3,144 +3,144 @@ |
||
3 | 3 | defined('WPINC') || die; |
4 | 4 | |
5 | 5 | if (apply_filters('site-reviews/support/deprecated/v4', true)) { |
6 | - // Unprotected review meta has been deprecated |
|
7 | - add_filter('get_post_metadata', function ($data, $postId, $metaKey, $single) { |
|
8 | - $metaKeys = array_keys(glsr('Defaults\CreateReviewDefaults')->defaults()); |
|
9 | - if (!in_array($metaKey, $metaKeys) || glsr()->post_type != get_post_type($postId)) { |
|
10 | - return $data; |
|
11 | - } |
|
12 | - glsr()->deprecated[] = sprintf( |
|
13 | - 'The "%1$s" meta_key has been deprecated for Reviews. Please use the protected "_%1$s" meta_key instead.', |
|
14 | - $metaKey |
|
15 | - ); |
|
16 | - return get_post_meta($postId, '_'.$metaKey, $single); |
|
17 | - }, 10, 4); |
|
6 | + // Unprotected review meta has been deprecated |
|
7 | + add_filter('get_post_metadata', function ($data, $postId, $metaKey, $single) { |
|
8 | + $metaKeys = array_keys(glsr('Defaults\CreateReviewDefaults')->defaults()); |
|
9 | + if (!in_array($metaKey, $metaKeys) || glsr()->post_type != get_post_type($postId)) { |
|
10 | + return $data; |
|
11 | + } |
|
12 | + glsr()->deprecated[] = sprintf( |
|
13 | + 'The "%1$s" meta_key has been deprecated for Reviews. Please use the protected "_%1$s" meta_key instead.', |
|
14 | + $metaKey |
|
15 | + ); |
|
16 | + return get_post_meta($postId, '_'.$metaKey, $single); |
|
17 | + }, 10, 4); |
|
18 | 18 | |
19 | - // Modules/Html/Template.php |
|
20 | - add_filter('site-reviews/interpolate/reviews', function ($context, $template) { |
|
21 | - $search = '{{ navigation }}'; |
|
22 | - if (false !== strpos($template, $search)) { |
|
23 | - $context['navigation'] = $context['pagination']; |
|
24 | - glsr()->deprecated[] = 'The {{ navigation }} template key in "YOUR_THEME/site-reviews/reviews.php" has been deprecated. Please use the {{ pagination }} template key instead.'; |
|
25 | - } |
|
26 | - return $context; |
|
27 | - }, 10, 2); |
|
19 | + // Modules/Html/Template.php |
|
20 | + add_filter('site-reviews/interpolate/reviews', function ($context, $template) { |
|
21 | + $search = '{{ navigation }}'; |
|
22 | + if (false !== strpos($template, $search)) { |
|
23 | + $context['navigation'] = $context['pagination']; |
|
24 | + glsr()->deprecated[] = 'The {{ navigation }} template key in "YOUR_THEME/site-reviews/reviews.php" has been deprecated. Please use the {{ pagination }} template key instead.'; |
|
25 | + } |
|
26 | + return $context; |
|
27 | + }, 10, 2); |
|
28 | 28 | |
29 | - // Modules/Html/Template.php |
|
30 | - add_filter('site-reviews/build/template/reviews', function ($template) { |
|
31 | - if (has_filter('site-reviews/reviews/pagination-wrapper')) { |
|
32 | - glsr()->deprecated[] = 'The "site-reviews/reviews/pagination-wrapper" hook has been removed. Please use the "site-reviews/builder/result" hook instead.'; |
|
33 | - } |
|
34 | - if (has_filter('site-reviews/reviews/reviews-wrapper')) { |
|
35 | - glsr()->deprecated[] = 'The "site-reviews/reviews/reviews-wrapper" hook has been removed. Please use the "site-reviews/builder/result" hook instead.'; |
|
36 | - } |
|
37 | - }); |
|
29 | + // Modules/Html/Template.php |
|
30 | + add_filter('site-reviews/build/template/reviews', function ($template) { |
|
31 | + if (has_filter('site-reviews/reviews/pagination-wrapper')) { |
|
32 | + glsr()->deprecated[] = 'The "site-reviews/reviews/pagination-wrapper" hook has been removed. Please use the "site-reviews/builder/result" hook instead.'; |
|
33 | + } |
|
34 | + if (has_filter('site-reviews/reviews/reviews-wrapper')) { |
|
35 | + glsr()->deprecated[] = 'The "site-reviews/reviews/reviews-wrapper" hook has been removed. Please use the "site-reviews/builder/result" hook instead.'; |
|
36 | + } |
|
37 | + }); |
|
38 | 38 | |
39 | - // Database/ReviewManager.php |
|
40 | - add_action('site-reviews/review/created', function ($review) { |
|
41 | - if (has_action('site-reviews/local/review/create')) { |
|
42 | - glsr()->deprecated[] = 'The "site-reviews/local/review/create" hook has been deprecated. Please use the "site-reviews/review/created" hook instead.'; |
|
43 | - do_action('site-reviews/local/review/create', (array) get_post($review->ID), (array) $review, $review->ID); |
|
44 | - } |
|
45 | - }, 9); |
|
39 | + // Database/ReviewManager.php |
|
40 | + add_action('site-reviews/review/created', function ($review) { |
|
41 | + if (has_action('site-reviews/local/review/create')) { |
|
42 | + glsr()->deprecated[] = 'The "site-reviews/local/review/create" hook has been deprecated. Please use the "site-reviews/review/created" hook instead.'; |
|
43 | + do_action('site-reviews/local/review/create', (array) get_post($review->ID), (array) $review, $review->ID); |
|
44 | + } |
|
45 | + }, 9); |
|
46 | 46 | |
47 | - // Handlers/CreateReview.php |
|
48 | - add_action('site-reviews/review/submitted', function ($review) { |
|
49 | - if (has_action('site-reviews/local/review/submitted')) { |
|
50 | - glsr()->deprecated[] = 'The "site-reviews/local/review/submitted" hook has been deprecated. Please use the "site-reviews/review/submitted" hook instead.'; |
|
51 | - do_action('site-reviews/local/review/submitted', null, $review); |
|
52 | - } |
|
53 | - if (has_filter('site-reviews/local/review/submitted/message')) { |
|
54 | - glsr()->deprecated[] = 'The "site-reviews/local/review/submitted/message" hook has been deprecated.'; |
|
55 | - } |
|
56 | - }, 9); |
|
47 | + // Handlers/CreateReview.php |
|
48 | + add_action('site-reviews/review/submitted', function ($review) { |
|
49 | + if (has_action('site-reviews/local/review/submitted')) { |
|
50 | + glsr()->deprecated[] = 'The "site-reviews/local/review/submitted" hook has been deprecated. Please use the "site-reviews/review/submitted" hook instead.'; |
|
51 | + do_action('site-reviews/local/review/submitted', null, $review); |
|
52 | + } |
|
53 | + if (has_filter('site-reviews/local/review/submitted/message')) { |
|
54 | + glsr()->deprecated[] = 'The "site-reviews/local/review/submitted/message" hook has been deprecated.'; |
|
55 | + } |
|
56 | + }, 9); |
|
57 | 57 | |
58 | - // Database/ReviewManager.php |
|
59 | - add_filter('site-reviews/create/review-values', function ($values, $command) { |
|
60 | - if (has_filter('site-reviews/local/review')) { |
|
61 | - glsr()->deprecated[] = 'The "site-reviews/local/review" hook has been deprecated. Please use the "site-reviews/create/review-values" hook instead.'; |
|
62 | - return apply_filters('site-reviews/local/review', $values, $command); |
|
63 | - } |
|
64 | - return $values; |
|
65 | - }, 9, 2); |
|
58 | + // Database/ReviewManager.php |
|
59 | + add_filter('site-reviews/create/review-values', function ($values, $command) { |
|
60 | + if (has_filter('site-reviews/local/review')) { |
|
61 | + glsr()->deprecated[] = 'The "site-reviews/local/review" hook has been deprecated. Please use the "site-reviews/create/review-values" hook instead.'; |
|
62 | + return apply_filters('site-reviews/local/review', $values, $command); |
|
63 | + } |
|
64 | + return $values; |
|
65 | + }, 9, 2); |
|
66 | 66 | |
67 | - // Handlers/EnqueuePublicAssets.php |
|
68 | - add_filter('site-reviews/enqueue/public/localize', function ($variables) { |
|
69 | - if (has_filter('site-reviews/enqueue/localize')) { |
|
70 | - glsr()->deprecated[] = 'The "site-reviews/enqueue/localize" hook has been deprecated. Please use the "site-reviews/enqueue/public/localize" hook instead.'; |
|
71 | - return apply_filters('site-reviews/enqueue/localize', $variables); |
|
72 | - } |
|
73 | - return $variables; |
|
74 | - }, 9); |
|
67 | + // Handlers/EnqueuePublicAssets.php |
|
68 | + add_filter('site-reviews/enqueue/public/localize', function ($variables) { |
|
69 | + if (has_filter('site-reviews/enqueue/localize')) { |
|
70 | + glsr()->deprecated[] = 'The "site-reviews/enqueue/localize" hook has been deprecated. Please use the "site-reviews/enqueue/public/localize" hook instead.'; |
|
71 | + return apply_filters('site-reviews/enqueue/localize', $variables); |
|
72 | + } |
|
73 | + return $variables; |
|
74 | + }, 9); |
|
75 | 75 | |
76 | - // Modules/Rating.php |
|
77 | - add_filter('site-reviews/rating/average', function ($average) { |
|
78 | - if (has_filter('site-reviews/average/rating')) { |
|
79 | - glsr()->deprecated[] = 'The "site-reviews/average/rating" hook has been deprecated. Please use the "site-reviews/rating/average" hook instead.'; |
|
80 | - } |
|
81 | - return $average; |
|
82 | - }, 9); |
|
76 | + // Modules/Rating.php |
|
77 | + add_filter('site-reviews/rating/average', function ($average) { |
|
78 | + if (has_filter('site-reviews/average/rating')) { |
|
79 | + glsr()->deprecated[] = 'The "site-reviews/average/rating" hook has been deprecated. Please use the "site-reviews/rating/average" hook instead.'; |
|
80 | + } |
|
81 | + return $average; |
|
82 | + }, 9); |
|
83 | 83 | |
84 | - // Modules/Rating.php |
|
85 | - add_filter('site-reviews/rating/ranking', function ($ranking) { |
|
86 | - if (has_filter('site-reviews/bayesian/ranking')) { |
|
87 | - glsr()->deprecated[] = 'The "site-reviews/bayesian/ranking" hook has been deprecated. Please use the "site-reviews/rating/ranking" hook instead.'; |
|
88 | - } |
|
89 | - return $ranking; |
|
90 | - }, 9); |
|
84 | + // Modules/Rating.php |
|
85 | + add_filter('site-reviews/rating/ranking', function ($ranking) { |
|
86 | + if (has_filter('site-reviews/bayesian/ranking')) { |
|
87 | + glsr()->deprecated[] = 'The "site-reviews/bayesian/ranking" hook has been deprecated. Please use the "site-reviews/rating/ranking" hook instead.'; |
|
88 | + } |
|
89 | + return $ranking; |
|
90 | + }, 9); |
|
91 | 91 | |
92 | - // Modules/Html/Partials/SiteReviews.php |
|
93 | - add_filter('site-reviews/review/build/after', function ($renderedFields) { |
|
94 | - if (has_filter('site-reviews/reviews/review/text')) { |
|
95 | - glsr()->deprecated[] = 'The "site-reviews/reviews/review/text" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.'; |
|
96 | - } |
|
97 | - if (has_filter('site-reviews/reviews/review/title')) { |
|
98 | - glsr()->deprecated[] = 'The "site-reviews/reviews/review/title" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.'; |
|
99 | - } |
|
100 | - return $renderedFields; |
|
101 | - }, 9); |
|
92 | + // Modules/Html/Partials/SiteReviews.php |
|
93 | + add_filter('site-reviews/review/build/after', function ($renderedFields) { |
|
94 | + if (has_filter('site-reviews/reviews/review/text')) { |
|
95 | + glsr()->deprecated[] = 'The "site-reviews/reviews/review/text" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.'; |
|
96 | + } |
|
97 | + if (has_filter('site-reviews/reviews/review/title')) { |
|
98 | + glsr()->deprecated[] = 'The "site-reviews/reviews/review/title" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.'; |
|
99 | + } |
|
100 | + return $renderedFields; |
|
101 | + }, 9); |
|
102 | 102 | |
103 | - // Modules/Html/Partials/SiteReviews.php |
|
104 | - add_filter('site-reviews/review/build/before', function ($review) { |
|
105 | - if (has_filter('site-reviews/rendered/review')) { |
|
106 | - glsr()->deprecated[] = 'The "site-reviews/rendered/review" hook has been deprecated. Please either use a custom "review.php" template (refer to the documentation), or use the "site-reviews/review/build/after" hook instead.'; |
|
107 | - } |
|
108 | - if (has_filter('site-reviews/rendered/review/meta/order')) { |
|
109 | - glsr()->deprecated[] = 'The "site-reviews/rendered/review/meta/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).'; |
|
110 | - } |
|
111 | - if (has_filter('site-reviews/rendered/review/order')) { |
|
112 | - glsr()->deprecated[] = 'The "site-reviews/rendered/review/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).'; |
|
113 | - } |
|
114 | - if (has_filter('site-reviews/rendered/review-form/login-register')) { |
|
115 | - glsr()->deprecated[] = 'The "site-reviews/rendered/review-form/login-register" hook has been deprecated. Please use a custom "login-register.php" template instead (refer to the documentation).'; |
|
116 | - } |
|
117 | - if (has_filter('site-reviews/reviews/navigation_links')) { |
|
118 | - glsr()->deprecated[] = 'The "site-reviews/reviews/navigation_links" hook has been deprecated. Please use a custom "pagination.php" template instead (refer to the documentation).'; |
|
119 | - } |
|
120 | - return $review; |
|
121 | - }, 9); |
|
103 | + // Modules/Html/Partials/SiteReviews.php |
|
104 | + add_filter('site-reviews/review/build/before', function ($review) { |
|
105 | + if (has_filter('site-reviews/rendered/review')) { |
|
106 | + glsr()->deprecated[] = 'The "site-reviews/rendered/review" hook has been deprecated. Please either use a custom "review.php" template (refer to the documentation), or use the "site-reviews/review/build/after" hook instead.'; |
|
107 | + } |
|
108 | + if (has_filter('site-reviews/rendered/review/meta/order')) { |
|
109 | + glsr()->deprecated[] = 'The "site-reviews/rendered/review/meta/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).'; |
|
110 | + } |
|
111 | + if (has_filter('site-reviews/rendered/review/order')) { |
|
112 | + glsr()->deprecated[] = 'The "site-reviews/rendered/review/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).'; |
|
113 | + } |
|
114 | + if (has_filter('site-reviews/rendered/review-form/login-register')) { |
|
115 | + glsr()->deprecated[] = 'The "site-reviews/rendered/review-form/login-register" hook has been deprecated. Please use a custom "login-register.php" template instead (refer to the documentation).'; |
|
116 | + } |
|
117 | + if (has_filter('site-reviews/reviews/navigation_links')) { |
|
118 | + glsr()->deprecated[] = 'The "site-reviews/reviews/navigation_links" hook has been deprecated. Please use a custom "pagination.php" template instead (refer to the documentation).'; |
|
119 | + } |
|
120 | + return $review; |
|
121 | + }, 9); |
|
122 | 122 | |
123 | - add_filter('site-reviews/validate/custom', function ($result, $request) { |
|
124 | - if (has_filter('site-reviews/validate/review/submission')) { |
|
125 | - glsr_log()->warning('The "site-reviews/validate/review/submission" hook has been deprecated. Please use the "site-reviews/validate/custom" hook instead.'); |
|
126 | - return apply_filters('site-reviews/validate/review/submission', $result, $request); |
|
127 | - } |
|
128 | - return $result; |
|
129 | - }, 9, 2); |
|
123 | + add_filter('site-reviews/validate/custom', function ($result, $request) { |
|
124 | + if (has_filter('site-reviews/validate/review/submission')) { |
|
125 | + glsr_log()->warning('The "site-reviews/validate/review/submission" hook has been deprecated. Please use the "site-reviews/validate/custom" hook instead.'); |
|
126 | + return apply_filters('site-reviews/validate/review/submission', $result, $request); |
|
127 | + } |
|
128 | + return $result; |
|
129 | + }, 9, 2); |
|
130 | 130 | |
131 | - add_filter('site-reviews/views/file', function ($file, $view, $data) { |
|
132 | - if (has_filter('site-reviews/addon/views/file')) { |
|
133 | - glsr()->deprecated[] = 'The "site-reviews/addon/views/file" hook has been deprecated. Please use the "site-reviews/views/file" hook instead.'; |
|
134 | - $file = apply_filters('site-reviews/addon/views/file', $file, $view, $data); |
|
135 | - } |
|
136 | - return $file; |
|
137 | - }, 9, 3); |
|
131 | + add_filter('site-reviews/views/file', function ($file, $view, $data) { |
|
132 | + if (has_filter('site-reviews/addon/views/file')) { |
|
133 | + glsr()->deprecated[] = 'The "site-reviews/addon/views/file" hook has been deprecated. Please use the "site-reviews/views/file" hook instead.'; |
|
134 | + $file = apply_filters('site-reviews/addon/views/file', $file, $view, $data); |
|
135 | + } |
|
136 | + return $file; |
|
137 | + }, 9, 3); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | add_action('wp_footer', function () { |
141 | - $notices = array_keys(array_flip(glsr()->deprecated)); |
|
142 | - natsort($notices); |
|
143 | - foreach ($notices as $notice) { |
|
144 | - glsr_log()->warning($notice); |
|
145 | - } |
|
141 | + $notices = array_keys(array_flip(glsr()->deprecated)); |
|
142 | + natsort($notices); |
|
143 | + foreach ($notices as $notice) { |
|
144 | + glsr_log()->warning($notice); |
|
145 | + } |
|
146 | 146 | }); |
@@ -1,146 +1,146 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -defined('WPINC') || die; |
|
3 | +defined( 'WPINC' ) || die; |
|
4 | 4 | |
5 | -if (apply_filters('site-reviews/support/deprecated/v4', true)) { |
|
5 | +if( apply_filters( 'site-reviews/support/deprecated/v4', true ) ) { |
|
6 | 6 | // Unprotected review meta has been deprecated |
7 | - add_filter('get_post_metadata', function ($data, $postId, $metaKey, $single) { |
|
8 | - $metaKeys = array_keys(glsr('Defaults\CreateReviewDefaults')->defaults()); |
|
9 | - if (!in_array($metaKey, $metaKeys) || glsr()->post_type != get_post_type($postId)) { |
|
7 | + add_filter( 'get_post_metadata', function( $data, $postId, $metaKey, $single ) { |
|
8 | + $metaKeys = array_keys( glsr( 'Defaults\CreateReviewDefaults' )->defaults() ); |
|
9 | + if( !in_array( $metaKey, $metaKeys ) || glsr()->post_type != get_post_type( $postId ) ) { |
|
10 | 10 | return $data; |
11 | 11 | } |
12 | 12 | glsr()->deprecated[] = sprintf( |
13 | 13 | 'The "%1$s" meta_key has been deprecated for Reviews. Please use the protected "_%1$s" meta_key instead.', |
14 | 14 | $metaKey |
15 | 15 | ); |
16 | - return get_post_meta($postId, '_'.$metaKey, $single); |
|
17 | - }, 10, 4); |
|
16 | + return get_post_meta( $postId, '_'.$metaKey, $single ); |
|
17 | + }, 10, 4 ); |
|
18 | 18 | |
19 | 19 | // Modules/Html/Template.php |
20 | - add_filter('site-reviews/interpolate/reviews', function ($context, $template) { |
|
20 | + add_filter( 'site-reviews/interpolate/reviews', function( $context, $template ) { |
|
21 | 21 | $search = '{{ navigation }}'; |
22 | - if (false !== strpos($template, $search)) { |
|
22 | + if( false !== strpos( $template, $search ) ) { |
|
23 | 23 | $context['navigation'] = $context['pagination']; |
24 | 24 | glsr()->deprecated[] = 'The {{ navigation }} template key in "YOUR_THEME/site-reviews/reviews.php" has been deprecated. Please use the {{ pagination }} template key instead.'; |
25 | 25 | } |
26 | 26 | return $context; |
27 | - }, 10, 2); |
|
27 | + }, 10, 2 ); |
|
28 | 28 | |
29 | 29 | // Modules/Html/Template.php |
30 | - add_filter('site-reviews/build/template/reviews', function ($template) { |
|
31 | - if (has_filter('site-reviews/reviews/pagination-wrapper')) { |
|
30 | + add_filter( 'site-reviews/build/template/reviews', function( $template ) { |
|
31 | + if( has_filter( 'site-reviews/reviews/pagination-wrapper' ) ) { |
|
32 | 32 | glsr()->deprecated[] = 'The "site-reviews/reviews/pagination-wrapper" hook has been removed. Please use the "site-reviews/builder/result" hook instead.'; |
33 | 33 | } |
34 | - if (has_filter('site-reviews/reviews/reviews-wrapper')) { |
|
34 | + if( has_filter( 'site-reviews/reviews/reviews-wrapper' ) ) { |
|
35 | 35 | glsr()->deprecated[] = 'The "site-reviews/reviews/reviews-wrapper" hook has been removed. Please use the "site-reviews/builder/result" hook instead.'; |
36 | 36 | } |
37 | 37 | }); |
38 | 38 | |
39 | 39 | // Database/ReviewManager.php |
40 | - add_action('site-reviews/review/created', function ($review) { |
|
41 | - if (has_action('site-reviews/local/review/create')) { |
|
40 | + add_action( 'site-reviews/review/created', function( $review ) { |
|
41 | + if( has_action( 'site-reviews/local/review/create' ) ) { |
|
42 | 42 | glsr()->deprecated[] = 'The "site-reviews/local/review/create" hook has been deprecated. Please use the "site-reviews/review/created" hook instead.'; |
43 | - do_action('site-reviews/local/review/create', (array) get_post($review->ID), (array) $review, $review->ID); |
|
43 | + do_action( 'site-reviews/local/review/create', (array)get_post( $review->ID ), (array)$review, $review->ID ); |
|
44 | 44 | } |
45 | - }, 9); |
|
45 | + }, 9 ); |
|
46 | 46 | |
47 | 47 | // Handlers/CreateReview.php |
48 | - add_action('site-reviews/review/submitted', function ($review) { |
|
49 | - if (has_action('site-reviews/local/review/submitted')) { |
|
48 | + add_action( 'site-reviews/review/submitted', function( $review ) { |
|
49 | + if( has_action( 'site-reviews/local/review/submitted' ) ) { |
|
50 | 50 | glsr()->deprecated[] = 'The "site-reviews/local/review/submitted" hook has been deprecated. Please use the "site-reviews/review/submitted" hook instead.'; |
51 | - do_action('site-reviews/local/review/submitted', null, $review); |
|
51 | + do_action( 'site-reviews/local/review/submitted', null, $review ); |
|
52 | 52 | } |
53 | - if (has_filter('site-reviews/local/review/submitted/message')) { |
|
53 | + if( has_filter( 'site-reviews/local/review/submitted/message' ) ) { |
|
54 | 54 | glsr()->deprecated[] = 'The "site-reviews/local/review/submitted/message" hook has been deprecated.'; |
55 | 55 | } |
56 | - }, 9); |
|
56 | + }, 9 ); |
|
57 | 57 | |
58 | 58 | // Database/ReviewManager.php |
59 | - add_filter('site-reviews/create/review-values', function ($values, $command) { |
|
60 | - if (has_filter('site-reviews/local/review')) { |
|
59 | + add_filter( 'site-reviews/create/review-values', function( $values, $command ) { |
|
60 | + if( has_filter( 'site-reviews/local/review' ) ) { |
|
61 | 61 | glsr()->deprecated[] = 'The "site-reviews/local/review" hook has been deprecated. Please use the "site-reviews/create/review-values" hook instead.'; |
62 | - return apply_filters('site-reviews/local/review', $values, $command); |
|
62 | + return apply_filters( 'site-reviews/local/review', $values, $command ); |
|
63 | 63 | } |
64 | 64 | return $values; |
65 | - }, 9, 2); |
|
65 | + }, 9, 2 ); |
|
66 | 66 | |
67 | 67 | // Handlers/EnqueuePublicAssets.php |
68 | - add_filter('site-reviews/enqueue/public/localize', function ($variables) { |
|
69 | - if (has_filter('site-reviews/enqueue/localize')) { |
|
68 | + add_filter( 'site-reviews/enqueue/public/localize', function( $variables ) { |
|
69 | + if( has_filter( 'site-reviews/enqueue/localize' ) ) { |
|
70 | 70 | glsr()->deprecated[] = 'The "site-reviews/enqueue/localize" hook has been deprecated. Please use the "site-reviews/enqueue/public/localize" hook instead.'; |
71 | - return apply_filters('site-reviews/enqueue/localize', $variables); |
|
71 | + return apply_filters( 'site-reviews/enqueue/localize', $variables ); |
|
72 | 72 | } |
73 | 73 | return $variables; |
74 | - }, 9); |
|
74 | + }, 9 ); |
|
75 | 75 | |
76 | 76 | // Modules/Rating.php |
77 | - add_filter('site-reviews/rating/average', function ($average) { |
|
78 | - if (has_filter('site-reviews/average/rating')) { |
|
77 | + add_filter( 'site-reviews/rating/average', function( $average ) { |
|
78 | + if( has_filter( 'site-reviews/average/rating' ) ) { |
|
79 | 79 | glsr()->deprecated[] = 'The "site-reviews/average/rating" hook has been deprecated. Please use the "site-reviews/rating/average" hook instead.'; |
80 | 80 | } |
81 | 81 | return $average; |
82 | - }, 9); |
|
82 | + }, 9 ); |
|
83 | 83 | |
84 | 84 | // Modules/Rating.php |
85 | - add_filter('site-reviews/rating/ranking', function ($ranking) { |
|
86 | - if (has_filter('site-reviews/bayesian/ranking')) { |
|
85 | + add_filter( 'site-reviews/rating/ranking', function( $ranking ) { |
|
86 | + if( has_filter( 'site-reviews/bayesian/ranking' ) ) { |
|
87 | 87 | glsr()->deprecated[] = 'The "site-reviews/bayesian/ranking" hook has been deprecated. Please use the "site-reviews/rating/ranking" hook instead.'; |
88 | 88 | } |
89 | 89 | return $ranking; |
90 | - }, 9); |
|
90 | + }, 9 ); |
|
91 | 91 | |
92 | 92 | // Modules/Html/Partials/SiteReviews.php |
93 | - add_filter('site-reviews/review/build/after', function ($renderedFields) { |
|
94 | - if (has_filter('site-reviews/reviews/review/text')) { |
|
93 | + add_filter( 'site-reviews/review/build/after', function( $renderedFields ) { |
|
94 | + if( has_filter( 'site-reviews/reviews/review/text' ) ) { |
|
95 | 95 | glsr()->deprecated[] = 'The "site-reviews/reviews/review/text" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.'; |
96 | 96 | } |
97 | - if (has_filter('site-reviews/reviews/review/title')) { |
|
97 | + if( has_filter( 'site-reviews/reviews/review/title' ) ) { |
|
98 | 98 | glsr()->deprecated[] = 'The "site-reviews/reviews/review/title" hook has been deprecated. Please use the "site-reviews/review/build/after" hook instead.'; |
99 | 99 | } |
100 | 100 | return $renderedFields; |
101 | - }, 9); |
|
101 | + }, 9 ); |
|
102 | 102 | |
103 | 103 | // Modules/Html/Partials/SiteReviews.php |
104 | - add_filter('site-reviews/review/build/before', function ($review) { |
|
105 | - if (has_filter('site-reviews/rendered/review')) { |
|
104 | + add_filter( 'site-reviews/review/build/before', function( $review ) { |
|
105 | + if( has_filter( 'site-reviews/rendered/review' ) ) { |
|
106 | 106 | glsr()->deprecated[] = 'The "site-reviews/rendered/review" hook has been deprecated. Please either use a custom "review.php" template (refer to the documentation), or use the "site-reviews/review/build/after" hook instead.'; |
107 | 107 | } |
108 | - if (has_filter('site-reviews/rendered/review/meta/order')) { |
|
108 | + if( has_filter( 'site-reviews/rendered/review/meta/order' ) ) { |
|
109 | 109 | glsr()->deprecated[] = 'The "site-reviews/rendered/review/meta/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).'; |
110 | 110 | } |
111 | - if (has_filter('site-reviews/rendered/review/order')) { |
|
111 | + if( has_filter( 'site-reviews/rendered/review/order' ) ) { |
|
112 | 112 | glsr()->deprecated[] = 'The "site-reviews/rendered/review/order" hook has been deprecated. Please use a custom "review.php" template instead (refer to the documentation).'; |
113 | 113 | } |
114 | - if (has_filter('site-reviews/rendered/review-form/login-register')) { |
|
114 | + if( has_filter( 'site-reviews/rendered/review-form/login-register' ) ) { |
|
115 | 115 | glsr()->deprecated[] = 'The "site-reviews/rendered/review-form/login-register" hook has been deprecated. Please use a custom "login-register.php" template instead (refer to the documentation).'; |
116 | 116 | } |
117 | - if (has_filter('site-reviews/reviews/navigation_links')) { |
|
117 | + if( has_filter( 'site-reviews/reviews/navigation_links' ) ) { |
|
118 | 118 | glsr()->deprecated[] = 'The "site-reviews/reviews/navigation_links" hook has been deprecated. Please use a custom "pagination.php" template instead (refer to the documentation).'; |
119 | 119 | } |
120 | 120 | return $review; |
121 | - }, 9); |
|
121 | + }, 9 ); |
|
122 | 122 | |
123 | - add_filter('site-reviews/validate/custom', function ($result, $request) { |
|
124 | - if (has_filter('site-reviews/validate/review/submission')) { |
|
125 | - glsr_log()->warning('The "site-reviews/validate/review/submission" hook has been deprecated. Please use the "site-reviews/validate/custom" hook instead.'); |
|
126 | - return apply_filters('site-reviews/validate/review/submission', $result, $request); |
|
123 | + add_filter( 'site-reviews/validate/custom', function( $result, $request ) { |
|
124 | + if( has_filter( 'site-reviews/validate/review/submission' ) ) { |
|
125 | + glsr_log()->warning( 'The "site-reviews/validate/review/submission" hook has been deprecated. Please use the "site-reviews/validate/custom" hook instead.' ); |
|
126 | + return apply_filters( 'site-reviews/validate/review/submission', $result, $request ); |
|
127 | 127 | } |
128 | 128 | return $result; |
129 | - }, 9, 2); |
|
129 | + }, 9, 2 ); |
|
130 | 130 | |
131 | - add_filter('site-reviews/views/file', function ($file, $view, $data) { |
|
132 | - if (has_filter('site-reviews/addon/views/file')) { |
|
131 | + add_filter( 'site-reviews/views/file', function( $file, $view, $data ) { |
|
132 | + if( has_filter( 'site-reviews/addon/views/file' ) ) { |
|
133 | 133 | glsr()->deprecated[] = 'The "site-reviews/addon/views/file" hook has been deprecated. Please use the "site-reviews/views/file" hook instead.'; |
134 | - $file = apply_filters('site-reviews/addon/views/file', $file, $view, $data); |
|
134 | + $file = apply_filters( 'site-reviews/addon/views/file', $file, $view, $data ); |
|
135 | 135 | } |
136 | 136 | return $file; |
137 | - }, 9, 3); |
|
137 | + }, 9, 3 ); |
|
138 | 138 | } |
139 | 139 | |
140 | -add_action('wp_footer', function () { |
|
141 | - $notices = array_keys(array_flip(glsr()->deprecated)); |
|
142 | - natsort($notices); |
|
143 | - foreach ($notices as $notice) { |
|
144 | - glsr_log()->warning($notice); |
|
140 | +add_action( 'wp_footer', function() { |
|
141 | + $notices = array_keys( array_flip( glsr()->deprecated ) ); |
|
142 | + natsort( $notices ); |
|
143 | + foreach( $notices as $notice ) { |
|
144 | + glsr_log()->warning( $notice ); |
|
145 | 145 | } |
146 | 146 | }); |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <p>This page shows all of the available shortcode options with examples of how to use them. You can use multiple options in the same shortcode.</p> |
4 | 4 | |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | <div class="glsr-card-header"> |
7 | 7 | <h3>[site_reviews]</h3> |
8 | 8 | <button type="button" class="handlediv" aria-expanded="true"> |
9 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
9 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
10 | 10 | <span class="toggle-indicator" aria-hidden="true"></span> |
11 | 11 | </button> |
12 | 12 | </div> |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | <div class="glsr-card-header"> |
76 | 76 | <h3>[site_reviews_form]</h3> |
77 | 77 | <button type="button" class="handlediv" aria-expanded="true"> |
78 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
78 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
79 | 79 | <span class="toggle-indicator" aria-hidden="true"></span> |
80 | 80 | </button> |
81 | 81 | </div> |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | <div class="glsr-card-header"> |
119 | 119 | <h3>[site_reviews_summary]</h3> |
120 | 120 | <button type="button" class="handlediv" aria-expanded="true"> |
121 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
121 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
122 | 122 | <span class="toggle-indicator" aria-hidden="true"></span> |
123 | 123 | </button> |
124 | 124 | </div> |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | <pre><code>[site_reviews_summary hide="bars,if_empty,rating,stars,summary"]</code></pre> |
149 | 149 | |
150 | 150 | <p class="glsr-heading">labels</p> |
151 | - <p>The "labels" attribute allows you to enter custom labels for the percentage bar levels (from high to low), each level should be separated with a comma. However, rather than using this attribute to change the labels it's recommended to instead create a custom translation for them in the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-translations'); ?>">Settings → Translations</a></code> page.</p> |
|
151 | + <p>The "labels" attribute allows you to enter custom labels for the percentage bar levels (from high to low), each level should be separated with a comma. However, rather than using this attribute to change the labels it's recommended to instead create a custom translation for them in the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-translations' ); ?>">Settings → Translations</a></code> page.</p> |
|
152 | 152 | <p>The default labels value is: <code>"Excellent,Very good,Average,Poor,Terrible"</code></p> |
153 | 153 | <pre><code>[site_reviews_summary labels="5 star,4 star,3 star,2 star,1 star"]</code></pre> |
154 | 154 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | <pre><code>[site_reviews_summary schema="true"]</code></pre> |
166 | 166 | |
167 | 167 | <p class="glsr-heading">text</p> |
168 | - <p>The "text" attribute allows you to change the summary text. Available template tags to use are, "{rating}" which represents the calculated average rating, "{max}" which represents the maximum star rating available, and "{num}" which represents the total number of reviews. However, rather than using this attribute to change the summary text it's recommended to instead create a custom translation for it in the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-translations'); ?>">Settings → Translations</a></code> page. That way, you will be able to customize both the singular (1 review) and plural (2 reviews) summary texts.</p> |
|
168 | + <p>The "text" attribute allows you to change the summary text. Available template tags to use are, "{rating}" which represents the calculated average rating, "{max}" which represents the maximum star rating available, and "{num}" which represents the total number of reviews. However, rather than using this attribute to change the summary text it's recommended to instead create a custom translation for it in the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-translations' ); ?>">Settings → Translations</a></code> page. That way, you will be able to customize both the singular (1 review) and plural (2 reviews) summary texts.</p> |
|
169 | 169 | <p>The default text value is: <code>"{rating} out of {max} stars (based on {num} reviews)"</code></p> |
170 | 170 | <pre><code>[site_reviews_summary text="{num} customer reviews"]</code></pre> |
171 | 171 | </div> |
@@ -1,15 +1,15 @@ discard block |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div id="faq-01" class="glsr-card postbox"> |
4 | 4 | <div class="glsr-card-header"> |
5 | 5 | <h3>How do I add additional values to the schema?</h3> |
6 | 6 | <button type="button" class="handlediv" aria-expanded="true"> |
7 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
7 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
8 | 8 | <span class="toggle-indicator" aria-hidden="true"></span> |
9 | 9 | </button> |
10 | 10 | </div> |
11 | 11 | <div class="inside"> |
12 | - <p>To add additional values to the generated schema, use the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-hooks'); ?>" data-expand="#hooks-07">site-reviews/schema/[SCHEMA_TYPE]</a></code> hook in your theme's functions.php file.</p> |
|
12 | + <p>To add additional values to the generated schema, use the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-hooks' ); ?>" data-expand="#hooks-07">site-reviews/schema/[SCHEMA_TYPE]</a></code> hook in your theme's functions.php file.</p> |
|
13 | 13 | <p>Make sure to use Google's <a href="https://search.google.com/structured-data/testing-tool">Structured Data Testing Tool</a> to test the schema after any custom modifications have been made.</p> |
14 | 14 | <pre><code class="php">/** |
15 | 15 | * Modifies the schema created by Site Reviews. |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | <div class="glsr-card-header"> |
35 | 35 | <h3>How do I add pagination to my reviews?</h3> |
36 | 36 | <button type="button" class="handlediv" aria-expanded="true"> |
37 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
37 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
38 | 38 | <span class="toggle-indicator" aria-hidden="true"></span> |
39 | 39 | </button> |
40 | 40 | </div> |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | <p>If you are using the shortcodes, then use the <code>pagination</code> and <code>count</code> options.</p> |
44 | 44 | <p>For example, this will paginate reviews to 10 reviews per-page:</p> |
45 | 45 | <pre><code class="php">[site_reviews pagination=ajax count=10]</code></pre> |
46 | - <p>To lean more about the available shortcode options and how to use them, please see the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes'); ?>">Documentation > Shortcodes</a></code> page.</p> |
|
46 | + <p>To lean more about the available shortcode options and how to use them, please see the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes' ); ?>">Documentation > Shortcodes</a></code> page.</p> |
|
47 | 47 | </div> |
48 | 48 | </div> |
49 | 49 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | <div class="glsr-card-header"> |
52 | 52 | <h3>How do I assign reviews to a page?</h3> |
53 | 53 | <button type="button" class="handlediv" aria-expanded="true"> |
54 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
54 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
55 | 55 | <span class="toggle-indicator" aria-hidden="true"></span> |
56 | 56 | </button> |
57 | 57 | </div> |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | <p>If you use <code>post_id</code> as the value, then Site Reviews will know to automatically use the Page ID of the current page.</p> |
70 | 70 | <p>If you use <code>parent_id</code> as the value, then Site Reviews will know to automatically use the Page ID of the current page's Parent.</p> |
71 | 71 | <p>You can, of course, also directly enter the numerical WordPress Page ID of the page instead if your prefer.</p> |
72 | - <p>To lean more about the available shortcode options and how to use them, please see the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes'); ?>">Documentation > Shortcodes</a></code> page.</p> |
|
72 | + <p>To lean more about the available shortcode options and how to use them, please see the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes' ); ?>">Documentation > Shortcodes</a></code> page.</p> |
|
73 | 73 | </div> |
74 | 74 | </div> |
75 | 75 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | <div class="glsr-card-header"> |
78 | 78 | <h3>How do I change the font?</h3> |
79 | 79 | <button type="button" class="handlediv" aria-expanded="true"> |
80 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
80 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
81 | 81 | <span class="toggle-indicator" aria-hidden="true"></span> |
82 | 82 | </button> |
83 | 83 | </div> |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | <div class="glsr-card-header"> |
94 | 94 | <h3>How do I change the order of the review fields?</h3> |
95 | 95 | <button type="button" class="handlediv" aria-expanded="true"> |
96 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
96 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
97 | 97 | <span class="toggle-indicator" aria-hidden="true"></span> |
98 | 98 | </button> |
99 | 99 | </div> |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | <div class="glsr-card-header"> |
122 | 122 | <h3>How do I change the order of the reviews summary fields?</h3> |
123 | 123 | <button type="button" class="handlediv" aria-expanded="true"> |
124 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
124 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
125 | 125 | <span class="toggle-indicator" aria-hidden="true"></span> |
126 | 126 | </button> |
127 | 127 | </div> |
@@ -147,12 +147,12 @@ discard block |
||
147 | 147 | <div class="glsr-card-header"> |
148 | 148 | <h3>How do I change the order of the submission form fields?</h3> |
149 | 149 | <button type="button" class="handlediv" aria-expanded="true"> |
150 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
150 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
151 | 151 | <span class="toggle-indicator" aria-hidden="true"></span> |
152 | 152 | </button> |
153 | 153 | </div> |
154 | 154 | <div class="inside"> |
155 | - <p>To customise the order of the fields in the review submission form, use the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-hooks'); ?>" data-expand="#hooks-01">site-reviews/submission-form/order</a></code> filter hook in your theme's <code>functions.php</code> file.</p> |
|
155 | + <p>To customise the order of the fields in the review submission form, use the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-hooks' ); ?>" data-expand="#hooks-01">site-reviews/submission-form/order</a></code> filter hook in your theme's <code>functions.php</code> file.</p> |
|
156 | 156 | <pre><code class="php">/** |
157 | 157 | * Customises the order of the fields used in the Site Reviews submission form. |
158 | 158 | * Paste this in your active theme's functions.php file. |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | 'terms', |
172 | 172 | ]; |
173 | 173 | });</code></pre> |
174 | - <p>If you have used the example above and the submission-form fields are not working correctly, check the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=tools#tab-console'); ?>">Tools → Console</a></code> for errors.</p> |
|
174 | + <p>If you have used the example above and the submission-form fields are not working correctly, check the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=tools#tab-console' ); ?>">Tools → Console</a></code> for errors.</p> |
|
175 | 175 | </div> |
176 | 176 | </div> |
177 | 177 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | <div class="glsr-card-header"> |
180 | 180 | <h3>How do I change the pagination query string?</h3> |
181 | 181 | <button type="button" class="handlediv" aria-expanded="true"> |
182 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
182 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
183 | 183 | <span class="toggle-indicator" aria-hidden="true"></span> |
184 | 184 | </button> |
185 | 185 | </div> |
@@ -201,12 +201,12 @@ discard block |
||
201 | 201 | <div class="glsr-card-header"> |
202 | 202 | <h3>How do I change the text of...?</h3> |
203 | 203 | <button type="button" class="handlediv" aria-expanded="true"> |
204 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
204 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
205 | 205 | <span class="toggle-indicator" aria-hidden="true"></span> |
206 | 206 | </button> |
207 | 207 | </div> |
208 | 208 | <div class="inside"> |
209 | - <p>You can change any text in the plugin on the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-translations'); ?>">Settings → Translations</a></code> page.</p> |
|
209 | + <p>You can change any text in the plugin on the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-translations' ); ?>">Settings → Translations</a></code> page.</p> |
|
210 | 210 | </div> |
211 | 211 | </div> |
212 | 212 | |
@@ -214,12 +214,12 @@ discard block |
||
214 | 214 | <div class="glsr-card-header"> |
215 | 215 | <h3>How do I create a review programmatically?</h3> |
216 | 216 | <button type="button" class="handlediv" aria-expanded="true"> |
217 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
217 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
218 | 218 | <span class="toggle-indicator" aria-hidden="true"></span> |
219 | 219 | </button> |
220 | 220 | </div> |
221 | 221 | <div class="inside"> |
222 | - <p>Site Reviews provides a <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-functions'); ?>" data-expand="#functions-02">glsr_create_review()</a></code> helper function to easily create a review.</p> |
|
222 | + <p>Site Reviews provides a <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-functions' ); ?>" data-expand="#functions-02">glsr_create_review()</a></code> helper function to easily create a review.</p> |
|
223 | 223 | <p>Here is an example:</p> |
224 | 224 | <pre><code class="php">if (function_exists('glsr_create_review')) { |
225 | 225 | $review = glsr_create_review([ |
@@ -239,12 +239,12 @@ discard block |
||
239 | 239 | <div class="glsr-card-header"> |
240 | 240 | <h3>How do I customise the stars?</h3> |
241 | 241 | <button type="button" class="handlediv" aria-expanded="true"> |
242 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
242 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
243 | 243 | <span class="toggle-indicator" aria-hidden="true"></span> |
244 | 244 | </button> |
245 | 245 | </div> |
246 | 246 | <div class="inside"> |
247 | - <p>To customise the star images used by the plugin, use the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-hooks'); ?>" data-expand="#hooks-02">site-reviews/config/inline-styles</a></code> filter hook in your theme's <code>functions.php</code> file.</p> |
|
247 | + <p>To customise the star images used by the plugin, use the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-hooks' ); ?>" data-expand="#hooks-02">site-reviews/config/inline-styles</a></code> filter hook in your theme's <code>functions.php</code> file.</p> |
|
248 | 248 | <p>Here is an example:</p> |
249 | 249 | <pre><code class="php">/** |
250 | 250 | * Customises the stars used by Site Reviews. |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | <li>Open the SVG images that you copied with a text editor</li> |
267 | 267 | <li>Change the <a target="_blank" href="https://www.hexcolortool.com">hex colour code</a> to the one you want</li> |
268 | 268 | <li>Install and activate the <a target="_blank" href="https://wordpress.org/plugins/safe-svg/">Safe SVG</a> plugin</li> |
269 | - <li>Upload the edited SVG images to your <a href="<?= admin_url('upload.php'); ?>">Media Library</a></li> |
|
269 | + <li>Upload the edited SVG images to your <a href="<?= admin_url( 'upload.php' ); ?>">Media Library</a></li> |
|
270 | 270 | <li>Copy the File URL of the uploaded SVG images and paste them into the snippet above</li> |
271 | 271 | </ol> |
272 | 272 | </div> |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | <div class="glsr-card-header"> |
277 | 277 | <h3>How do I hide the form after a review is submitted?</h3> |
278 | 278 | <button type="button" class="handlediv" aria-expanded="true"> |
279 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
279 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
280 | 280 | <span class="toggle-indicator" aria-hidden="true"></span> |
281 | 281 | </button> |
282 | 282 | </div> |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | });"; |
299 | 299 | });</code></pre> |
300 | 300 | <p>You can also hide the form from registered users who have already submitted a review.</p> |
301 | - <p>To do this, you will need to first make sure that the "Limit Reviews" setting on the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-submissions'); ?>">Settings → Submissions</a></code> page is set to "By Username". Once that is done, you can use the following code snippet:</p> |
|
301 | + <p>To do this, you will need to first make sure that the "Limit Reviews" setting on the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-submissions' ); ?>">Settings → Submissions</a></code> page is set to "By Username". Once that is done, you can use the following code snippet:</p> |
|
302 | 302 | <pre><code class="php">/** |
303 | 303 | * Hides the submission form from registered users who have already submitted a review |
304 | 304 | * Paste this in your active theme's functions.php file |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | <div class="glsr-card-header"> |
320 | 320 | <h3>How do I limit the submitted review length?</h3> |
321 | 321 | <button type="button" class="handlediv" aria-expanded="true"> |
322 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
322 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
323 | 323 | <span class="toggle-indicator" aria-hidden="true"></span> |
324 | 324 | </button> |
325 | 325 | </div> |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | <div class="glsr-card-header"> |
358 | 358 | <h3>How do I order pages with assigned reviews by rating or ranking?</h3> |
359 | 359 | <button type="button" class="handlediv" aria-expanded="true"> |
360 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
360 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
361 | 361 | <span class="toggle-indicator" aria-hidden="true"></span> |
362 | 362 | </button> |
363 | 363 | </div> |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | <div class="glsr-card-header"> |
414 | 414 | <h3>How do I prevent search engines from indexing paginated reviews?</h3> |
415 | 415 | <button type="button" class="handlediv" aria-expanded="true"> |
416 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
416 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
417 | 417 | <span class="toggle-indicator" aria-hidden="true"></span> |
418 | 418 | </button> |
419 | 419 | </div> |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | <p>Here is how to prevent search engines from indexing your paginated reviews:</p> |
423 | 423 | <ol> |
424 | 424 | <li>Install and activate the <a href="https://wordpress.org/plugins/robots-txt-editor/">Robots.txt Editor</a> plugin.</li> |
425 | - <li>Go to the <code><a href="<?= admin_url('options-reading.php'); ?>">WordPress > Settings > Reading</a></code> page.</li> |
|
425 | + <li>Go to the <code><a href="<?= admin_url( 'options-reading.php' ); ?>">WordPress > Settings > Reading</a></code> page.</li> |
|
426 | 426 | <li>Make sure that the Robots.txt starts with: <code>User-Agent: *</code></li> |
427 | 427 | <li>Add the following lines: |
428 | 428 | <pre><code>Disallow: /*?reviews-page=* |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | <div class="glsr-card-header"> |
444 | 444 | <h3>How do I redirect to a custom URL after a form is submitted?</h3> |
445 | 445 | <button type="button" class="handlediv" aria-expanded="true"> |
446 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
446 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
447 | 447 | <span class="toggle-indicator" aria-hidden="true"></span> |
448 | 448 | </button> |
449 | 449 | </div> |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | <div class="glsr-card-header"> |
457 | 457 | <h3>How do I remove the dash in front of the author's name?</h3> |
458 | 458 | <button type="button" class="handlediv" aria-expanded="true"> |
459 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
459 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
460 | 460 | <span class="toggle-indicator" aria-hidden="true"></span> |
461 | 461 | </button> |
462 | 462 | </div> |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | <div class="glsr-card-header"> |
473 | 473 | <h3>How do I use the plugin templates in my theme?</h3> |
474 | 474 | <button type="button" class="handlediv" aria-expanded="true"> |
475 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
475 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
476 | 476 | <span class="toggle-indicator" aria-hidden="true"></span> |
477 | 477 | </button> |
478 | 478 | </div> |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | <div class="glsr-card-header"> |
491 | 491 | <h3>Why are the IP Addresses not being detected correctly?</h3> |
492 | 492 | <button type="button" class="handlediv" aria-expanded="true"> |
493 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
493 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
494 | 494 | <span class="toggle-indicator" aria-hidden="true"></span> |
495 | 495 | </button> |
496 | 496 | </div> |
@@ -6,26 +6,26 @@ |
||
6 | 6 | <p><?= __('Add-ons extend the functionality of Site Reviews.', 'site-reviews'); ?></p> |
7 | 7 | <div class="glsr-addons wp-clearfix"> |
8 | 8 | <?php |
9 | - $template->render('partials/addons/addon', [ |
|
10 | - 'beta' => false, |
|
11 | - 'context' => [ |
|
12 | - 'description' => __('This add-on allows your site visitors to filter, search, and sort your reviews. Apply now to test the unreleased beta version.', 'site-reviews'), |
|
13 | - 'link' => 'https://niftyplugins.com/plugins/filters/', |
|
14 | - 'slug' => 'filters', |
|
15 | - 'title' => 'Filters', |
|
16 | - ], |
|
17 | - 'plugin' => 'site-reviews-filters/site-reviews-filters.php', |
|
18 | - ]); |
|
19 | - $template->render('partials/addons/addon', [ |
|
20 | - 'beta' => true, |
|
21 | - 'context' => [ |
|
22 | - 'description' => __('This add-on allows your site visitors to submit images with their reviews. Apply now to test the unreleased beta version.', 'site-reviews'), |
|
23 | - 'link' => 'https://niftyplugins.com/plugins/images/', |
|
24 | - 'slug' => 'images', |
|
25 | - 'title' => 'Images', |
|
26 | - ], |
|
27 | - 'plugin' => 'site-reviews-images/site-reviews-images.php', |
|
28 | - ]); |
|
29 | - ?> |
|
9 | + $template->render('partials/addons/addon', [ |
|
10 | + 'beta' => false, |
|
11 | + 'context' => [ |
|
12 | + 'description' => __('This add-on allows your site visitors to filter, search, and sort your reviews. Apply now to test the unreleased beta version.', 'site-reviews'), |
|
13 | + 'link' => 'https://niftyplugins.com/plugins/filters/', |
|
14 | + 'slug' => 'filters', |
|
15 | + 'title' => 'Filters', |
|
16 | + ], |
|
17 | + 'plugin' => 'site-reviews-filters/site-reviews-filters.php', |
|
18 | + ]); |
|
19 | + $template->render('partials/addons/addon', [ |
|
20 | + 'beta' => true, |
|
21 | + 'context' => [ |
|
22 | + 'description' => __('This add-on allows your site visitors to submit images with their reviews. Apply now to test the unreleased beta version.', 'site-reviews'), |
|
23 | + 'link' => 'https://niftyplugins.com/plugins/images/', |
|
24 | + 'slug' => 'images', |
|
25 | + 'title' => 'Images', |
|
26 | + ], |
|
27 | + 'plugin' => 'site-reviews-images/site-reviews-images.php', |
|
28 | + ]); |
|
29 | + ?> |
|
30 | 30 | </div> |
31 | 31 | </div> |
@@ -1,31 +1,31 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="wrap"> |
4 | - <h1 class="wp-heading-inline"><?= esc_html(get_admin_page_title()); ?></h1> |
|
4 | + <h1 class="wp-heading-inline"><?= esc_html( get_admin_page_title() ); ?></h1> |
|
5 | 5 | <?= $notices; ?> |
6 | - <p><?= __('Add-ons extend the functionality of Site Reviews.', 'site-reviews'); ?></p> |
|
6 | + <p><?= __( 'Add-ons extend the functionality of Site Reviews.', 'site-reviews' ); ?></p> |
|
7 | 7 | <div class="glsr-addons wp-clearfix"> |
8 | 8 | <?php |
9 | - $template->render('partials/addons/addon', [ |
|
9 | + $template->render( 'partials/addons/addon', [ |
|
10 | 10 | 'beta' => false, |
11 | 11 | 'context' => [ |
12 | - 'description' => __('This add-on allows your site visitors to filter, search, and sort your reviews. Apply now to test the unreleased beta version.', 'site-reviews'), |
|
12 | + 'description' => __( 'This add-on allows your site visitors to filter, search, and sort your reviews. Apply now to test the unreleased beta version.', 'site-reviews' ), |
|
13 | 13 | 'link' => 'https://niftyplugins.com/plugins/filters/', |
14 | 14 | 'slug' => 'filters', |
15 | 15 | 'title' => 'Filters', |
16 | 16 | ], |
17 | 17 | 'plugin' => 'site-reviews-filters/site-reviews-filters.php', |
18 | - ]); |
|
19 | - $template->render('partials/addons/addon', [ |
|
18 | + ] ); |
|
19 | + $template->render( 'partials/addons/addon', [ |
|
20 | 20 | 'beta' => true, |
21 | 21 | 'context' => [ |
22 | - 'description' => __('This add-on allows your site visitors to submit images with their reviews. Apply now to test the unreleased beta version.', 'site-reviews'), |
|
22 | + 'description' => __( 'This add-on allows your site visitors to submit images with their reviews. Apply now to test the unreleased beta version.', 'site-reviews' ), |
|
23 | 23 | 'link' => 'https://niftyplugins.com/plugins/images/', |
24 | 24 | 'slug' => 'images', |
25 | 25 | 'title' => 'Images', |
26 | 26 | ], |
27 | 27 | 'plugin' => 'site-reviews-images/site-reviews-images.php', |
28 | - ]); |
|
28 | + ] ); |
|
29 | 29 | ?> |
30 | 30 | </div> |
31 | 31 | </div> |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="et_contact_bottom_container"> |
4 | 4 | <button type="submit" class="glsr-button et_pb_contact_submit et_pb_button"> |
@@ -8,218 +8,218 @@ |
||
8 | 8 | |
9 | 9 | class Helper |
10 | 10 | { |
11 | - /** |
|
12 | - * @param string $name |
|
13 | - * @param string $path |
|
14 | - * @return string |
|
15 | - */ |
|
16 | - public static function buildClassName($name, $path = '') |
|
17 | - { |
|
18 | - $className = Str::camelCase($name); |
|
19 | - $path = ltrim(str_replace(__NAMESPACE__, '', $path), '\\'); |
|
20 | - return !empty($path) |
|
21 | - ? __NAMESPACE__.'\\'.$path.'\\'.$className |
|
22 | - : $className; |
|
23 | - } |
|
24 | - |
|
25 | - /** |
|
26 | - * @param string $name |
|
27 | - * @param string $prefix |
|
28 | - * @return string |
|
29 | - */ |
|
30 | - public static function buildMethodName($name, $prefix = '') |
|
31 | - { |
|
32 | - return lcfirst($prefix.static::buildClassName($name)); |
|
33 | - } |
|
34 | - |
|
35 | - /** |
|
36 | - * @param string $name |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - public static function buildPropertyName($name) |
|
40 | - { |
|
41 | - return static::buildMethodName($name); |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * @param string $cast |
|
46 | - * @param mixed $value |
|
47 | - * @return mixed |
|
48 | - */ |
|
49 | - public static function castTo($cast = '', $value) |
|
50 | - { |
|
51 | - $method = static::buildMethodName($cast, 'castTo'); |
|
52 | - return !empty($cast) && method_exists(__CLASS__, $method) |
|
53 | - ? static::$method($value) |
|
54 | - : $value; |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * @param mixed $value |
|
59 | - * @return array |
|
60 | - */ |
|
61 | - public static function castToArray($value) |
|
62 | - { |
|
63 | - return (array) $value; |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * @param mixed $value |
|
68 | - * @return bool |
|
69 | - */ |
|
70 | - public static function castToBool($value) |
|
71 | - { |
|
72 | - return filter_var($value, FILTER_VALIDATE_BOOLEAN); |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * @param mixed $value |
|
77 | - * @return float |
|
78 | - */ |
|
79 | - public static function castToFloat($value) |
|
80 | - { |
|
81 | - return (float) filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND); |
|
82 | - } |
|
83 | - |
|
84 | - /** |
|
85 | - * @param mixed $value |
|
86 | - * @return int |
|
87 | - */ |
|
88 | - public static function castToInt($value) |
|
89 | - { |
|
90 | - return (int) filter_var($value, FILTER_VALIDATE_INT); |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * @param mixed $value |
|
95 | - * @return object |
|
96 | - */ |
|
97 | - public static function castToObject($value) |
|
98 | - { |
|
99 | - return (object) (array) $value; |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * @param mixed $value |
|
104 | - * @return string |
|
105 | - */ |
|
106 | - public static function castToString($value) |
|
107 | - { |
|
108 | - if (is_object($value) && in_array('__toString', get_class_methods($value))) { |
|
109 | - return (string) $value->__toString(); |
|
110 | - } |
|
111 | - if (is_array($value) || is_object($value)) { |
|
112 | - return serialize($value); |
|
113 | - } |
|
114 | - return (string) $value; |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * @param string $key |
|
119 | - * @return mixed |
|
120 | - */ |
|
121 | - public static function filterInput($key, array $request = []) |
|
122 | - { |
|
123 | - if (isset($request[$key])) { |
|
124 | - return $request[$key]; |
|
125 | - } |
|
126 | - $variable = filter_input(INPUT_POST, $key); |
|
127 | - if (is_null($variable) && isset($_POST[$key])) { |
|
128 | - $variable = $_POST[$key]; |
|
129 | - } |
|
130 | - return $variable; |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * @param string $key |
|
135 | - * @return array |
|
136 | - */ |
|
137 | - public static function filterInputArray($key) |
|
138 | - { |
|
139 | - $variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); |
|
140 | - if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) { |
|
141 | - $variable = $_POST[$key]; |
|
142 | - } |
|
143 | - return (array) $variable; |
|
144 | - } |
|
145 | - |
|
146 | - /** |
|
147 | - * @return string |
|
148 | - */ |
|
149 | - public static function getIpAddress() |
|
150 | - { |
|
151 | - $whitelist = []; |
|
152 | - $isUsingCloudflare = !empty(filter_input(INPUT_SERVER, 'CF-Connecting-IP')); |
|
153 | - if (apply_filters('site-reviews/whip/whitelist/cloudflare', $isUsingCloudflare)) { |
|
154 | - $cloudflareIps = glsr(Cache::class)->getCloudflareIps(); |
|
155 | - $whitelist[Whip::CLOUDFLARE_HEADERS] = [Whip::IPV4 => $cloudflareIps['v4']]; |
|
156 | - if (defined('AF_INET6')) { |
|
157 | - $whitelist[Whip::CLOUDFLARE_HEADERS][Whip::IPV6] = $cloudflareIps['v6']; |
|
158 | - } |
|
159 | - } |
|
160 | - $whitelist = apply_filters('site-reviews/whip/whitelist', $whitelist); |
|
161 | - $methods = apply_filters('site-reviews/whip/methods', Whip::ALL_METHODS); |
|
162 | - $whip = new Whip($methods, $whitelist); |
|
163 | - do_action_ref_array('site-reviews/whip', [$whip]); |
|
164 | - if (false !== ($clientAddress = $whip->getValidIpAddress())) { |
|
165 | - return (string) $clientAddress; |
|
166 | - } |
|
167 | - glsr_log()->error('Unable to detect IP address, please see the FAQ page for a possible solution.'); |
|
168 | - return 'unknown'; |
|
169 | - } |
|
170 | - |
|
171 | - /** |
|
172 | - * @param mixed $value |
|
173 | - * @param string|int $min |
|
174 | - * @param string|int $max |
|
175 | - * @return bool |
|
176 | - */ |
|
177 | - public static function inRange($value, $min, $max) |
|
178 | - { |
|
179 | - $inRange = filter_var($value, FILTER_VALIDATE_INT, ['options' => [ |
|
180 | - 'min_range' => intval($min), |
|
181 | - 'max_range' => intval($max), |
|
182 | - ]]); |
|
183 | - return false !== $inRange; |
|
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * @param int|string $value |
|
188 | - * @param int|string $compareWithValue |
|
189 | - * @return bool |
|
190 | - */ |
|
191 | - public static function isGreaterThan($value, $compareWithValue) |
|
192 | - { |
|
193 | - return version_compare($value, $compareWithValue, '>'); |
|
194 | - } |
|
195 | - |
|
196 | - /** |
|
197 | - * @param int|string $value |
|
198 | - * @param int|string $compareWithValue |
|
199 | - * @return bool |
|
200 | - */ |
|
201 | - public static function isGreaterThanOrEqual($value, $compareWithValue) |
|
202 | - { |
|
203 | - return version_compare($value, $compareWithValue, '>='); |
|
204 | - } |
|
205 | - |
|
206 | - /** |
|
207 | - * @param int|string $value |
|
208 | - * @param int|string $compareWithValue |
|
209 | - * @return bool |
|
210 | - */ |
|
211 | - public static function isLessThan($value, $compareWithValue) |
|
212 | - { |
|
213 | - return version_compare($value, $compareWithValue, '<'); |
|
214 | - } |
|
215 | - |
|
216 | - /** |
|
217 | - * @param int|string $value |
|
218 | - * @param int|string $compareWithValue |
|
219 | - * @return bool |
|
220 | - */ |
|
221 | - public static function isLessThanOrEqual($value, $compareWithValue) |
|
222 | - { |
|
223 | - return version_compare($value, $compareWithValue, '<='); |
|
224 | - } |
|
11 | + /** |
|
12 | + * @param string $name |
|
13 | + * @param string $path |
|
14 | + * @return string |
|
15 | + */ |
|
16 | + public static function buildClassName($name, $path = '') |
|
17 | + { |
|
18 | + $className = Str::camelCase($name); |
|
19 | + $path = ltrim(str_replace(__NAMESPACE__, '', $path), '\\'); |
|
20 | + return !empty($path) |
|
21 | + ? __NAMESPACE__.'\\'.$path.'\\'.$className |
|
22 | + : $className; |
|
23 | + } |
|
24 | + |
|
25 | + /** |
|
26 | + * @param string $name |
|
27 | + * @param string $prefix |
|
28 | + * @return string |
|
29 | + */ |
|
30 | + public static function buildMethodName($name, $prefix = '') |
|
31 | + { |
|
32 | + return lcfirst($prefix.static::buildClassName($name)); |
|
33 | + } |
|
34 | + |
|
35 | + /** |
|
36 | + * @param string $name |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + public static function buildPropertyName($name) |
|
40 | + { |
|
41 | + return static::buildMethodName($name); |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * @param string $cast |
|
46 | + * @param mixed $value |
|
47 | + * @return mixed |
|
48 | + */ |
|
49 | + public static function castTo($cast = '', $value) |
|
50 | + { |
|
51 | + $method = static::buildMethodName($cast, 'castTo'); |
|
52 | + return !empty($cast) && method_exists(__CLASS__, $method) |
|
53 | + ? static::$method($value) |
|
54 | + : $value; |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * @param mixed $value |
|
59 | + * @return array |
|
60 | + */ |
|
61 | + public static function castToArray($value) |
|
62 | + { |
|
63 | + return (array) $value; |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * @param mixed $value |
|
68 | + * @return bool |
|
69 | + */ |
|
70 | + public static function castToBool($value) |
|
71 | + { |
|
72 | + return filter_var($value, FILTER_VALIDATE_BOOLEAN); |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * @param mixed $value |
|
77 | + * @return float |
|
78 | + */ |
|
79 | + public static function castToFloat($value) |
|
80 | + { |
|
81 | + return (float) filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND); |
|
82 | + } |
|
83 | + |
|
84 | + /** |
|
85 | + * @param mixed $value |
|
86 | + * @return int |
|
87 | + */ |
|
88 | + public static function castToInt($value) |
|
89 | + { |
|
90 | + return (int) filter_var($value, FILTER_VALIDATE_INT); |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * @param mixed $value |
|
95 | + * @return object |
|
96 | + */ |
|
97 | + public static function castToObject($value) |
|
98 | + { |
|
99 | + return (object) (array) $value; |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * @param mixed $value |
|
104 | + * @return string |
|
105 | + */ |
|
106 | + public static function castToString($value) |
|
107 | + { |
|
108 | + if (is_object($value) && in_array('__toString', get_class_methods($value))) { |
|
109 | + return (string) $value->__toString(); |
|
110 | + } |
|
111 | + if (is_array($value) || is_object($value)) { |
|
112 | + return serialize($value); |
|
113 | + } |
|
114 | + return (string) $value; |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * @param string $key |
|
119 | + * @return mixed |
|
120 | + */ |
|
121 | + public static function filterInput($key, array $request = []) |
|
122 | + { |
|
123 | + if (isset($request[$key])) { |
|
124 | + return $request[$key]; |
|
125 | + } |
|
126 | + $variable = filter_input(INPUT_POST, $key); |
|
127 | + if (is_null($variable) && isset($_POST[$key])) { |
|
128 | + $variable = $_POST[$key]; |
|
129 | + } |
|
130 | + return $variable; |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * @param string $key |
|
135 | + * @return array |
|
136 | + */ |
|
137 | + public static function filterInputArray($key) |
|
138 | + { |
|
139 | + $variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); |
|
140 | + if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) { |
|
141 | + $variable = $_POST[$key]; |
|
142 | + } |
|
143 | + return (array) $variable; |
|
144 | + } |
|
145 | + |
|
146 | + /** |
|
147 | + * @return string |
|
148 | + */ |
|
149 | + public static function getIpAddress() |
|
150 | + { |
|
151 | + $whitelist = []; |
|
152 | + $isUsingCloudflare = !empty(filter_input(INPUT_SERVER, 'CF-Connecting-IP')); |
|
153 | + if (apply_filters('site-reviews/whip/whitelist/cloudflare', $isUsingCloudflare)) { |
|
154 | + $cloudflareIps = glsr(Cache::class)->getCloudflareIps(); |
|
155 | + $whitelist[Whip::CLOUDFLARE_HEADERS] = [Whip::IPV4 => $cloudflareIps['v4']]; |
|
156 | + if (defined('AF_INET6')) { |
|
157 | + $whitelist[Whip::CLOUDFLARE_HEADERS][Whip::IPV6] = $cloudflareIps['v6']; |
|
158 | + } |
|
159 | + } |
|
160 | + $whitelist = apply_filters('site-reviews/whip/whitelist', $whitelist); |
|
161 | + $methods = apply_filters('site-reviews/whip/methods', Whip::ALL_METHODS); |
|
162 | + $whip = new Whip($methods, $whitelist); |
|
163 | + do_action_ref_array('site-reviews/whip', [$whip]); |
|
164 | + if (false !== ($clientAddress = $whip->getValidIpAddress())) { |
|
165 | + return (string) $clientAddress; |
|
166 | + } |
|
167 | + glsr_log()->error('Unable to detect IP address, please see the FAQ page for a possible solution.'); |
|
168 | + return 'unknown'; |
|
169 | + } |
|
170 | + |
|
171 | + /** |
|
172 | + * @param mixed $value |
|
173 | + * @param string|int $min |
|
174 | + * @param string|int $max |
|
175 | + * @return bool |
|
176 | + */ |
|
177 | + public static function inRange($value, $min, $max) |
|
178 | + { |
|
179 | + $inRange = filter_var($value, FILTER_VALIDATE_INT, ['options' => [ |
|
180 | + 'min_range' => intval($min), |
|
181 | + 'max_range' => intval($max), |
|
182 | + ]]); |
|
183 | + return false !== $inRange; |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * @param int|string $value |
|
188 | + * @param int|string $compareWithValue |
|
189 | + * @return bool |
|
190 | + */ |
|
191 | + public static function isGreaterThan($value, $compareWithValue) |
|
192 | + { |
|
193 | + return version_compare($value, $compareWithValue, '>'); |
|
194 | + } |
|
195 | + |
|
196 | + /** |
|
197 | + * @param int|string $value |
|
198 | + * @param int|string $compareWithValue |
|
199 | + * @return bool |
|
200 | + */ |
|
201 | + public static function isGreaterThanOrEqual($value, $compareWithValue) |
|
202 | + { |
|
203 | + return version_compare($value, $compareWithValue, '>='); |
|
204 | + } |
|
205 | + |
|
206 | + /** |
|
207 | + * @param int|string $value |
|
208 | + * @param int|string $compareWithValue |
|
209 | + * @return bool |
|
210 | + */ |
|
211 | + public static function isLessThan($value, $compareWithValue) |
|
212 | + { |
|
213 | + return version_compare($value, $compareWithValue, '<'); |
|
214 | + } |
|
215 | + |
|
216 | + /** |
|
217 | + * @param int|string $value |
|
218 | + * @param int|string $compareWithValue |
|
219 | + * @return bool |
|
220 | + */ |
|
221 | + public static function isLessThanOrEqual($value, $compareWithValue) |
|
222 | + { |
|
223 | + return version_compare($value, $compareWithValue, '<='); |
|
224 | + } |
|
225 | 225 | } |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | * @param string $path |
14 | 14 | * @return string |
15 | 15 | */ |
16 | - public static function buildClassName($name, $path = '') |
|
16 | + public static function buildClassName( $name, $path = '' ) |
|
17 | 17 | { |
18 | - $className = Str::camelCase($name); |
|
19 | - $path = ltrim(str_replace(__NAMESPACE__, '', $path), '\\'); |
|
18 | + $className = Str::camelCase( $name ); |
|
19 | + $path = ltrim( str_replace( __NAMESPACE__, '', $path ), '\\' ); |
|
20 | 20 | return !empty($path) |
21 | 21 | ? __NAMESPACE__.'\\'.$path.'\\'.$className |
22 | 22 | : $className; |
@@ -27,18 +27,18 @@ discard block |
||
27 | 27 | * @param string $prefix |
28 | 28 | * @return string |
29 | 29 | */ |
30 | - public static function buildMethodName($name, $prefix = '') |
|
30 | + public static function buildMethodName( $name, $prefix = '' ) |
|
31 | 31 | { |
32 | - return lcfirst($prefix.static::buildClassName($name)); |
|
32 | + return lcfirst( $prefix.static::buildClassName( $name ) ); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
36 | 36 | * @param string $name |
37 | 37 | * @return string |
38 | 38 | */ |
39 | - public static function buildPropertyName($name) |
|
39 | + public static function buildPropertyName( $name ) |
|
40 | 40 | { |
41 | - return static::buildMethodName($name); |
|
41 | + return static::buildMethodName( $name ); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | * @param mixed $value |
47 | 47 | * @return mixed |
48 | 48 | */ |
49 | - public static function castTo($cast = '', $value) |
|
49 | + public static function castTo( $cast = '', $value ) |
|
50 | 50 | { |
51 | - $method = static::buildMethodName($cast, 'castTo'); |
|
52 | - return !empty($cast) && method_exists(__CLASS__, $method) |
|
53 | - ? static::$method($value) |
|
51 | + $method = static::buildMethodName( $cast, 'castTo' ); |
|
52 | + return !empty($cast) && method_exists( __CLASS__, $method ) |
|
53 | + ? static::$method( $value ) |
|
54 | 54 | : $value; |
55 | 55 | } |
56 | 56 | |
@@ -58,73 +58,73 @@ discard block |
||
58 | 58 | * @param mixed $value |
59 | 59 | * @return array |
60 | 60 | */ |
61 | - public static function castToArray($value) |
|
61 | + public static function castToArray( $value ) |
|
62 | 62 | { |
63 | - return (array) $value; |
|
63 | + return (array)$value; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | 67 | * @param mixed $value |
68 | 68 | * @return bool |
69 | 69 | */ |
70 | - public static function castToBool($value) |
|
70 | + public static function castToBool( $value ) |
|
71 | 71 | { |
72 | - return filter_var($value, FILTER_VALIDATE_BOOLEAN); |
|
72 | + return filter_var( $value, FILTER_VALIDATE_BOOLEAN ); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
76 | 76 | * @param mixed $value |
77 | 77 | * @return float |
78 | 78 | */ |
79 | - public static function castToFloat($value) |
|
79 | + public static function castToFloat( $value ) |
|
80 | 80 | { |
81 | - return (float) filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND); |
|
81 | + return (float)filter_var( $value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND ); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
85 | 85 | * @param mixed $value |
86 | 86 | * @return int |
87 | 87 | */ |
88 | - public static function castToInt($value) |
|
88 | + public static function castToInt( $value ) |
|
89 | 89 | { |
90 | - return (int) filter_var($value, FILTER_VALIDATE_INT); |
|
90 | + return (int)filter_var( $value, FILTER_VALIDATE_INT ); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
94 | 94 | * @param mixed $value |
95 | 95 | * @return object |
96 | 96 | */ |
97 | - public static function castToObject($value) |
|
97 | + public static function castToObject( $value ) |
|
98 | 98 | { |
99 | - return (object) (array) $value; |
|
99 | + return (object)(array)$value; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
103 | 103 | * @param mixed $value |
104 | 104 | * @return string |
105 | 105 | */ |
106 | - public static function castToString($value) |
|
106 | + public static function castToString( $value ) |
|
107 | 107 | { |
108 | - if (is_object($value) && in_array('__toString', get_class_methods($value))) { |
|
109 | - return (string) $value->__toString(); |
|
108 | + if( is_object( $value ) && in_array( '__toString', get_class_methods( $value ) ) ) { |
|
109 | + return (string)$value->__toString(); |
|
110 | 110 | } |
111 | - if (is_array($value) || is_object($value)) { |
|
112 | - return serialize($value); |
|
111 | + if( is_array( $value ) || is_object( $value ) ) { |
|
112 | + return serialize( $value ); |
|
113 | 113 | } |
114 | - return (string) $value; |
|
114 | + return (string)$value; |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
118 | 118 | * @param string $key |
119 | 119 | * @return mixed |
120 | 120 | */ |
121 | - public static function filterInput($key, array $request = []) |
|
121 | + public static function filterInput( $key, array $request = [] ) |
|
122 | 122 | { |
123 | - if (isset($request[$key])) { |
|
123 | + if( isset($request[$key]) ) { |
|
124 | 124 | return $request[$key]; |
125 | 125 | } |
126 | - $variable = filter_input(INPUT_POST, $key); |
|
127 | - if (is_null($variable) && isset($_POST[$key])) { |
|
126 | + $variable = filter_input( INPUT_POST, $key ); |
|
127 | + if( is_null( $variable ) && isset($_POST[$key]) ) { |
|
128 | 128 | $variable = $_POST[$key]; |
129 | 129 | } |
130 | 130 | return $variable; |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | * @param string $key |
135 | 135 | * @return array |
136 | 136 | */ |
137 | - public static function filterInputArray($key) |
|
137 | + public static function filterInputArray( $key ) |
|
138 | 138 | { |
139 | - $variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); |
|
140 | - if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) { |
|
139 | + $variable = filter_input( INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
|
140 | + if( empty($variable) && !empty($_POST[$key]) && is_array( $_POST[$key] ) ) { |
|
141 | 141 | $variable = $_POST[$key]; |
142 | 142 | } |
143 | - return (array) $variable; |
|
143 | + return (array)$variable; |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -149,22 +149,22 @@ discard block |
||
149 | 149 | public static function getIpAddress() |
150 | 150 | { |
151 | 151 | $whitelist = []; |
152 | - $isUsingCloudflare = !empty(filter_input(INPUT_SERVER, 'CF-Connecting-IP')); |
|
153 | - if (apply_filters('site-reviews/whip/whitelist/cloudflare', $isUsingCloudflare)) { |
|
154 | - $cloudflareIps = glsr(Cache::class)->getCloudflareIps(); |
|
152 | + $isUsingCloudflare = !empty(filter_input( INPUT_SERVER, 'CF-Connecting-IP' )); |
|
153 | + if( apply_filters( 'site-reviews/whip/whitelist/cloudflare', $isUsingCloudflare ) ) { |
|
154 | + $cloudflareIps = glsr( Cache::class )->getCloudflareIps(); |
|
155 | 155 | $whitelist[Whip::CLOUDFLARE_HEADERS] = [Whip::IPV4 => $cloudflareIps['v4']]; |
156 | - if (defined('AF_INET6')) { |
|
156 | + if( defined( 'AF_INET6' ) ) { |
|
157 | 157 | $whitelist[Whip::CLOUDFLARE_HEADERS][Whip::IPV6] = $cloudflareIps['v6']; |
158 | 158 | } |
159 | 159 | } |
160 | - $whitelist = apply_filters('site-reviews/whip/whitelist', $whitelist); |
|
161 | - $methods = apply_filters('site-reviews/whip/methods', Whip::ALL_METHODS); |
|
162 | - $whip = new Whip($methods, $whitelist); |
|
163 | - do_action_ref_array('site-reviews/whip', [$whip]); |
|
164 | - if (false !== ($clientAddress = $whip->getValidIpAddress())) { |
|
165 | - return (string) $clientAddress; |
|
160 | + $whitelist = apply_filters( 'site-reviews/whip/whitelist', $whitelist ); |
|
161 | + $methods = apply_filters( 'site-reviews/whip/methods', Whip::ALL_METHODS ); |
|
162 | + $whip = new Whip( $methods, $whitelist ); |
|
163 | + do_action_ref_array( 'site-reviews/whip', [$whip] ); |
|
164 | + if( false !== ($clientAddress = $whip->getValidIpAddress()) ) { |
|
165 | + return (string)$clientAddress; |
|
166 | 166 | } |
167 | - glsr_log()->error('Unable to detect IP address, please see the FAQ page for a possible solution.'); |
|
167 | + glsr_log()->error( 'Unable to detect IP address, please see the FAQ page for a possible solution.' ); |
|
168 | 168 | return 'unknown'; |
169 | 169 | } |
170 | 170 | |
@@ -174,12 +174,12 @@ discard block |
||
174 | 174 | * @param string|int $max |
175 | 175 | * @return bool |
176 | 176 | */ |
177 | - public static function inRange($value, $min, $max) |
|
177 | + public static function inRange( $value, $min, $max ) |
|
178 | 178 | { |
179 | - $inRange = filter_var($value, FILTER_VALIDATE_INT, ['options' => [ |
|
180 | - 'min_range' => intval($min), |
|
181 | - 'max_range' => intval($max), |
|
182 | - ]]); |
|
179 | + $inRange = filter_var( $value, FILTER_VALIDATE_INT, ['options' => [ |
|
180 | + 'min_range' => intval( $min ), |
|
181 | + 'max_range' => intval( $max ), |
|
182 | + ]] ); |
|
183 | 183 | return false !== $inRange; |
184 | 184 | } |
185 | 185 | |
@@ -188,9 +188,9 @@ discard block |
||
188 | 188 | * @param int|string $compareWithValue |
189 | 189 | * @return bool |
190 | 190 | */ |
191 | - public static function isGreaterThan($value, $compareWithValue) |
|
191 | + public static function isGreaterThan( $value, $compareWithValue ) |
|
192 | 192 | { |
193 | - return version_compare($value, $compareWithValue, '>'); |
|
193 | + return version_compare( $value, $compareWithValue, '>' ); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -198,9 +198,9 @@ discard block |
||
198 | 198 | * @param int|string $compareWithValue |
199 | 199 | * @return bool |
200 | 200 | */ |
201 | - public static function isGreaterThanOrEqual($value, $compareWithValue) |
|
201 | + public static function isGreaterThanOrEqual( $value, $compareWithValue ) |
|
202 | 202 | { |
203 | - return version_compare($value, $compareWithValue, '>='); |
|
203 | + return version_compare( $value, $compareWithValue, '>=' ); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -208,9 +208,9 @@ discard block |
||
208 | 208 | * @param int|string $compareWithValue |
209 | 209 | * @return bool |
210 | 210 | */ |
211 | - public static function isLessThan($value, $compareWithValue) |
|
211 | + public static function isLessThan( $value, $compareWithValue ) |
|
212 | 212 | { |
213 | - return version_compare($value, $compareWithValue, '<'); |
|
213 | + return version_compare( $value, $compareWithValue, '<' ); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | * @param int|string $compareWithValue |
219 | 219 | * @return bool |
220 | 220 | */ |
221 | - public static function isLessThanOrEqual($value, $compareWithValue) |
|
221 | + public static function isLessThanOrEqual( $value, $compareWithValue ) |
|
222 | 222 | { |
223 | - return version_compare($value, $compareWithValue, '<='); |
|
223 | + return version_compare( $value, $compareWithValue, '<=' ); |
|
224 | 224 | } |
225 | 225 | } |
@@ -13,294 +13,294 @@ |
||
13 | 13 | |
14 | 14 | class SiteReviewsForm implements PartialContract |
15 | 15 | { |
16 | - /** |
|
17 | - * @var array |
|
18 | - */ |
|
19 | - protected $args; |
|
16 | + /** |
|
17 | + * @var array |
|
18 | + */ |
|
19 | + protected $args; |
|
20 | 20 | |
21 | - /** |
|
22 | - * @var array |
|
23 | - */ |
|
24 | - protected $errors; |
|
21 | + /** |
|
22 | + * @var array |
|
23 | + */ |
|
24 | + protected $errors; |
|
25 | 25 | |
26 | - /** |
|
27 | - * @var string |
|
28 | - */ |
|
29 | - protected $message; |
|
26 | + /** |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + protected $message; |
|
30 | 30 | |
31 | - /** |
|
32 | - * @var array |
|
33 | - */ |
|
34 | - protected $required; |
|
31 | + /** |
|
32 | + * @var array |
|
33 | + */ |
|
34 | + protected $required; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @var array |
|
38 | - */ |
|
39 | - protected $values; |
|
36 | + /** |
|
37 | + * @var array |
|
38 | + */ |
|
39 | + protected $values; |
|
40 | 40 | |
41 | - /** |
|
42 | - * {@inheritdoc} |
|
43 | - */ |
|
44 | - public function build(array $args = []) |
|
45 | - { |
|
46 | - $this->args = $args; |
|
47 | - if (!is_user_logged_in() && glsr(OptionManager::class)->getBool('settings.general.require.login')) { |
|
48 | - return $this->buildLoginRegister(); |
|
49 | - } |
|
50 | - $this->errors = glsr()->sessionGet($args['id'].'errors', []); |
|
51 | - $this->message = glsr()->sessionGet($args['id'].'message', ''); |
|
52 | - $this->required = glsr(OptionManager::class)->get('settings.submissions.required', []); |
|
53 | - $this->values = glsr()->sessionGet($args['id'].'values', []); |
|
54 | - $fields = array_reduce($this->getFields(), function ($carry, $field) { |
|
55 | - return $carry.$field; |
|
56 | - }); |
|
57 | - return glsr(Template::class)->build('templates/reviews-form', [ |
|
58 | - 'args' => $args, |
|
59 | - 'context' => [ |
|
60 | - 'class' => $this->getClass(), |
|
61 | - 'fields' => $fields, |
|
62 | - 'id' => $this->args['id'], |
|
63 | - 'response' => $this->buildResponse(), |
|
64 | - 'submit_button' => $this->buildSubmitButton().$this->buildRecaptcha(), |
|
65 | - ], |
|
66 | - ]); |
|
67 | - } |
|
41 | + /** |
|
42 | + * {@inheritdoc} |
|
43 | + */ |
|
44 | + public function build(array $args = []) |
|
45 | + { |
|
46 | + $this->args = $args; |
|
47 | + if (!is_user_logged_in() && glsr(OptionManager::class)->getBool('settings.general.require.login')) { |
|
48 | + return $this->buildLoginRegister(); |
|
49 | + } |
|
50 | + $this->errors = glsr()->sessionGet($args['id'].'errors', []); |
|
51 | + $this->message = glsr()->sessionGet($args['id'].'message', ''); |
|
52 | + $this->required = glsr(OptionManager::class)->get('settings.submissions.required', []); |
|
53 | + $this->values = glsr()->sessionGet($args['id'].'values', []); |
|
54 | + $fields = array_reduce($this->getFields(), function ($carry, $field) { |
|
55 | + return $carry.$field; |
|
56 | + }); |
|
57 | + return glsr(Template::class)->build('templates/reviews-form', [ |
|
58 | + 'args' => $args, |
|
59 | + 'context' => [ |
|
60 | + 'class' => $this->getClass(), |
|
61 | + 'fields' => $fields, |
|
62 | + 'id' => $this->args['id'], |
|
63 | + 'response' => $this->buildResponse(), |
|
64 | + 'submit_button' => $this->buildSubmitButton().$this->buildRecaptcha(), |
|
65 | + ], |
|
66 | + ]); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @return string |
|
71 | - */ |
|
72 | - protected function buildLoginRegister() |
|
73 | - { |
|
74 | - return glsr(Template::class)->build('templates/login-register', [ |
|
75 | - 'context' => [ |
|
76 | - 'text' => trim($this->getLoginText().' '.$this->getRegisterText()), |
|
77 | - ], |
|
78 | - ]); |
|
79 | - } |
|
69 | + /** |
|
70 | + * @return string |
|
71 | + */ |
|
72 | + protected function buildLoginRegister() |
|
73 | + { |
|
74 | + return glsr(Template::class)->build('templates/login-register', [ |
|
75 | + 'context' => [ |
|
76 | + 'text' => trim($this->getLoginText().' '.$this->getRegisterText()), |
|
77 | + ], |
|
78 | + ]); |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * @return void|string |
|
83 | - */ |
|
84 | - protected function buildRecaptcha() |
|
85 | - { |
|
86 | - if (!glsr(OptionManager::class)->isRecaptchaEnabled()) { |
|
87 | - return; |
|
88 | - } |
|
89 | - return glsr(Builder::class)->div([ |
|
90 | - 'class' => 'glsr-recaptcha-holder', |
|
91 | - 'data-badge' => glsr(OptionManager::class)->get('settings.submissions.recaptcha.position'), |
|
92 | - 'data-sitekey' => sanitize_text_field(glsr(OptionManager::class)->get('settings.submissions.recaptcha.key')), |
|
93 | - 'data-size' => 'invisible', |
|
94 | - ]); |
|
95 | - } |
|
81 | + /** |
|
82 | + * @return void|string |
|
83 | + */ |
|
84 | + protected function buildRecaptcha() |
|
85 | + { |
|
86 | + if (!glsr(OptionManager::class)->isRecaptchaEnabled()) { |
|
87 | + return; |
|
88 | + } |
|
89 | + return glsr(Builder::class)->div([ |
|
90 | + 'class' => 'glsr-recaptcha-holder', |
|
91 | + 'data-badge' => glsr(OptionManager::class)->get('settings.submissions.recaptcha.position'), |
|
92 | + 'data-sitekey' => sanitize_text_field(glsr(OptionManager::class)->get('settings.submissions.recaptcha.key')), |
|
93 | + 'data-size' => 'invisible', |
|
94 | + ]); |
|
95 | + } |
|
96 | 96 | |
97 | - /** |
|
98 | - * @return string |
|
99 | - */ |
|
100 | - protected function buildResponse() |
|
101 | - { |
|
102 | - $classes = !empty($this->errors) |
|
103 | - ? glsr(StyleValidationDefaults::class)->defaults()['message_error_class'] |
|
104 | - : ''; |
|
105 | - return glsr(Template::class)->build('templates/form/response', [ |
|
106 | - 'context' => [ |
|
107 | - 'class' => $classes, |
|
108 | - 'message' => wpautop($this->message), |
|
109 | - ], |
|
110 | - 'has_errors' => !empty($this->errors), |
|
111 | - ]); |
|
112 | - } |
|
97 | + /** |
|
98 | + * @return string |
|
99 | + */ |
|
100 | + protected function buildResponse() |
|
101 | + { |
|
102 | + $classes = !empty($this->errors) |
|
103 | + ? glsr(StyleValidationDefaults::class)->defaults()['message_error_class'] |
|
104 | + : ''; |
|
105 | + return glsr(Template::class)->build('templates/form/response', [ |
|
106 | + 'context' => [ |
|
107 | + 'class' => $classes, |
|
108 | + 'message' => wpautop($this->message), |
|
109 | + ], |
|
110 | + 'has_errors' => !empty($this->errors), |
|
111 | + ]); |
|
112 | + } |
|
113 | 113 | |
114 | - /** |
|
115 | - * @return string |
|
116 | - */ |
|
117 | - protected function buildSubmitButton() |
|
118 | - { |
|
119 | - return glsr(Template::class)->build('templates/form/submit-button', [ |
|
120 | - 'context' => [ |
|
121 | - 'text' => __('Submit your review', 'site-reviews'), |
|
122 | - ], |
|
123 | - ]); |
|
124 | - } |
|
114 | + /** |
|
115 | + * @return string |
|
116 | + */ |
|
117 | + protected function buildSubmitButton() |
|
118 | + { |
|
119 | + return glsr(Template::class)->build('templates/form/submit-button', [ |
|
120 | + 'context' => [ |
|
121 | + 'text' => __('Submit your review', 'site-reviews'), |
|
122 | + ], |
|
123 | + ]); |
|
124 | + } |
|
125 | 125 | |
126 | - /** |
|
127 | - * @return string |
|
128 | - */ |
|
129 | - protected function getClass() |
|
130 | - { |
|
131 | - return trim('glsr-form '.$this->args['class']); |
|
132 | - } |
|
126 | + /** |
|
127 | + * @return string |
|
128 | + */ |
|
129 | + protected function getClass() |
|
130 | + { |
|
131 | + return trim('glsr-form '.$this->args['class']); |
|
132 | + } |
|
133 | 133 | |
134 | - /** |
|
135 | - * @return array |
|
136 | - */ |
|
137 | - protected function getFields() |
|
138 | - { |
|
139 | - $hiddenFields = $this->getHiddenFields(); |
|
140 | - $hiddenFields[] = $this->getHoneypotField(); |
|
141 | - $fields = $this->normalizeFields(glsr(Form::class)->getFields('submission-form')); |
|
142 | - $paths = array_map(function ($obj) { |
|
143 | - return $obj->field['path']; |
|
144 | - }, $hiddenFields); |
|
145 | - foreach ($fields as $field) { |
|
146 | - $index = array_search($field->field['path'], $paths); |
|
147 | - if (false === $index) { |
|
148 | - continue; |
|
149 | - } |
|
150 | - unset($hiddenFields[$index]); |
|
151 | - } |
|
152 | - return array_merge($hiddenFields, $fields); |
|
153 | - } |
|
134 | + /** |
|
135 | + * @return array |
|
136 | + */ |
|
137 | + protected function getFields() |
|
138 | + { |
|
139 | + $hiddenFields = $this->getHiddenFields(); |
|
140 | + $hiddenFields[] = $this->getHoneypotField(); |
|
141 | + $fields = $this->normalizeFields(glsr(Form::class)->getFields('submission-form')); |
|
142 | + $paths = array_map(function ($obj) { |
|
143 | + return $obj->field['path']; |
|
144 | + }, $hiddenFields); |
|
145 | + foreach ($fields as $field) { |
|
146 | + $index = array_search($field->field['path'], $paths); |
|
147 | + if (false === $index) { |
|
148 | + continue; |
|
149 | + } |
|
150 | + unset($hiddenFields[$index]); |
|
151 | + } |
|
152 | + return array_merge($hiddenFields, $fields); |
|
153 | + } |
|
154 | 154 | |
155 | - /** |
|
156 | - * @return string |
|
157 | - */ |
|
158 | - protected function getLoginText() |
|
159 | - { |
|
160 | - $loginLink = glsr(Builder::class)->a([ |
|
161 | - 'href' => wp_login_url(strval(get_permalink())), |
|
162 | - 'text' => __('logged in', 'site-reviews'), |
|
163 | - ]); |
|
164 | - return sprintf(__('You must be %s to submit a review.', 'site-reviews'), $loginLink); |
|
165 | - } |
|
155 | + /** |
|
156 | + * @return string |
|
157 | + */ |
|
158 | + protected function getLoginText() |
|
159 | + { |
|
160 | + $loginLink = glsr(Builder::class)->a([ |
|
161 | + 'href' => wp_login_url(strval(get_permalink())), |
|
162 | + 'text' => __('logged in', 'site-reviews'), |
|
163 | + ]); |
|
164 | + return sprintf(__('You must be %s to submit a review.', 'site-reviews'), $loginLink); |
|
165 | + } |
|
166 | 166 | |
167 | - /** |
|
168 | - * @return void|string |
|
169 | - */ |
|
170 | - protected function getRegisterText() |
|
171 | - { |
|
172 | - if (!get_option('users_can_register') || !glsr(OptionManager::class)->getBool('settings.general.require.login')) { |
|
173 | - return; |
|
174 | - } |
|
175 | - $registerLink = glsr(Builder::class)->a([ |
|
176 | - 'href' => wp_registration_url(), |
|
177 | - 'text' => __('register', 'site-reviews'), |
|
178 | - ]); |
|
179 | - return sprintf(__('You may also %s for an account.', 'site-reviews'), $registerLink); |
|
180 | - } |
|
167 | + /** |
|
168 | + * @return void|string |
|
169 | + */ |
|
170 | + protected function getRegisterText() |
|
171 | + { |
|
172 | + if (!get_option('users_can_register') || !glsr(OptionManager::class)->getBool('settings.general.require.login')) { |
|
173 | + return; |
|
174 | + } |
|
175 | + $registerLink = glsr(Builder::class)->a([ |
|
176 | + 'href' => wp_registration_url(), |
|
177 | + 'text' => __('register', 'site-reviews'), |
|
178 | + ]); |
|
179 | + return sprintf(__('You may also %s for an account.', 'site-reviews'), $registerLink); |
|
180 | + } |
|
181 | 181 | |
182 | - /** |
|
183 | - * @return array |
|
184 | - */ |
|
185 | - protected function getHiddenFields() |
|
186 | - { |
|
187 | - $fields = [[ |
|
188 | - 'name' => '_action', |
|
189 | - 'value' => 'submit-review', |
|
190 | - ], [ |
|
191 | - 'name' => '_counter', |
|
192 | - ], [ |
|
193 | - 'name' => '_nonce', |
|
194 | - 'value' => wp_create_nonce('submit-review'), |
|
195 | - ], [ |
|
196 | - 'name' => '_post_id', |
|
197 | - 'value' => get_the_ID(), |
|
198 | - ], [ |
|
199 | - 'name' => '_referer', |
|
200 | - 'value' => wp_unslash(filter_input(INPUT_SERVER, 'REQUEST_URI')), |
|
201 | - ], [ |
|
202 | - 'name' => 'assign_to', |
|
203 | - 'value' => $this->args['assign_to'], |
|
204 | - ], [ |
|
205 | - 'name' => 'category', |
|
206 | - 'value' => $this->args['category'], |
|
207 | - ], [ |
|
208 | - 'name' => 'excluded', |
|
209 | - 'value' => $this->args['hide'], |
|
210 | - ], [ |
|
211 | - 'name' => 'form_id', |
|
212 | - 'value' => $this->args['id'], |
|
213 | - ]]; |
|
214 | - return array_map(function ($field) { |
|
215 | - return new Field(wp_parse_args($field, ['type' => 'hidden'])); |
|
216 | - }, $fields); |
|
217 | - } |
|
182 | + /** |
|
183 | + * @return array |
|
184 | + */ |
|
185 | + protected function getHiddenFields() |
|
186 | + { |
|
187 | + $fields = [[ |
|
188 | + 'name' => '_action', |
|
189 | + 'value' => 'submit-review', |
|
190 | + ], [ |
|
191 | + 'name' => '_counter', |
|
192 | + ], [ |
|
193 | + 'name' => '_nonce', |
|
194 | + 'value' => wp_create_nonce('submit-review'), |
|
195 | + ], [ |
|
196 | + 'name' => '_post_id', |
|
197 | + 'value' => get_the_ID(), |
|
198 | + ], [ |
|
199 | + 'name' => '_referer', |
|
200 | + 'value' => wp_unslash(filter_input(INPUT_SERVER, 'REQUEST_URI')), |
|
201 | + ], [ |
|
202 | + 'name' => 'assign_to', |
|
203 | + 'value' => $this->args['assign_to'], |
|
204 | + ], [ |
|
205 | + 'name' => 'category', |
|
206 | + 'value' => $this->args['category'], |
|
207 | + ], [ |
|
208 | + 'name' => 'excluded', |
|
209 | + 'value' => $this->args['hide'], |
|
210 | + ], [ |
|
211 | + 'name' => 'form_id', |
|
212 | + 'value' => $this->args['id'], |
|
213 | + ]]; |
|
214 | + return array_map(function ($field) { |
|
215 | + return new Field(wp_parse_args($field, ['type' => 'hidden'])); |
|
216 | + }, $fields); |
|
217 | + } |
|
218 | 218 | |
219 | - /** |
|
220 | - * @return Field |
|
221 | - */ |
|
222 | - protected function getHoneypotField() |
|
223 | - { |
|
224 | - return new Field([ |
|
225 | - 'name' => 'gotcha', |
|
226 | - 'type' => 'honeypot', |
|
227 | - ]); |
|
228 | - } |
|
219 | + /** |
|
220 | + * @return Field |
|
221 | + */ |
|
222 | + protected function getHoneypotField() |
|
223 | + { |
|
224 | + return new Field([ |
|
225 | + 'name' => 'gotcha', |
|
226 | + 'type' => 'honeypot', |
|
227 | + ]); |
|
228 | + } |
|
229 | 229 | |
230 | - /** |
|
231 | - * @return void |
|
232 | - */ |
|
233 | - protected function normalizeFieldId(Field &$field) |
|
234 | - { |
|
235 | - if (empty($this->args['id']) || empty($field->field['id'])) { |
|
236 | - return; |
|
237 | - } |
|
238 | - $field->field['id'].= '-'.$this->args['id']; |
|
239 | - } |
|
230 | + /** |
|
231 | + * @return void |
|
232 | + */ |
|
233 | + protected function normalizeFieldId(Field &$field) |
|
234 | + { |
|
235 | + if (empty($this->args['id']) || empty($field->field['id'])) { |
|
236 | + return; |
|
237 | + } |
|
238 | + $field->field['id'].= '-'.$this->args['id']; |
|
239 | + } |
|
240 | 240 | |
241 | - /** |
|
242 | - * @return void |
|
243 | - */ |
|
244 | - protected function normalizeFieldClass(Field &$field) |
|
245 | - { |
|
246 | - $field->field['class'] = trim(Arr::get($field->field, 'class').' glsr-field-control'); |
|
247 | - } |
|
241 | + /** |
|
242 | + * @return void |
|
243 | + */ |
|
244 | + protected function normalizeFieldClass(Field &$field) |
|
245 | + { |
|
246 | + $field->field['class'] = trim(Arr::get($field->field, 'class').' glsr-field-control'); |
|
247 | + } |
|
248 | 248 | |
249 | - /** |
|
250 | - * @return void |
|
251 | - */ |
|
252 | - protected function normalizeFieldErrors(Field &$field) |
|
253 | - { |
|
254 | - if (!array_key_exists($field->field['path'], $this->errors)) { |
|
255 | - return; |
|
256 | - } |
|
257 | - $field->field['errors'] = $this->errors[$field->field['path']]; |
|
258 | - } |
|
249 | + /** |
|
250 | + * @return void |
|
251 | + */ |
|
252 | + protected function normalizeFieldErrors(Field &$field) |
|
253 | + { |
|
254 | + if (!array_key_exists($field->field['path'], $this->errors)) { |
|
255 | + return; |
|
256 | + } |
|
257 | + $field->field['errors'] = $this->errors[$field->field['path']]; |
|
258 | + } |
|
259 | 259 | |
260 | - /** |
|
261 | - * @return void |
|
262 | - */ |
|
263 | - protected function normalizeFieldRequired(Field &$field) |
|
264 | - { |
|
265 | - if (!in_array($field->field['path'], $this->required)) { |
|
266 | - return; |
|
267 | - } |
|
268 | - $field->field['required'] = true; |
|
269 | - } |
|
260 | + /** |
|
261 | + * @return void |
|
262 | + */ |
|
263 | + protected function normalizeFieldRequired(Field &$field) |
|
264 | + { |
|
265 | + if (!in_array($field->field['path'], $this->required)) { |
|
266 | + return; |
|
267 | + } |
|
268 | + $field->field['required'] = true; |
|
269 | + } |
|
270 | 270 | |
271 | - /** |
|
272 | - * @return array |
|
273 | - */ |
|
274 | - protected function normalizeFields($fields) |
|
275 | - { |
|
276 | - $normalizedFields = []; |
|
277 | - foreach ($fields as $field) { |
|
278 | - if (in_array($field->field['path'], $this->args['hide'])) { |
|
279 | - continue; |
|
280 | - } |
|
281 | - $field->field['is_public'] = true; |
|
282 | - $this->normalizeFieldClass($field); |
|
283 | - $this->normalizeFieldErrors($field); |
|
284 | - $this->normalizeFieldRequired($field); |
|
285 | - $this->normalizeFieldValue($field); |
|
286 | - $this->normalizeFieldId($field); |
|
287 | - $normalizedFields[] = $field; |
|
288 | - } |
|
289 | - return $normalizedFields; |
|
290 | - } |
|
271 | + /** |
|
272 | + * @return array |
|
273 | + */ |
|
274 | + protected function normalizeFields($fields) |
|
275 | + { |
|
276 | + $normalizedFields = []; |
|
277 | + foreach ($fields as $field) { |
|
278 | + if (in_array($field->field['path'], $this->args['hide'])) { |
|
279 | + continue; |
|
280 | + } |
|
281 | + $field->field['is_public'] = true; |
|
282 | + $this->normalizeFieldClass($field); |
|
283 | + $this->normalizeFieldErrors($field); |
|
284 | + $this->normalizeFieldRequired($field); |
|
285 | + $this->normalizeFieldValue($field); |
|
286 | + $this->normalizeFieldId($field); |
|
287 | + $normalizedFields[] = $field; |
|
288 | + } |
|
289 | + return $normalizedFields; |
|
290 | + } |
|
291 | 291 | |
292 | - /** |
|
293 | - * @return void |
|
294 | - */ |
|
295 | - protected function normalizeFieldValue(Field &$field) |
|
296 | - { |
|
297 | - if (!array_key_exists($field->field['path'], $this->values)) { |
|
298 | - return; |
|
299 | - } |
|
300 | - if (in_array($field->field['type'], ['radio', 'checkbox'])) { |
|
301 | - $field->field['checked'] = $field->field['value'] == $this->values[$field->field['path']]; |
|
302 | - } else { |
|
303 | - $field->field['value'] = $this->values[$field->field['path']]; |
|
304 | - } |
|
305 | - } |
|
292 | + /** |
|
293 | + * @return void |
|
294 | + */ |
|
295 | + protected function normalizeFieldValue(Field &$field) |
|
296 | + { |
|
297 | + if (!array_key_exists($field->field['path'], $this->values)) { |
|
298 | + return; |
|
299 | + } |
|
300 | + if (in_array($field->field['type'], ['radio', 'checkbox'])) { |
|
301 | + $field->field['checked'] = $field->field['value'] == $this->values[$field->field['path']]; |
|
302 | + } else { |
|
303 | + $field->field['value'] = $this->values[$field->field['path']]; |
|
304 | + } |
|
305 | + } |
|
306 | 306 | } |
@@ -41,20 +41,20 @@ discard block |
||
41 | 41 | /** |
42 | 42 | * {@inheritdoc} |
43 | 43 | */ |
44 | - public function build(array $args = []) |
|
44 | + public function build( array $args = [] ) |
|
45 | 45 | { |
46 | 46 | $this->args = $args; |
47 | - if (!is_user_logged_in() && glsr(OptionManager::class)->getBool('settings.general.require.login')) { |
|
47 | + if( !is_user_logged_in() && glsr( OptionManager::class )->getBool( 'settings.general.require.login' ) ) { |
|
48 | 48 | return $this->buildLoginRegister(); |
49 | 49 | } |
50 | - $this->errors = glsr()->sessionGet($args['id'].'errors', []); |
|
51 | - $this->message = glsr()->sessionGet($args['id'].'message', ''); |
|
52 | - $this->required = glsr(OptionManager::class)->get('settings.submissions.required', []); |
|
53 | - $this->values = glsr()->sessionGet($args['id'].'values', []); |
|
54 | - $fields = array_reduce($this->getFields(), function ($carry, $field) { |
|
50 | + $this->errors = glsr()->sessionGet( $args['id'].'errors', [] ); |
|
51 | + $this->message = glsr()->sessionGet( $args['id'].'message', '' ); |
|
52 | + $this->required = glsr( OptionManager::class )->get( 'settings.submissions.required', [] ); |
|
53 | + $this->values = glsr()->sessionGet( $args['id'].'values', [] ); |
|
54 | + $fields = array_reduce( $this->getFields(), function( $carry, $field ) { |
|
55 | 55 | return $carry.$field; |
56 | 56 | }); |
57 | - return glsr(Template::class)->build('templates/reviews-form', [ |
|
57 | + return glsr( Template::class )->build( 'templates/reviews-form', [ |
|
58 | 58 | 'args' => $args, |
59 | 59 | 'context' => [ |
60 | 60 | 'class' => $this->getClass(), |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | 'response' => $this->buildResponse(), |
64 | 64 | 'submit_button' => $this->buildSubmitButton().$this->buildRecaptcha(), |
65 | 65 | ], |
66 | - ]); |
|
66 | + ] ); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | */ |
72 | 72 | protected function buildLoginRegister() |
73 | 73 | { |
74 | - return glsr(Template::class)->build('templates/login-register', [ |
|
74 | + return glsr( Template::class )->build( 'templates/login-register', [ |
|
75 | 75 | 'context' => [ |
76 | - 'text' => trim($this->getLoginText().' '.$this->getRegisterText()), |
|
76 | + 'text' => trim( $this->getLoginText().' '.$this->getRegisterText() ), |
|
77 | 77 | ], |
78 | - ]); |
|
78 | + ] ); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -83,15 +83,15 @@ discard block |
||
83 | 83 | */ |
84 | 84 | protected function buildRecaptcha() |
85 | 85 | { |
86 | - if (!glsr(OptionManager::class)->isRecaptchaEnabled()) { |
|
86 | + if( !glsr( OptionManager::class )->isRecaptchaEnabled() ) { |
|
87 | 87 | return; |
88 | 88 | } |
89 | - return glsr(Builder::class)->div([ |
|
89 | + return glsr( Builder::class )->div( [ |
|
90 | 90 | 'class' => 'glsr-recaptcha-holder', |
91 | - 'data-badge' => glsr(OptionManager::class)->get('settings.submissions.recaptcha.position'), |
|
92 | - 'data-sitekey' => sanitize_text_field(glsr(OptionManager::class)->get('settings.submissions.recaptcha.key')), |
|
91 | + 'data-badge' => glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.position' ), |
|
92 | + 'data-sitekey' => sanitize_text_field( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.key' ) ), |
|
93 | 93 | 'data-size' => 'invisible', |
94 | - ]); |
|
94 | + ] ); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -100,15 +100,15 @@ discard block |
||
100 | 100 | protected function buildResponse() |
101 | 101 | { |
102 | 102 | $classes = !empty($this->errors) |
103 | - ? glsr(StyleValidationDefaults::class)->defaults()['message_error_class'] |
|
103 | + ? glsr( StyleValidationDefaults::class )->defaults()['message_error_class'] |
|
104 | 104 | : ''; |
105 | - return glsr(Template::class)->build('templates/form/response', [ |
|
105 | + return glsr( Template::class )->build( 'templates/form/response', [ |
|
106 | 106 | 'context' => [ |
107 | 107 | 'class' => $classes, |
108 | - 'message' => wpautop($this->message), |
|
108 | + 'message' => wpautop( $this->message ), |
|
109 | 109 | ], |
110 | 110 | 'has_errors' => !empty($this->errors), |
111 | - ]); |
|
111 | + ] ); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | */ |
117 | 117 | protected function buildSubmitButton() |
118 | 118 | { |
119 | - return glsr(Template::class)->build('templates/form/submit-button', [ |
|
119 | + return glsr( Template::class )->build( 'templates/form/submit-button', [ |
|
120 | 120 | 'context' => [ |
121 | - 'text' => __('Submit your review', 'site-reviews'), |
|
121 | + 'text' => __( 'Submit your review', 'site-reviews' ), |
|
122 | 122 | ], |
123 | - ]); |
|
123 | + ] ); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | protected function getClass() |
130 | 130 | { |
131 | - return trim('glsr-form '.$this->args['class']); |
|
131 | + return trim( 'glsr-form '.$this->args['class'] ); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -138,18 +138,18 @@ discard block |
||
138 | 138 | { |
139 | 139 | $hiddenFields = $this->getHiddenFields(); |
140 | 140 | $hiddenFields[] = $this->getHoneypotField(); |
141 | - $fields = $this->normalizeFields(glsr(Form::class)->getFields('submission-form')); |
|
142 | - $paths = array_map(function ($obj) { |
|
141 | + $fields = $this->normalizeFields( glsr( Form::class )->getFields( 'submission-form' ) ); |
|
142 | + $paths = array_map( function( $obj ) { |
|
143 | 143 | return $obj->field['path']; |
144 | - }, $hiddenFields); |
|
145 | - foreach ($fields as $field) { |
|
146 | - $index = array_search($field->field['path'], $paths); |
|
147 | - if (false === $index) { |
|
144 | + }, $hiddenFields ); |
|
145 | + foreach( $fields as $field ) { |
|
146 | + $index = array_search( $field->field['path'], $paths ); |
|
147 | + if( false === $index ) { |
|
148 | 148 | continue; |
149 | 149 | } |
150 | 150 | unset($hiddenFields[$index]); |
151 | 151 | } |
152 | - return array_merge($hiddenFields, $fields); |
|
152 | + return array_merge( $hiddenFields, $fields ); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | */ |
158 | 158 | protected function getLoginText() |
159 | 159 | { |
160 | - $loginLink = glsr(Builder::class)->a([ |
|
161 | - 'href' => wp_login_url(strval(get_permalink())), |
|
162 | - 'text' => __('logged in', 'site-reviews'), |
|
163 | - ]); |
|
164 | - return sprintf(__('You must be %s to submit a review.', 'site-reviews'), $loginLink); |
|
160 | + $loginLink = glsr( Builder::class )->a( [ |
|
161 | + 'href' => wp_login_url( strval( get_permalink() ) ), |
|
162 | + 'text' => __( 'logged in', 'site-reviews' ), |
|
163 | + ] ); |
|
164 | + return sprintf( __( 'You must be %s to submit a review.', 'site-reviews' ), $loginLink ); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -169,14 +169,14 @@ discard block |
||
169 | 169 | */ |
170 | 170 | protected function getRegisterText() |
171 | 171 | { |
172 | - if (!get_option('users_can_register') || !glsr(OptionManager::class)->getBool('settings.general.require.login')) { |
|
172 | + if( !get_option( 'users_can_register' ) || !glsr( OptionManager::class )->getBool( 'settings.general.require.login' ) ) { |
|
173 | 173 | return; |
174 | 174 | } |
175 | - $registerLink = glsr(Builder::class)->a([ |
|
175 | + $registerLink = glsr( Builder::class )->a( [ |
|
176 | 176 | 'href' => wp_registration_url(), |
177 | - 'text' => __('register', 'site-reviews'), |
|
178 | - ]); |
|
179 | - return sprintf(__('You may also %s for an account.', 'site-reviews'), $registerLink); |
|
177 | + 'text' => __( 'register', 'site-reviews' ), |
|
178 | + ] ); |
|
179 | + return sprintf( __( 'You may also %s for an account.', 'site-reviews' ), $registerLink ); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -191,13 +191,13 @@ discard block |
||
191 | 191 | 'name' => '_counter', |
192 | 192 | ], [ |
193 | 193 | 'name' => '_nonce', |
194 | - 'value' => wp_create_nonce('submit-review'), |
|
194 | + 'value' => wp_create_nonce( 'submit-review' ), |
|
195 | 195 | ], [ |
196 | 196 | 'name' => '_post_id', |
197 | 197 | 'value' => get_the_ID(), |
198 | 198 | ], [ |
199 | 199 | 'name' => '_referer', |
200 | - 'value' => wp_unslash(filter_input(INPUT_SERVER, 'REQUEST_URI')), |
|
200 | + 'value' => wp_unslash( filter_input( INPUT_SERVER, 'REQUEST_URI' ) ), |
|
201 | 201 | ], [ |
202 | 202 | 'name' => 'assign_to', |
203 | 203 | 'value' => $this->args['assign_to'], |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | 'name' => 'form_id', |
212 | 212 | 'value' => $this->args['id'], |
213 | 213 | ]]; |
214 | - return array_map(function ($field) { |
|
215 | - return new Field(wp_parse_args($field, ['type' => 'hidden'])); |
|
216 | - }, $fields); |
|
214 | + return array_map( function( $field ) { |
|
215 | + return new Field( wp_parse_args( $field, ['type' => 'hidden'] ) ); |
|
216 | + }, $fields ); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -221,37 +221,37 @@ discard block |
||
221 | 221 | */ |
222 | 222 | protected function getHoneypotField() |
223 | 223 | { |
224 | - return new Field([ |
|
224 | + return new Field( [ |
|
225 | 225 | 'name' => 'gotcha', |
226 | 226 | 'type' => 'honeypot', |
227 | - ]); |
|
227 | + ] ); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
231 | 231 | * @return void |
232 | 232 | */ |
233 | - protected function normalizeFieldId(Field &$field) |
|
233 | + protected function normalizeFieldId( Field &$field ) |
|
234 | 234 | { |
235 | - if (empty($this->args['id']) || empty($field->field['id'])) { |
|
235 | + if( empty($this->args['id']) || empty($field->field['id']) ) { |
|
236 | 236 | return; |
237 | 237 | } |
238 | - $field->field['id'].= '-'.$this->args['id']; |
|
238 | + $field->field['id'] .= '-'.$this->args['id']; |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
242 | 242 | * @return void |
243 | 243 | */ |
244 | - protected function normalizeFieldClass(Field &$field) |
|
244 | + protected function normalizeFieldClass( Field &$field ) |
|
245 | 245 | { |
246 | - $field->field['class'] = trim(Arr::get($field->field, 'class').' glsr-field-control'); |
|
246 | + $field->field['class'] = trim( Arr::get( $field->field, 'class' ).' glsr-field-control' ); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
250 | 250 | * @return void |
251 | 251 | */ |
252 | - protected function normalizeFieldErrors(Field &$field) |
|
252 | + protected function normalizeFieldErrors( Field &$field ) |
|
253 | 253 | { |
254 | - if (!array_key_exists($field->field['path'], $this->errors)) { |
|
254 | + if( !array_key_exists( $field->field['path'], $this->errors ) ) { |
|
255 | 255 | return; |
256 | 256 | } |
257 | 257 | $field->field['errors'] = $this->errors[$field->field['path']]; |
@@ -260,9 +260,9 @@ discard block |
||
260 | 260 | /** |
261 | 261 | * @return void |
262 | 262 | */ |
263 | - protected function normalizeFieldRequired(Field &$field) |
|
263 | + protected function normalizeFieldRequired( Field &$field ) |
|
264 | 264 | { |
265 | - if (!in_array($field->field['path'], $this->required)) { |
|
265 | + if( !in_array( $field->field['path'], $this->required ) ) { |
|
266 | 266 | return; |
267 | 267 | } |
268 | 268 | $field->field['required'] = true; |
@@ -271,19 +271,19 @@ discard block |
||
271 | 271 | /** |
272 | 272 | * @return array |
273 | 273 | */ |
274 | - protected function normalizeFields($fields) |
|
274 | + protected function normalizeFields( $fields ) |
|
275 | 275 | { |
276 | 276 | $normalizedFields = []; |
277 | - foreach ($fields as $field) { |
|
278 | - if (in_array($field->field['path'], $this->args['hide'])) { |
|
277 | + foreach( $fields as $field ) { |
|
278 | + if( in_array( $field->field['path'], $this->args['hide'] ) ) { |
|
279 | 279 | continue; |
280 | 280 | } |
281 | 281 | $field->field['is_public'] = true; |
282 | - $this->normalizeFieldClass($field); |
|
283 | - $this->normalizeFieldErrors($field); |
|
284 | - $this->normalizeFieldRequired($field); |
|
285 | - $this->normalizeFieldValue($field); |
|
286 | - $this->normalizeFieldId($field); |
|
282 | + $this->normalizeFieldClass( $field ); |
|
283 | + $this->normalizeFieldErrors( $field ); |
|
284 | + $this->normalizeFieldRequired( $field ); |
|
285 | + $this->normalizeFieldValue( $field ); |
|
286 | + $this->normalizeFieldId( $field ); |
|
287 | 287 | $normalizedFields[] = $field; |
288 | 288 | } |
289 | 289 | return $normalizedFields; |
@@ -292,12 +292,12 @@ discard block |
||
292 | 292 | /** |
293 | 293 | * @return void |
294 | 294 | */ |
295 | - protected function normalizeFieldValue(Field &$field) |
|
295 | + protected function normalizeFieldValue( Field &$field ) |
|
296 | 296 | { |
297 | - if (!array_key_exists($field->field['path'], $this->values)) { |
|
297 | + if( !array_key_exists( $field->field['path'], $this->values ) ) { |
|
298 | 298 | return; |
299 | 299 | } |
300 | - if (in_array($field->field['type'], ['radio', 'checkbox'])) { |
|
300 | + if( in_array( $field->field['type'], ['radio', 'checkbox'] ) ) { |
|
301 | 301 | $field->field['checked'] = $field->field['value'] == $this->values[$field->field['path']]; |
302 | 302 | } else { |
303 | 303 | $field->field['value'] = $this->values[$field->field['path']]; |