Completed
Push — master ( 8d1412...e15369 )
by
unknown
49s
created
redux-core/inc/classes/class-redux-validation.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 		public function validate( array $plugin_options, array $options, array $sections ): array {
33 33
 			$core = $this->core();
34 34
 
35
-			if (null === $core) {
35
+			if ( null === $core ) {
36 36
 				return $plugin_options;
37 37
 			}
38 38
 
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
 						}
45 45
 
46 46
 						if ( isset( $field['type'] ) && ( 'checkbox' === $field['type'] || 'checkbox_hide_below' === $field['type'] || 'checkbox_hide_all' === $field['type'] ) ) {
47
-							if ( ! isset( $plugin_options[ $field['id'] ] ) ) {
48
-								$plugin_options[ $field['id'] ] = 0;
47
+							if ( ! isset( $plugin_options[$field['id']] ) ) {
48
+								$plugin_options[$field['id']] = 0;
49 49
 							}
50 50
 						}
51 51
 
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
 						 * }
59 59
 						 */
60 60
 
61
-						if ( isset( $core->extensions[ $field['type'] ] ) && method_exists( $core->extensions[ $field['type'] ], '_validate_values' ) ) {
62
-							$plugin_options = $core->extensions[ $field['type'] ]->_validate_values( $plugin_options, $field, $sections );
61
+						if ( isset( $core->extensions[$field['type']] ) && method_exists( $core->extensions[$field['type']], '_validate_values' ) ) {
62
+							$plugin_options = $core->extensions[$field['type']]->_validate_values( $plugin_options, $field, $sections );
63 63
 						}
64 64
 
65 65
 						// Make sure 'validate' field is set.
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 								}
90 90
 
91 91
 								// Check for empty id value.
92
-								if ( ! isset( $field['id'] ) || ! isset( $plugin_options[ $field['id'] ] ) || ( '' === $plugin_options[ $field['id'] ] ) ) {
92
+								if ( ! isset( $field['id'] ) || ! isset( $plugin_options[$field['id']] ) || ( '' === $plugin_options[$field['id']] ) ) {
93 93
 
94 94
 									// If we are looking for an empty value, in the case of 'not_empty'
95 95
 									// then we need to keep processing.
@@ -143,33 +143,33 @@  discard block
 block discarded – undo
143 143
 								}
144 144
 
145 145
 								if ( class_exists( $validate ) ) {
146
-									if ( empty( $options[ $field['id'] ] ) ) {
147
-										$options[ $field['id'] ] = '';
146
+									if ( empty( $options[$field['id']] ) ) {
147
+										$options[$field['id']] = '';
148 148
 									}
149 149
 
150
-									if ( isset( $plugin_options[ $field['id'] ] ) && is_array( $plugin_options[ $field['id'] ] ) && ! empty( $plugin_options[ $field['id'] ] ) ) {
151
-										foreach ( $plugin_options[ $field['id'] ] as $key => $value ) {
150
+									if ( isset( $plugin_options[$field['id']] ) && is_array( $plugin_options[$field['id']] ) && ! empty( $plugin_options[$field['id']] ) ) {
151
+										foreach ( $plugin_options[$field['id']] as $key => $value ) {
152 152
 											$before = null;
153 153
 											$after  = null;
154 154
 
155
-											if ( isset( $plugin_options[ $field['id'] ][ $key ] ) && ( ! empty( $plugin_options[ $field['id'] ][ $key ] ) || '0' === $plugin_options[ $field['id'] ][ $key ] ) ) {
156
-												if ( is_array( $plugin_options[ $field['id'] ][ $key ] ) ) {
157
-													$before = $plugin_options[ $field['id'] ][ $key ];
155
+											if ( isset( $plugin_options[$field['id']][$key] ) && ( ! empty( $plugin_options[$field['id']][$key] ) || '0' === $plugin_options[$field['id']][$key] ) ) {
156
+												if ( is_array( $plugin_options[$field['id']][$key] ) ) {
157
+													$before = $plugin_options[$field['id']][$key];
158 158
 												} else {
159
-													$before = trim( $plugin_options[ $field['id'] ][ $key ] );
159
+													$before = trim( $plugin_options[$field['id']][$key] );
160 160
 												}
161 161
 											}
162 162
 
163
-											if ( isset( $options[ $field['id'] ][ $key ] ) && ( ! empty( $plugin_options[ $field['id'] ][ $key ] ) || '0' === $plugin_options[ $field['id'] ][ $key ] ) ) {
164
-												$after = $options[ $field['id'] ][ $key ];
163
+											if ( isset( $options[$field['id']][$key] ) && ( ! empty( $plugin_options[$field['id']][$key] ) || '0' === $plugin_options[$field['id']][$key] ) ) {
164
+												$after = $options[$field['id']][$key];
165 165
 											}
166 166
 
167 167
 											$validation = new $validate( $core, $field, $before, $after );
168 168
 
169 169
 											if ( ! empty( $validation->value ) || '0' === $validation->value ) {
170
-												$plugin_options[ $field['id'] ][ $key ] = $validation->value;
170
+												$plugin_options[$field['id']][$key] = $validation->value;
171 171
 											} else {
172
-												unset( $plugin_options[ $field['id'] ][ $key ] );
172
+												unset( $plugin_options[$field['id']][$key] );
173 173
 											}
174 174
 
175 175
 											if ( ! empty( $validation->error ) ) {
@@ -185,18 +185,18 @@  discard block
 block discarded – undo
185 185
 											}
186 186
 										}
187 187
 									} else {
188
-										if ( isset( $plugin_options[ $field['id'] ] ) ) {
189
-											if ( is_array( $plugin_options[ $field['id'] ] ) ) {
190
-												$pofi = $plugin_options[ $field['id'] ];
188
+										if ( isset( $plugin_options[$field['id']] ) ) {
189
+											if ( is_array( $plugin_options[$field['id']] ) ) {
190
+												$pofi = $plugin_options[$field['id']];
191 191
 											} else {
192
-												$pofi = trim( $plugin_options[ $field['id'] ] );
192
+												$pofi = trim( $plugin_options[$field['id']] );
193 193
 											}
194 194
 										} else {
195 195
 											$pofi = null;
196 196
 										}
197 197
 
198
-										$validation                     = new $validate( $core, $field, $pofi, $options[ $field['id'] ] );
199
-										$plugin_options[ $field['id'] ] = $validation->value;
198
+										$validation                     = new $validate( $core, $field, $pofi, $options[$field['id']] );
199
+										$plugin_options[$field['id']] = $validation->value;
200 200
 
201 201
 										if ( ! empty( $validation->error ) ) {
202 202
 											$core->errors[] = $validation->error;
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
 							$callback = $field['validate_callback'];
221 221
 							unset( $field['validate_callback'] );
222 222
 
223
-							$plugin_option = $plugin_options[ $field['id'] ] ?? null;
224
-							$option        = $options[ $field['id'] ] ?? null;
223
+							$plugin_option = $plugin_options[$field['id']] ?? null;
224
+							$option        = $options[$field['id']] ?? null;
225 225
 
226 226
 							if ( null !== $plugin_option ) {
227 227
 								$callbackvalues = call_user_func( $callback, $field, $plugin_option, $option );
228 228
 
229
-								$plugin_options[ $field['id'] ] = $callbackvalues['value'];
229
+								$plugin_options[$field['id']] = $callbackvalues['value'];
230 230
 
231 231
 								if ( isset( $callbackvalues['error'] ) ) {
232 232
 									$core->errors[] = $callbackvalues['error'];
Please login to merge, or discard this patch.