@@ -48,7 +48,9 @@ |
||
48 | 48 | */ |
49 | 49 | public function enqueueRecaptchaScript() |
50 | 50 | { |
51 | - if( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.integration' ) != 'custom' )return; |
|
51 | + if( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.integration' ) != 'custom' ) { |
|
52 | + return; |
|
53 | + } |
|
52 | 54 | $language = apply_filters( 'site-reviews/recaptcha/language', get_locale() ); |
53 | 55 | wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg([ |
54 | 56 | 'hl' => $language, |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function enqueueAssets() |
25 | 25 | { |
26 | - if( apply_filters( 'site-reviews/assets/css', true )) { |
|
26 | + if( apply_filters( 'site-reviews/assets/css', true ) ) { |
|
27 | 27 | wp_enqueue_style( |
28 | 28 | Application::ID, |
29 | 29 | $this->getStylesheet(), |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | glsr()->version |
32 | 32 | ); |
33 | 33 | } |
34 | - if( apply_filters( 'site-reviews/assets/js', true )) { |
|
34 | + if( apply_filters( 'site-reviews/assets/js', true ) ) { |
|
35 | 35 | $dependencies = apply_filters( 'site-reviews/enqueue/public/dependencies', [] ); |
36 | 36 | wp_enqueue_script( |
37 | 37 | Application::ID, |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | { |
51 | 51 | if( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.integration' ) != 'custom' )return; |
52 | 52 | $language = apply_filters( 'site-reviews/recaptcha/language', get_locale() ); |
53 | - wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg([ |
|
53 | + wp_enqueue_script( Application::ID.'/google-recaptcha', add_query_arg( [ |
|
54 | 54 | 'hl' => $language, |
55 | 55 | 'onload' => 'glsr_render_recaptcha', |
56 | 56 | 'render' => 'explicit', |
57 | - ], 'https://www.google.com/recaptcha/api.js' )); |
|
58 | - $inlineScript = file_get_contents( glsr()->path( 'assets/scripts/recaptcha.js' )); |
|
57 | + ], 'https://www.google.com/recaptcha/api.js' ) ); |
|
58 | + $inlineScript = file_get_contents( glsr()->path( 'assets/scripts/recaptcha.js' ) ); |
|
59 | 59 | wp_add_inline_script( Application::ID.'/google-recaptcha', $inlineScript, 'before' ); |
60 | 60 | } |
61 | 61 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | { |
67 | 67 | $variables = [ |
68 | 68 | 'action' => Application::PREFIX.'action', |
69 | - 'ajaxpagination' => ['#wpadminbar','.site-navigation-fixed'], |
|
69 | + 'ajaxpagination' => ['#wpadminbar', '.site-navigation-fixed'], |
|
70 | 70 | 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
71 | 71 | ]; |
72 | 72 | $variables = apply_filters( 'site-reviews/enqueue/public/localize', $variables ); |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | */ |
79 | 79 | protected function getStylesheet() |
80 | 80 | { |
81 | - $currentTheme = sanitize_title( (string)wp_get_theme()->get( 'Name' )); |
|
82 | - return file_exists( glsr()->path( 'assets/styles/themes/'.$currentTheme.'.css' )) |
|
81 | + $currentTheme = sanitize_title( (string)wp_get_theme()->get( 'Name' ) ); |
|
82 | + return file_exists( glsr()->path( 'assets/styles/themes/'.$currentTheme.'.css' ) ) |
|
83 | 83 | ? glsr()->url( 'assets/styles/themes/'.$currentTheme.'.css' ) |
84 | 84 | : glsr()->url( 'assets/styles/'.Application::ID.'.css' ); |
85 | 85 | } |
@@ -27,13 +27,13 @@ |
||
27 | 27 | public function getFields( $id ) |
28 | 28 | { |
29 | 29 | $fields = []; |
30 | - $configPath = glsr()->path( 'config/'.$id.'.php' );; |
|
30 | + $configPath = glsr()->path( 'config/'.$id.'.php' ); ; |
|
31 | 31 | $values = file_exists( $configPath ) |
32 | 32 | ? include $configPath |
33 | 33 | : []; |
34 | 34 | $values = apply_filters( 'site-reviews/form/fields', $values ); |
35 | 35 | foreach( $values as $name => $field ) { |
36 | - $fields[] = new Field( wp_parse_args( $field, ['name' => $name] )); |
|
36 | + $fields[] = new Field( wp_parse_args( $field, ['name' => $name] ) ); |
|
37 | 37 | } |
38 | 38 | return $fields; |
39 | 39 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | { |
14 | 14 | $this->builder->args = wp_parse_args( $this->builder->args, [ |
15 | 15 | 'name' => $this->builder->args['text'], |
16 | - ]); |
|
16 | + ] ); |
|
17 | 17 | $this->builder->tag = 'input'; |
18 | 18 | $this->mergeFieldArgs(); |
19 | 19 | return $this->builder->getOpeningTag(); |
@@ -80,7 +80,9 @@ discard block |
||
80 | 80 | ]; |
81 | 81 | if( !isset( $properties[$property] ) |
82 | 82 | || empty( array_filter( [$value], $properties[$property] )) |
83 | - )return; |
|
83 | + ) { |
|
84 | + return; |
|
85 | + } |
|
84 | 86 | $this->$property = $value; |
85 | 87 | } |
86 | 88 | |
@@ -129,7 +131,9 @@ discard block |
||
129 | 131 | */ |
130 | 132 | protected function buildFieldDescription() |
131 | 133 | { |
132 | - if( empty( $this->args['description'] ))return; |
|
134 | + if( empty( $this->args['description'] )) { |
|
135 | + return; |
|
136 | + } |
|
133 | 137 | if( $this->args['is_widget'] ) { |
134 | 138 | return $this->small( $this->args['description'] ); |
135 | 139 | } |
@@ -184,7 +188,9 @@ discard block |
||
184 | 188 | */ |
185 | 189 | protected function buildFormLabel() |
186 | 190 | { |
187 | - if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' )return; |
|
191 | + if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' ) { |
|
192 | + return; |
|
193 | + } |
|
188 | 194 | return $this->label([ |
189 | 195 | 'for' => $this->args['id'], |
190 | 196 | 'text' => $this->args['label'], |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | { |
56 | 56 | $instance = new static; |
57 | 57 | $instance->setTagFromMethod( $method ); |
58 | - call_user_func_array( [$instance, 'normalize'], $args += ['',''] ); |
|
58 | + call_user_func_array( [$instance, 'normalize'], $args += ['', ''] ); |
|
59 | 59 | $tags = array_merge( static::TAGS_FORM, static::TAGS_SINGLE, static::TAGS_STRUCTURE, static::TAGS_TEXT ); |
60 | 60 | $generatedTag = in_array( $instance->tag, $tags ) |
61 | 61 | ? $instance->buildTag() |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | 'render' => 'is_bool', |
79 | 79 | 'tag' => 'is_string', |
80 | 80 | ]; |
81 | - if( !isset( $properties[$property] ) |
|
82 | - || empty( array_filter( [$value], $properties[$property] )) |
|
81 | + if( !isset($properties[$property]) |
|
82 | + || empty(array_filter( [$value], $properties[$property] )) |
|
83 | 83 | )return; |
84 | 84 | $this->$property = $value; |
85 | 85 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function getOpeningTag() |
99 | 99 | { |
100 | - $attributes = glsr( Attributes::class )->{$this->tag}( $this->args )->toString(); |
|
100 | + $attributes = glsr( Attributes::class )->{$this->tag}($this->args)->toString(); |
|
101 | 101 | return '<'.trim( $this->tag.' '.$attributes ).'>'; |
102 | 102 | } |
103 | 103 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | protected function buildCustomField() |
108 | 108 | { |
109 | 109 | $className = $this->getCustomFieldClassName(); |
110 | - if( class_exists( $className )) { |
|
110 | + if( class_exists( $className ) ) { |
|
111 | 111 | return (new $className( $this ))->build(); |
112 | 112 | } |
113 | 113 | glsr_log()->error( 'Field missing: '.$className ); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | protected function buildDefaultTag( $text = '' ) |
120 | 120 | { |
121 | - if( empty( $text )) { |
|
121 | + if( empty($text) ) { |
|
122 | 122 | $text = $this->args['text']; |
123 | 123 | } |
124 | 124 | return $this->getOpeningTag().$text.$this->getClosingTag(); |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | */ |
130 | 130 | protected function buildFieldDescription() |
131 | 131 | { |
132 | - if( empty( $this->args['description'] ))return; |
|
132 | + if( empty($this->args['description']) )return; |
|
133 | 133 | if( $this->args['is_widget'] ) { |
134 | 134 | return $this->small( $this->args['description'] ); |
135 | 135 | } |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | */ |
142 | 142 | protected function buildFormInput() |
143 | 143 | { |
144 | - if( !in_array( $this->args['type'], ['checkbox', 'radio'] )) { |
|
145 | - if( isset( $this->args['multiple'] )) { |
|
146 | - $this->args['name'].= '[]'; |
|
144 | + if( !in_array( $this->args['type'], ['checkbox', 'radio'] ) ) { |
|
145 | + if( isset($this->args['multiple']) ) { |
|
146 | + $this->args['name'] .= '[]'; |
|
147 | 147 | } |
148 | 148 | return $this->buildFormLabel().$this->getOpeningTag(); |
149 | 149 | } |
150 | - return empty( $this->args['options'] ) |
|
150 | + return empty($this->args['options']) |
|
151 | 151 | ? $this->buildFormInputChoice() |
152 | 152 | : $this->buildFormInputMultiChoice(); |
153 | 153 | } |
@@ -157,13 +157,13 @@ discard block |
||
157 | 157 | */ |
158 | 158 | protected function buildFormInputChoice() |
159 | 159 | { |
160 | - $labelText = !empty( $this->args['text'] ) |
|
160 | + $labelText = !empty($this->args['text']) |
|
161 | 161 | ? $this->args['text'] |
162 | 162 | : $this->args['label']; |
163 | 163 | return $this->label( $this->getOpeningTag().' '.$labelText, [ |
164 | 164 | 'class' => 'glsr-'.$this->args['type'].'-label', |
165 | 165 | 'for' => $this->args['id'], |
166 | - ]); |
|
166 | + ] ); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | protected function buildFormInputMultiChoice() |
173 | 173 | { |
174 | 174 | if( $this->args['type'] == 'checkbox' ) { |
175 | - $this->args['name'].= '[]'; |
|
175 | + $this->args['name'] .= '[]'; |
|
176 | 176 | } |
177 | 177 | $options = array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) { |
178 | 178 | return $carry.$this->li( $this->{$this->args['type']}([ |
@@ -180,12 +180,12 @@ discard block |
||
180 | 180 | 'name' => $this->args['name'], |
181 | 181 | 'text' => $this->args['options'][$key], |
182 | 182 | 'value' => $key, |
183 | - ])); |
|
183 | + ]) ); |
|
184 | 184 | }); |
185 | 185 | return $this->ul( $options, [ |
186 | 186 | 'class' => $this->args['class'], |
187 | 187 | 'id' => $this->args['id'], |
188 | - ]); |
|
188 | + ] ); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -193,11 +193,11 @@ discard block |
||
193 | 193 | */ |
194 | 194 | protected function buildFormLabel() |
195 | 195 | { |
196 | - if( empty( $this->args['label'] ) || $this->args['type'] == 'hidden' )return; |
|
197 | - return $this->label([ |
|
196 | + if( empty($this->args['label']) || $this->args['type'] == 'hidden' )return; |
|
197 | + return $this->label( [ |
|
198 | 198 | 'for' => $this->args['id'], |
199 | 199 | 'text' => $this->args['label'], |
200 | - ]); |
|
200 | + ] ); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -214,11 +214,11 @@ discard block |
||
214 | 214 | protected function buildFormSelectOptions() |
215 | 215 | { |
216 | 216 | return array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) { |
217 | - return $carry.$this->option([ |
|
217 | + return $carry.$this->option( [ |
|
218 | 218 | 'selected' => $this->args['value'] == $key, |
219 | 219 | 'text' => $this->args['options'][$key], |
220 | 220 | 'value' => $key, |
221 | - ]); |
|
221 | + ] ); |
|
222 | 222 | }); |
223 | 223 | } |
224 | 224 | |
@@ -236,10 +236,10 @@ discard block |
||
236 | 236 | protected function buildTag() |
237 | 237 | { |
238 | 238 | $this->mergeArgsWithRequiredDefaults(); |
239 | - if( in_array( $this->tag, static::TAGS_SINGLE )) { |
|
239 | + if( in_array( $this->tag, static::TAGS_SINGLE ) ) { |
|
240 | 240 | return $this->getOpeningTag(); |
241 | 241 | } |
242 | - if( !in_array( $this->tag, static::TAGS_FORM )) { |
|
242 | + if( !in_array( $this->tag, static::TAGS_FORM ) ) { |
|
243 | 243 | return $this->buildDefaultTag(); |
244 | 244 | } |
245 | 245 | return call_user_func( [$this, 'buildForm'.ucfirst( $this->tag )] ).$this->buildFieldDescription(); |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | protected function mergeArgsWithRequiredDefaults() |
260 | 260 | { |
261 | 261 | $className = $this->getCustomFieldClassName(); |
262 | - if( class_exists( $className )) { |
|
262 | + if( class_exists( $className ) ) { |
|
263 | 263 | $this->args = array_merge( |
264 | 264 | wp_parse_args( $this->args, $className::defaults() ), |
265 | 265 | $className::required() |
@@ -274,13 +274,13 @@ discard block |
||
274 | 274 | */ |
275 | 275 | protected function normalize( ...$params ) |
276 | 276 | { |
277 | - if( is_string( $params[0] ) || is_numeric( $params[0] )) { |
|
277 | + if( is_string( $params[0] ) || is_numeric( $params[0] ) ) { |
|
278 | 278 | $this->setNameOrTextAttributeForTag( $params[0] ); |
279 | 279 | } |
280 | - if( is_array( $params[0] )) { |
|
280 | + if( is_array( $params[0] ) ) { |
|
281 | 281 | $this->args += $params[0]; |
282 | 282 | } |
283 | - else if( is_array( $params[1] )) { |
|
283 | + else if( is_array( $params[1] ) ) { |
|
284 | 284 | $this->args += $params[1]; |
285 | 285 | } |
286 | 286 | } |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | protected function setTagFromMethod( $method ) |
305 | 305 | { |
306 | 306 | $this->tag = strtolower( $method ); |
307 | - if( in_array( $this->tag, static::INPUT_TYPES )) { |
|
307 | + if( in_array( $this->tag, static::INPUT_TYPES ) ) { |
|
308 | 308 | $this->args['type'] = $this->tag; |
309 | 309 | $this->tag = 'input'; |
310 | 310 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | glsr()->version, |
45 | 45 | true |
46 | 46 | ); |
47 | - if( !empty( $this->pointers )) { |
|
47 | + if( !empty($this->pointers) ) { |
|
48 | 48 | wp_enqueue_style( 'wp-pointer' ); |
49 | 49 | wp_enqueue_script( 'wp-pointer' ); |
50 | 50 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $dependencies = apply_filters( 'site-reviews/enqueue/admin/dependencies', [] ); |
85 | 85 | $dependencies = array_merge( $dependencies, [ |
86 | 86 | 'jquery', 'jquery-ui-sortable', 'underscore', 'wp-util', |
87 | - ]); |
|
87 | + ] ); |
|
88 | 88 | return $dependencies; |
89 | 89 | } |
90 | 90 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $generatedPointers = []; |
115 | 115 | foreach( $pointers as $pointer ) { |
116 | 116 | if( $pointer['screen'] != glsr_current_screen()->id )continue; |
117 | - if( in_array( $pointer['id'], $dismissedPointers ))continue; |
|
117 | + if( in_array( $pointer['id'], $dismissedPointers ) )continue; |
|
118 | 118 | $generatedPointers[] = $this->generatePointer( $pointer ); |
119 | 119 | } |
120 | 120 | $this->pointers = $generatedPointers; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | protected function isCurrentScreen() |
127 | 127 | { |
128 | 128 | $screen = glsr_current_screen(); |
129 | - return $screen && ( $screen->post_type == Application::POST_TYPE |
|
129 | + return $screen && ($screen->post_type == Application::POST_TYPE |
|
130 | 130 | || $screen->base == 'post' |
131 | 131 | || $screen->id == 'dashboard' |
132 | 132 | || $screen->id == 'widgets' |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | { |
141 | 141 | $variables = []; |
142 | 142 | foreach( glsr()->mceShortcodes as $tag => $args ) { |
143 | - if( empty( $args['required'] ))continue; |
|
143 | + if( empty($args['required']) )continue; |
|
144 | 144 | $variables[$tag] = $args['required']; |
145 | 145 | } |
146 | 146 | return $variables; |
@@ -36,7 +36,9 @@ discard block |
||
36 | 36 | [], |
37 | 37 | glsr()->version |
38 | 38 | ); |
39 | - if( !$this->isCurrentScreen() )return; |
|
39 | + if( !$this->isCurrentScreen() ) { |
|
40 | + return; |
|
41 | + } |
|
40 | 42 | wp_enqueue_script( |
41 | 43 | Application::ID, |
42 | 44 | glsr()->url( 'assets/scripts/'.Application::ID.'-admin.js' ), |
@@ -113,8 +115,12 @@ discard block |
||
113 | 115 | $dismissedPointers = explode( ',', (string)$dismissedPointers ); |
114 | 116 | $generatedPointers = []; |
115 | 117 | foreach( $pointers as $pointer ) { |
116 | - if( $pointer['screen'] != glsr_current_screen()->id )continue; |
|
117 | - if( in_array( $pointer['id'], $dismissedPointers ))continue; |
|
118 | + if( $pointer['screen'] != glsr_current_screen()->id ) { |
|
119 | + continue; |
|
120 | + } |
|
121 | + if( in_array( $pointer['id'], $dismissedPointers )) { |
|
122 | + continue; |
|
123 | + } |
|
118 | 124 | $generatedPointers[] = $this->generatePointer( $pointer ); |
119 | 125 | } |
120 | 126 | $this->pointers = $generatedPointers; |
@@ -140,7 +146,9 @@ discard block |
||
140 | 146 | { |
141 | 147 | $variables = []; |
142 | 148 | foreach( glsr()->mceShortcodes as $tag => $args ) { |
143 | - if( empty( $args['required'] ))continue; |
|
149 | + if( empty( $args['required'] )) { |
|
150 | + continue; |
|
151 | + } |
|
144 | 152 | $variables[$tag] = $args['required']; |
145 | 153 | } |
146 | 154 | return $variables; |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | defined( 'WPINC' ) || die; |
4 | 4 | |
5 | -require_once( ABSPATH.WPINC.'/class-phpass.php' ); |
|
5 | +require_once(ABSPATH.WPINC.'/class-phpass.php'); |
|
6 | 6 | |
7 | 7 | spl_autoload_register( function( $className ) { |
8 | 8 | $namespaces = [ |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | foreach( $namespaces as $prefix => $baseDir ) { |
17 | 17 | $len = strlen( $prefix ); |
18 | 18 | if( strncmp( $prefix, $className, $len ) !== 0 )continue; |
19 | - $file = $baseDir.str_replace( '\\', '/', substr( $className, $len )).'.php'; |
|
20 | - if( !file_exists( $file ))continue; |
|
19 | + $file = $baseDir.str_replace( '\\', '/', substr( $className, $len ) ).'.php'; |
|
20 | + if( !file_exists( $file ) )continue; |
|
21 | 21 | require $file; |
22 | 22 | break; |
23 | 23 | } |
@@ -15,9 +15,13 @@ |
||
15 | 15 | ]; |
16 | 16 | foreach( $namespaces as $prefix => $baseDir ) { |
17 | 17 | $len = strlen( $prefix ); |
18 | - if( strncmp( $prefix, $className, $len ) !== 0 )continue; |
|
18 | + if( strncmp( $prefix, $className, $len ) !== 0 ) { |
|
19 | + continue; |
|
20 | + } |
|
19 | 21 | $file = $baseDir.str_replace( '\\', '/', substr( $className, $len )).'.php'; |
20 | - if( !file_exists( $file ))continue; |
|
22 | + if( !file_exists( $file )) { |
|
23 | + continue; |
|
24 | + } |
|
21 | 25 | require $file; |
22 | 26 | break; |
23 | 27 | } |
@@ -50,7 +50,7 @@ |
||
50 | 50 | public function routerSubmitReview( array $request ) |
51 | 51 | { |
52 | 52 | $validated = glsr( ValidateReview::class )->validate( $request ); |
53 | - if( !empty( $validated->error ) || $validated->recaptchaIsUnset )return; |
|
54 | - $this->execute( new CreateReview( $validated->request )); |
|
53 | + if( !empty($validated->error) || $validated->recaptchaIsUnset )return; |
|
54 | + $this->execute( new CreateReview( $validated->request ) ); |
|
55 | 55 | } |
56 | 56 | } |
@@ -50,7 +50,9 @@ |
||
50 | 50 | public function routerSubmitReview( array $request ) |
51 | 51 | { |
52 | 52 | $validated = glsr( ValidateReview::class )->validate( $request ); |
53 | - if( !empty( $validated->error ) || $validated->recaptchaIsUnset )return; |
|
53 | + if( !empty( $validated->error ) || $validated->recaptchaIsUnset ) { |
|
54 | + return; |
|
55 | + } |
|
54 | 56 | $this->execute( new CreateReview( $validated->request )); |
55 | 57 | } |
56 | 58 | } |
@@ -152,7 +152,9 @@ discard block |
||
152 | 152 | */ |
153 | 153 | protected function normalizeFieldErrors( Field &$field ) |
154 | 154 | { |
155 | - if( !array_key_exists( $field->field['path'], $this->errors ))return; |
|
155 | + if( !array_key_exists( $field->field['path'], $this->errors )) { |
|
156 | + return; |
|
157 | + } |
|
156 | 158 | $field->field['errors'] = $this->errors[$field->field['path']]; |
157 | 159 | } |
158 | 160 | |
@@ -161,7 +163,9 @@ discard block |
||
161 | 163 | */ |
162 | 164 | protected function normalizeFieldRequired( Field &$field ) |
163 | 165 | { |
164 | - if( !in_array( $field->field['path'], $this->required ))return; |
|
166 | + if( !in_array( $field->field['path'], $this->required )) { |
|
167 | + return; |
|
168 | + } |
|
165 | 169 | $field->field['required'] = true; |
166 | 170 | } |
167 | 171 | |
@@ -183,7 +187,9 @@ discard block |
||
183 | 187 | */ |
184 | 188 | protected function normalizeFieldValue( Field &$field ) |
185 | 189 | { |
186 | - if( !array_key_exists( $field->field['path'], $this->values ))return; |
|
190 | + if( !array_key_exists( $field->field['path'], $this->values )) { |
|
191 | + return; |
|
192 | + } |
|
187 | 193 | if( in_array( $field->field['type'], ['radio', 'checkbox'] )) { |
188 | 194 | $field->field['checked'] = $field->field['value'] == $this->values[$field->field['path']]; |
189 | 195 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | 'results' => $this->buildResults(), |
61 | 61 | 'submit_button' => $this->buildSubmitButton().$this->buildRecaptcha(), |
62 | 62 | ], |
63 | - ]); |
|
63 | + ] ); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | { |
71 | 71 | $integration = glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.integration' ); |
72 | 72 | $recaptchaMethod = glsr( Helper::class )->buildMethodName( $integration, 'getRecaptcha' ); |
73 | - if( method_exists( $this, $recaptchaMethod )) { |
|
73 | + if( method_exists( $this, $recaptchaMethod ) ) { |
|
74 | 74 | return $this->$recaptchaMethod(); |
75 | 75 | } |
76 | 76 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | return glsr( Partial::class )->build( 'form-results', [ |
84 | 84 | 'errors' => $this->errors, |
85 | 85 | 'message' => $this->message, |
86 | - ]); |
|
86 | + ] ); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | 'context' => [ |
96 | 96 | 'text' => __( 'Submit your review', 'site-reviews' ), |
97 | 97 | ], |
98 | - ]); |
|
98 | + ] ); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $fields = array_merge( |
116 | 116 | $this->getHiddenFields(), |
117 | 117 | [$this->getHoneypotField()], |
118 | - $this->normalizeFields( glsr( Form::class )->getFields( 'submission-form' )) |
|
118 | + $this->normalizeFields( glsr( Form::class )->getFields( 'submission-form' ) ) |
|
119 | 119 | ); |
120 | 120 | return $fields; |
121 | 121 | } |
@@ -128,27 +128,27 @@ discard block |
||
128 | 128 | $fields = [[ |
129 | 129 | 'name' => 'action', |
130 | 130 | 'value' => 'submit-review', |
131 | - ],[ |
|
131 | + ], [ |
|
132 | 132 | 'name' => 'assign_to', |
133 | 133 | 'value' => $this->args['assign_to'], |
134 | - ],[ |
|
134 | + ], [ |
|
135 | 135 | 'name' => 'category', |
136 | 136 | 'value' => $this->args['category'], |
137 | - ],[ |
|
137 | + ], [ |
|
138 | 138 | 'name' => 'excluded', |
139 | 139 | 'value' => $this->args['excluded'], // @todo should default to "[]" |
140 | - ],[ |
|
140 | + ], [ |
|
141 | 141 | 'name' => 'form_id', |
142 | 142 | 'value' => $this->args['id'], |
143 | - ],[ |
|
143 | + ], [ |
|
144 | 144 | 'name' => 'nonce', |
145 | 145 | 'value' => wp_create_nonce( 'submit-review' ), |
146 | - ],[ |
|
146 | + ], [ |
|
147 | 147 | 'name' => 'referer', |
148 | - 'value' => wp_unslash( filter_input( INPUT_SERVER, 'REQUEST_URI' )), |
|
148 | + 'value' => wp_unslash( filter_input( INPUT_SERVER, 'REQUEST_URI' ) ), |
|
149 | 149 | ]]; |
150 | 150 | return array_map( function( $field ) { |
151 | - return new Field( wp_parse_args( $field, ['type' => 'hidden'] )); |
|
151 | + return new Field( wp_parse_args( $field, ['type' => 'hidden'] ) ); |
|
152 | 152 | }, $fields ); |
153 | 153 | } |
154 | 154 | |
@@ -157,10 +157,10 @@ discard block |
||
157 | 157 | */ |
158 | 158 | protected function getHoneypotField() |
159 | 159 | { |
160 | - return new Field([ |
|
160 | + return new Field( [ |
|
161 | 161 | 'name' => 'gotcha', |
162 | 162 | 'type' => 'honeypot', |
163 | - ]); |
|
163 | + ] ); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -168,12 +168,12 @@ discard block |
||
168 | 168 | */ |
169 | 169 | protected function getRecaptchaCustom() |
170 | 170 | { |
171 | - return glsr( Builder::class )->div([ |
|
171 | + return glsr( Builder::class )->div( [ |
|
172 | 172 | 'class' => 'glsr-recaptcha-holder', |
173 | - 'data-badge' => sanitize_text_field( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.position' )), |
|
174 | - 'data-sitekey' => sanitize_text_field( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.key' )), |
|
173 | + 'data-badge' => sanitize_text_field( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.position' ) ), |
|
174 | + 'data-sitekey' => sanitize_text_field( glsr( OptionManager::class )->get( 'settings.submissions.recaptcha.key' ) ), |
|
175 | 175 | 'data-size' => 'invisible', |
176 | - ]); |
|
176 | + ] ); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $html = ob_get_clean(); |
187 | 187 | return glsr( Builder::class )->div( $html, [ |
188 | 188 | 'class' => 'glsr-recaptcha-holder', |
189 | - ]); |
|
189 | + ] ); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | */ |
195 | 195 | protected function normalizeFieldErrors( Field &$field ) |
196 | 196 | { |
197 | - if( !array_key_exists( $field->field['path'], $this->errors ))return; |
|
197 | + if( !array_key_exists( $field->field['path'], $this->errors ) )return; |
|
198 | 198 | $field->field['errors'] = $this->errors[$field->field['path']]; |
199 | 199 | } |
200 | 200 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | */ |
204 | 204 | protected function normalizeFieldRequired( Field &$field ) |
205 | 205 | { |
206 | - if( !in_array( $field->field['path'], $this->required ))return; |
|
206 | + if( !in_array( $field->field['path'], $this->required ) )return; |
|
207 | 207 | $field->field['required'] = true; |
208 | 208 | } |
209 | 209 | |
@@ -225,8 +225,8 @@ discard block |
||
225 | 225 | */ |
226 | 226 | protected function normalizeFieldValue( Field &$field ) |
227 | 227 | { |
228 | - if( !array_key_exists( $field->field['path'], $this->values ))return; |
|
229 | - if( in_array( $field->field['type'], ['radio', 'checkbox'] )) { |
|
228 | + if( !array_key_exists( $field->field['path'], $this->values ) )return; |
|
229 | + if( in_array( $field->field['type'], ['radio', 'checkbox'] ) ) { |
|
230 | 230 | $field->field['checked'] = $field->field['value'] == $this->values[$field->field['path']]; |
231 | 231 | } |
232 | 232 | else { |
@@ -43,7 +43,9 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function build() |
45 | 45 | { |
46 | - if( !$this->field['is_valid'] )return; |
|
46 | + if( !$this->field['is_valid'] ) { |
|
47 | + return; |
|
48 | + } |
|
47 | 49 | if( $this->field['is_raw'] ) { |
48 | 50 | return glsr( Builder::class )->{$this->field['type']}( $this->field ); |
49 | 51 | } |
@@ -143,7 +145,9 @@ discard block |
||
143 | 145 | */ |
144 | 146 | protected function getFieldErrors() |
145 | 147 | { |
146 | - if( empty( $this->field['errors'] ) || !is_array( $this->field['errors'] ))return; |
|
148 | + if( empty( $this->field['errors'] ) || !is_array( $this->field['errors'] )) { |
|
149 | + return; |
|
150 | + } |
|
147 | 151 | $errors = array_reduce( $this->field['errors'], function( $carry, $error ) { |
148 | 152 | return $carry.glsr( Builder::class )->span( $error, ['class' => 'glsr-field-error'] ); |
149 | 153 | }); |
@@ -170,7 +174,9 @@ discard block |
||
170 | 174 | 'name', 'type', |
171 | 175 | ]; |
172 | 176 | foreach( $requiredValues as $value ) { |
173 | - if( isset( $this->field[$value] ))continue; |
|
177 | + if( isset( $this->field[$value] )) { |
|
178 | + continue; |
|
179 | + } |
|
174 | 180 | $missingValues[] = $value; |
175 | 181 | $this->field['is_valid'] = false; |
176 | 182 | } |
@@ -187,7 +193,9 @@ discard block |
||
187 | 193 | */ |
188 | 194 | protected function normalize() |
189 | 195 | { |
190 | - if( !$this->isFieldValid() )return; |
|
196 | + if( !$this->isFieldValid() ) { |
|
197 | + return; |
|
198 | + } |
|
191 | 199 | $this->field['path'] = $this->field['name']; |
192 | 200 | $className = glsr( Helper::class )->buildClassName( $this->field['type'], __NAMESPACE__.'\Fields' ); |
193 | 201 | if( class_exists( $className )) { |
@@ -205,7 +213,9 @@ discard block |
||
205 | 213 | */ |
206 | 214 | protected function normalizeFieldId() |
207 | 215 | { |
208 | - if( isset( $this->field['id'] ) || $this->field['is_raw'] )return; |
|
216 | + if( isset( $this->field['id'] ) || $this->field['is_raw'] ) { |
|
217 | + return; |
|
218 | + } |
|
209 | 219 | $this->field['id'] = glsr( Helper::class )->convertPathToId( |
210 | 220 | $this->field['path'], |
211 | 221 | $this->getFieldPrefix() |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | 'is_valid' => true, |
27 | 27 | 'is_widget' => false, |
28 | 28 | 'path' => '', |
29 | - ]); |
|
29 | + ] ); |
|
30 | 30 | $this->normalize(); |
31 | 31 | } |
32 | 32 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | { |
46 | 46 | if( !$this->field['is_valid'] )return; |
47 | 47 | if( $this->field['is_raw'] ) { |
48 | - return glsr( Builder::class )->{$this->field['type']}( $this->field ); |
|
48 | + return glsr( Builder::class )->{$this->field['type']}($this->field); |
|
49 | 49 | } |
50 | 50 | if( !$this->field['is_setting'] ) { |
51 | 51 | return $this->buildField(); |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | 'context' => [ |
74 | 74 | 'class' => $this->getFieldClass(), |
75 | 75 | 'errors' => $this->getFieldErrors(), |
76 | - 'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ), |
|
76 | + 'field' => glsr( Builder::class )->{$this->field['type']}($this->field), |
|
77 | 77 | ], |
78 | - ]); |
|
78 | + ] ); |
|
79 | 79 | return apply_filters( 'site-reviews/rendered/field', $field, $this->field['type'], $this->field ); |
80 | 80 | } |
81 | 81 | |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | return glsr( Template::class )->build( 'partials/form/table-row', [ |
88 | 88 | 'context' => [ |
89 | 89 | 'class' => $this->getFieldClass(), |
90 | - 'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ), |
|
90 | + 'field' => glsr( Builder::class )->{$this->field['type']}($this->field), |
|
91 | 91 | 'label' => glsr( Builder::class )->label( $this->field['legend'], ['for' => $this->field['id']] ), |
92 | 92 | ], |
93 | - ]); |
|
93 | + ] ); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -99,16 +99,16 @@ discard block |
||
99 | 99 | protected function buildSettingMultiField() |
100 | 100 | { |
101 | 101 | $dependsOn = $this->getFieldDependsOn(); |
102 | - unset( $this->field['data-depends'] ); |
|
102 | + unset($this->field['data-depends']); |
|
103 | 103 | return glsr( Template::class )->build( 'partials/form/table-row-multiple', [ |
104 | 104 | 'context' => [ |
105 | 105 | 'class' => $this->getFieldClass(), |
106 | 106 | 'depends_on' => $dependsOn, |
107 | - 'field' => glsr( Builder::class )->{$this->field['type']}( $this->field ), |
|
107 | + 'field' => glsr( Builder::class )->{$this->field['type']}($this->field), |
|
108 | 108 | 'label' => glsr( Builder::class )->label( $this->field['legend'], ['for' => $this->field['id']] ), |
109 | 109 | 'legend' => $this->field['legend'], |
110 | 110 | ], |
111 | - ]); |
|
111 | + ] ); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -117,13 +117,13 @@ discard block |
||
117 | 117 | protected function getFieldClass() |
118 | 118 | { |
119 | 119 | $classes = []; |
120 | - if( !empty( $this->field['errors'] )) { |
|
120 | + if( !empty($this->field['errors']) ) { |
|
121 | 121 | $classes[] = 'glsr-has-error'; |
122 | 122 | } |
123 | 123 | if( $this->field['is_hidden'] ) { |
124 | 124 | $classes[] = 'hidden'; |
125 | 125 | } |
126 | - if( !empty( $this->field['required'] )) { |
|
126 | + if( !empty($this->field['required']) ) { |
|
127 | 127 | $classes[] = 'glsr-required'; |
128 | 128 | } |
129 | 129 | return implode( ' ', $classes ); |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | protected function getFieldDependsOn() |
136 | 136 | { |
137 | - return !empty( $this->field['data-depends'] ) |
|
137 | + return !empty($this->field['data-depends']) |
|
138 | 138 | ? $this->field['data-depends'] |
139 | 139 | : ''; |
140 | 140 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | protected function getFieldErrors() |
146 | 146 | { |
147 | - if( empty( $this->field['errors'] ) || !is_array( $this->field['errors'] ))return; |
|
147 | + if( empty($this->field['errors']) || !is_array( $this->field['errors'] ) )return; |
|
148 | 148 | $errors = array_reduce( $this->field['errors'], function( $carry, $error ) { |
149 | 149 | return $carry.glsr( Builder::class )->span( $error, ['class' => 'glsr-field-error'] ); |
150 | 150 | }); |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | 'context' => [ |
153 | 153 | 'errors' => $errors, |
154 | 154 | ], |
155 | - ]); |
|
155 | + ] ); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -175,13 +175,13 @@ discard block |
||
175 | 175 | 'name', 'type', |
176 | 176 | ]; |
177 | 177 | foreach( $requiredValues as $value ) { |
178 | - if( isset( $this->field[$value] ))continue; |
|
178 | + if( isset($this->field[$value]) )continue; |
|
179 | 179 | $missingValues[] = $value; |
180 | 180 | $this->field['is_valid'] = false; |
181 | 181 | } |
182 | - if( !empty( $missingValues )) { |
|
182 | + if( !empty($missingValues) ) { |
|
183 | 183 | glsr_log() |
184 | - ->warning( 'Field is missing: '.implode( ', ', $missingValues )) |
|
184 | + ->warning( 'Field is missing: '.implode( ', ', $missingValues ) ) |
|
185 | 185 | ->info( $this->field ); |
186 | 186 | } |
187 | 187 | return $this->field['is_valid']; |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | if( !$this->isFieldValid() )return; |
196 | 196 | $this->field['path'] = $this->field['name']; |
197 | 197 | $className = glsr( Helper::class )->buildClassName( $this->field['type'], __NAMESPACE__.'\Fields' ); |
198 | - if( class_exists( $className )) { |
|
198 | + if( class_exists( $className ) ) { |
|
199 | 199 | $this->field = array_merge( |
200 | 200 | wp_parse_args( $this->field, $className::defaults() ), |
201 | 201 | $className::required() |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | */ |
211 | 211 | protected function normalizeFieldId() |
212 | 212 | { |
213 | - if( isset( $this->field['id'] ) || $this->field['is_raw'] )return; |
|
213 | + if( isset($this->field['id']) || $this->field['is_raw'] )return; |
|
214 | 214 | $this->field['id'] = glsr( Helper::class )->convertPathToId( |
215 | 215 | $this->field['path'], |
216 | 216 | $this->getFieldPrefix() |