@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Fields API Control Class |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Fields_API |
|
7 | - * |
|
8 | - * @property array $choices Key/Values used by Multiple choice control types |
|
9 | - */ |
|
3 | + * Fields API Control Class |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Fields_API |
|
7 | + * |
|
8 | + * @property array $choices Key/Values used by Multiple choice control types |
|
9 | + */ |
|
10 | 10 | class WP_Fields_API_Control { |
11 | 11 | |
12 | 12 | /** |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | |
158 | 158 | $args = func_get_args(); |
159 | 159 | |
160 | - call_user_func_array( array( $this, 'init' ), $args ); |
|
160 | + call_user_func_array(array($this, 'init'), $args); |
|
161 | 161 | |
162 | 162 | } |
163 | 163 | |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @param string $id A specific ID of the control. |
169 | 169 | * @param array $args Control arguments. |
170 | 170 | */ |
171 | - public function init( $object_type, $id, $args = array() ) { |
|
171 | + public function init($object_type, $id, $args = array()) { |
|
172 | 172 | |
173 | 173 | /** |
174 | 174 | * @var $wp_fields WP_Fields_API |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | |
178 | 178 | $this->object_type = $object_type; |
179 | 179 | |
180 | - if ( is_array( $id ) ) { |
|
180 | + if (is_array($id)) { |
|
181 | 181 | $args = $id; |
182 | 182 | |
183 | 183 | $id = ''; |
@@ -185,40 +185,40 @@ discard block |
||
185 | 185 | $this->id = $id; |
186 | 186 | } |
187 | 187 | |
188 | - $keys = array_keys( get_object_vars( $this ) ); |
|
188 | + $keys = array_keys(get_object_vars($this)); |
|
189 | 189 | |
190 | - foreach ( $keys as $key ) { |
|
191 | - if ( isset( $args[ $key ] ) ) { |
|
192 | - $this->$key = $args[ $key ]; |
|
190 | + foreach ($keys as $key) { |
|
191 | + if (isset($args[$key])) { |
|
192 | + $this->$key = $args[$key]; |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | |
196 | - if ( empty( $this->active_callback ) ) { |
|
197 | - $this->active_callback = array( $this, 'active_callback' ); |
|
196 | + if (empty($this->active_callback)) { |
|
197 | + $this->active_callback = array($this, 'active_callback'); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | self::$instance_count += 1; |
201 | 201 | $this->instance_number = self::$instance_count; |
202 | 202 | |
203 | 203 | // Process fields. |
204 | - if ( empty( $this->fields ) ) { |
|
204 | + if (empty($this->fields)) { |
|
205 | 205 | $this->fields = $id; |
206 | 206 | } |
207 | 207 | |
208 | 208 | $fields = array(); |
209 | 209 | |
210 | - if ( is_array( $this->fields ) ) { |
|
211 | - foreach ( $this->fields as $key => $field ) { |
|
212 | - $field_obj = $wp_fields->get_field( $this->object_type, $field, $this->object_name ); |
|
210 | + if (is_array($this->fields)) { |
|
211 | + foreach ($this->fields as $key => $field) { |
|
212 | + $field_obj = $wp_fields->get_field($this->object_type, $field, $this->object_name); |
|
213 | 213 | |
214 | - if ( $field_obj ) { |
|
215 | - $fields[ $key ] = $field_obj; |
|
214 | + if ($field_obj) { |
|
215 | + $fields[$key] = $field_obj; |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | } else { |
219 | - $field_obj = $wp_fields->get_field( $this->object_type, $this->fields, $this->object_name ); |
|
219 | + $field_obj = $wp_fields->get_field($this->object_type, $this->fields, $this->object_name); |
|
220 | 220 | |
221 | - if ( $field_obj ) { |
|
221 | + if ($field_obj) { |
|
222 | 222 | $this->field = $field_obj; |
223 | 223 | $fields['default'] = $field_obj; |
224 | 224 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | */ |
234 | 234 | public function setup_choices() { |
235 | 235 | |
236 | - if ( ! isset( $this->choices ) ) { |
|
236 | + if ( ! isset($this->choices)) { |
|
237 | 237 | $choices = $this->choices(); |
238 | 238 | |
239 | 239 | $this->choices = $choices; |
@@ -267,8 +267,8 @@ discard block |
||
267 | 267 | $control = $this; |
268 | 268 | $active = true; |
269 | 269 | |
270 | - if ( is_callable( $this->active_callback ) ) { |
|
271 | - $active = call_user_func( $this->active_callback, $this ); |
|
270 | + if (is_callable($this->active_callback)) { |
|
271 | + $active = call_user_func($this->active_callback, $this); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * @param bool $active Whether the Field control is active. |
278 | 278 | * @param WP_Fields_API_Control $control WP_Fields_API_Control instance. |
279 | 279 | */ |
280 | - $active = apply_filters( 'fields_control_active_' . $this->object_type, $active, $control ); |
|
280 | + $active = apply_filters('fields_control_active_'.$this->object_type, $active, $control); |
|
281 | 281 | |
282 | 282 | return $active; |
283 | 283 | |
@@ -306,15 +306,15 @@ discard block |
||
306 | 306 | * @param string $field_key |
307 | 307 | * @return mixed The requested field's value, if the field exists. |
308 | 308 | */ |
309 | - final public function value( $field_key = 'default' ) { |
|
309 | + final public function value($field_key = 'default') { |
|
310 | 310 | |
311 | - if ( isset( $this->fields[ $field_key ] ) ) { |
|
311 | + if (isset($this->fields[$field_key])) { |
|
312 | 312 | /** |
313 | 313 | * @var $field WP_Fields_API_Field |
314 | 314 | */ |
315 | - $field = $this->fields[ $field_key ]; |
|
315 | + $field = $this->fields[$field_key]; |
|
316 | 316 | |
317 | - return $field->value( $this->item_id ); |
|
317 | + return $field->value($this->item_id); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | return null; |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | |
331 | 331 | $array = array(); |
332 | 332 | |
333 | - $array['fields'] = wp_list_pluck( $this->fields, 'id' ); |
|
333 | + $array['fields'] = wp_list_pluck($this->fields, 'id'); |
|
334 | 334 | $array['type'] = $this->type; |
335 | 335 | $array['priority'] = $this->priority; |
336 | 336 | $array['active'] = $this->active(); |
@@ -359,22 +359,22 @@ discard block |
||
359 | 359 | /** |
360 | 360 | * @var $field WP_Fields_API_Field |
361 | 361 | */ |
362 | - foreach ( $this->fields as $field ) { |
|
363 | - if ( ! $field || ! $field->check_capabilities() ) { |
|
362 | + foreach ($this->fields as $field) { |
|
363 | + if ( ! $field || ! $field->check_capabilities()) { |
|
364 | 364 | return false; |
365 | 365 | } |
366 | 366 | } |
367 | 367 | |
368 | - $section = $wp_fields->get_section( $this->object_type, $this->section, $this->object_name ); |
|
368 | + $section = $wp_fields->get_section($this->object_type, $this->section, $this->object_name); |
|
369 | 369 | |
370 | - if ( $section && ! $section->check_capabilities() ) { |
|
370 | + if ($section && ! $section->check_capabilities()) { |
|
371 | 371 | return false; |
372 | 372 | } |
373 | 373 | |
374 | 374 | $access = true; |
375 | 375 | |
376 | - if ( is_callable( $this->capabilities_callback ) ) { |
|
377 | - $access = call_user_func( $this->capabilities_callback, $this ); |
|
376 | + if (is_callable($this->capabilities_callback)) { |
|
377 | + $access = call_user_func($this->capabilities_callback, $this); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | return $access; |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | |
393 | 393 | $this->maybe_render(); |
394 | 394 | |
395 | - $template = trim( ob_get_clean() ); |
|
395 | + $template = trim(ob_get_clean()); |
|
396 | 396 | |
397 | 397 | return $template; |
398 | 398 | |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | */ |
406 | 406 | final public function maybe_render() { |
407 | 407 | |
408 | - if ( ! $this->check_capabilities() ) { |
|
408 | + if ( ! $this->check_capabilities()) { |
|
409 | 409 | return; |
410 | 410 | } |
411 | 411 | |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | * |
415 | 415 | * @param WP_Fields_API_Control $this WP_Fields_API_Control instance. |
416 | 416 | */ |
417 | - do_action( 'fields_render_control_' . $this->object_type, $this ); |
|
417 | + do_action('fields_render_control_'.$this->object_type, $this); |
|
418 | 418 | |
419 | 419 | /** |
420 | 420 | * Fires just before a specific control is rendered. |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * |
425 | 425 | * @param WP_Fields_API_Control $this {@see WP_Fields_API_Control} instance. |
426 | 426 | */ |
427 | - do_action( 'fields_render_control_' . $this->object_type . '_' . $this->object_name . '_' . $this->id, $this ); |
|
427 | + do_action('fields_render_control_'.$this->object_type.'_'.$this->object_name.'_'.$this->id, $this); |
|
428 | 428 | |
429 | 429 | $this->render(); |
430 | 430 | |
@@ -436,10 +436,10 @@ discard block |
||
436 | 436 | */ |
437 | 437 | protected function render() { |
438 | 438 | |
439 | - $id = 'fields-control-' . str_replace( '[', '-', str_replace( ']', '', $this->id ) ); |
|
440 | - $class = 'fields-control fields-control-' . $this->type; |
|
439 | + $id = 'fields-control-'.str_replace('[', '-', str_replace(']', '', $this->id)); |
|
440 | + $class = 'fields-control fields-control-'.$this->type; |
|
441 | 441 | |
442 | - ?><li id="<?php echo esc_attr( $id ); ?>" class="<?php echo esc_attr( $class ); ?>"> |
|
442 | + ?><li id="<?php echo esc_attr($id); ?>" class="<?php echo esc_attr($class); ?>"> |
|
443 | 443 | <?php $this->render_content(); ?> |
444 | 444 | </li><?php |
445 | 445 | |
@@ -452,13 +452,13 @@ discard block |
||
452 | 452 | * @param string $field_key |
453 | 453 | * @return string Data link parameter, if $field_key is a valid field, empty string otherwise. |
454 | 454 | */ |
455 | - public function get_link( $field_key = 'default' ) { |
|
455 | + public function get_link($field_key = 'default') { |
|
456 | 456 | |
457 | - if ( ! isset( $this->fields[ $field_key ] ) ) { |
|
457 | + if ( ! isset($this->fields[$field_key])) { |
|
458 | 458 | return ''; |
459 | 459 | } |
460 | 460 | |
461 | - return 'data-fields-field-link="' . esc_attr( $this->fields[ $field_key ]->id ) . '"'; |
|
461 | + return 'data-fields-field-link="'.esc_attr($this->fields[$field_key]->id).'"'; |
|
462 | 462 | |
463 | 463 | } |
464 | 464 | |
@@ -469,9 +469,9 @@ discard block |
||
469 | 469 | * |
470 | 470 | * @param string $field_key |
471 | 471 | */ |
472 | - public function link( $field_key = 'default' ) { |
|
472 | + public function link($field_key = 'default') { |
|
473 | 473 | |
474 | - echo $this->get_link( $field_key ); |
|
474 | + echo $this->get_link($field_key); |
|
475 | 475 | |
476 | 476 | } |
477 | 477 | |
@@ -482,8 +482,8 @@ discard block |
||
482 | 482 | */ |
483 | 483 | public function input_attrs() { |
484 | 484 | |
485 | - foreach ( $this->input_attrs as $attr => $value ) { |
|
486 | - echo $attr . '="' . esc_attr( $value ) . '" '; |
|
485 | + foreach ($this->input_attrs as $attr => $value) { |
|
486 | + echo $attr.'="'.esc_attr($value).'" '; |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | } |
@@ -502,13 +502,13 @@ discard block |
||
502 | 502 | |
503 | 503 | ?> |
504 | 504 | <label> |
505 | - <?php if ( ! empty( $this->label ) ) : ?> |
|
506 | - <span class="fields-control-title"><?php echo esc_html( $this->label ); ?></span> |
|
505 | + <?php if ( ! empty($this->label)) : ?> |
|
506 | + <span class="fields-control-title"><?php echo esc_html($this->label); ?></span> |
|
507 | 507 | <?php endif; |
508 | - if ( ! empty( $this->description ) ) : ?> |
|
508 | + if ( ! empty($this->description)) : ?> |
|
509 | 509 | <span class="description fields-control-description"><?php echo $this->description; ?></span> |
510 | 510 | <?php endif; ?> |
511 | - <input type="<?php echo esc_attr( $this->type ); ?>" <?php $this->input_attrs(); ?> value="<?php echo esc_attr( $this->value( $this->item_id ) ); ?>" <?php $this->link(); ?> /> |
|
511 | + <input type="<?php echo esc_attr($this->type); ?>" <?php $this->input_attrs(); ?> value="<?php echo esc_attr($this->value($this->item_id)); ?>" <?php $this->link(); ?> /> |
|
512 | 512 | </label> |
513 | 513 | <?php |
514 | 514 | |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | public function print_template() { |
527 | 527 | |
528 | 528 | ?> |
529 | - <script type="text/html" id="tmpl-fields-<?php echo esc_attr( $this->object_type ); ?>-control-<?php echo esc_attr( $this->type ); ?>-content"> |
|
529 | + <script type="text/html" id="tmpl-fields-<?php echo esc_attr($this->object_type); ?>-control-<?php echo esc_attr($this->type); ?>-content"> |
|
530 | 530 | <?php $this->content_template(); ?> |
531 | 531 | </script> |
532 | 532 | <?php |
@@ -554,10 +554,10 @@ discard block |
||
554 | 554 | * |
555 | 555 | * @return mixed|null |
556 | 556 | */ |
557 | - public function &__get( $name ) { |
|
557 | + public function &__get($name) { |
|
558 | 558 | |
559 | 559 | // Map $this->choices to $this->choices() for dynamic choice handling |
560 | - if ( 'choices' == $name ) { |
|
560 | + if ('choices' == $name) { |
|
561 | 561 | $this->setup_choices(); |
562 | 562 | |
563 | 563 | return $this->choices; |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | $args = func_get_args(); |
158 | 158 | |
159 | - call_user_func_array( array( $this, 'init' ), $args ); |
|
159 | + call_user_func_array(array($this, 'init'), $args); |
|
160 | 160 | |
161 | 161 | } |
162 | 162 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * @param string $id A specific ID of the section. |
168 | 168 | * @param array $args Section arguments. |
169 | 169 | */ |
170 | - public function init( $object_type, $id, $args = array() ) { |
|
170 | + public function init($object_type, $id, $args = array()) { |
|
171 | 171 | |
172 | 172 | /** |
173 | 173 | * @var $wp_fields WP_Fields_API |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | $this->object_type = $object_type; |
178 | 178 | |
179 | - if ( is_array( $id ) ) { |
|
179 | + if (is_array($id)) { |
|
180 | 180 | $args = $id; |
181 | 181 | |
182 | 182 | $id = ''; |
@@ -184,19 +184,19 @@ discard block |
||
184 | 184 | $this->id = $id; |
185 | 185 | } |
186 | 186 | |
187 | - $keys = array_keys( get_object_vars( $this ) ); |
|
187 | + $keys = array_keys(get_object_vars($this)); |
|
188 | 188 | |
189 | - foreach ( $keys as $key ) { |
|
190 | - if ( isset( $args[ $key ] ) ) { |
|
191 | - $this->$key = $args[ $key ]; |
|
189 | + foreach ($keys as $key) { |
|
190 | + if (isset($args[$key])) { |
|
191 | + $this->$key = $args[$key]; |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
195 | 195 | self::$instance_count += 1; |
196 | 196 | $this->instance_number = self::$instance_count; |
197 | 197 | |
198 | - if ( empty( $this->active_callback ) ) { |
|
199 | - $this->active_callback = array( $this, 'active_callback' ); |
|
198 | + if (empty($this->active_callback)) { |
|
199 | + $this->active_callback = array($this, 'active_callback'); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /*if ( $this->screen ) { |
@@ -224,8 +224,8 @@ discard block |
||
224 | 224 | $section = $this; |
225 | 225 | $active = true; |
226 | 226 | |
227 | - if ( is_callable( $this->active_callback ) ) { |
|
228 | - $active = call_user_func( $this->active_callback, $this ); |
|
227 | + if (is_callable($this->active_callback)) { |
|
228 | + $active = call_user_func($this->active_callback, $this); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * @param bool $active Whether the Fields API section is active. |
235 | 235 | * @param WP_Fields_API_Section $section {@see WP_Fields_API_Section} instance. |
236 | 236 | */ |
237 | - $active = apply_filters( 'fields_api_section_active_' . $this->object_type, $active, $section ); |
|
237 | + $active = apply_filters('fields_api_section_active_'.$this->object_type, $active, $section); |
|
238 | 238 | |
239 | 239 | return $active; |
240 | 240 | |
@@ -264,8 +264,8 @@ discard block |
||
264 | 264 | */ |
265 | 265 | public function json() { |
266 | 266 | |
267 | - $array = wp_array_slice_assoc( (array) $this, array( 'id', 'description', 'priority', 'screen', 'type' ) ); |
|
268 | - $array['title'] = html_entity_decode( $this->title, ENT_QUOTES, get_bloginfo( 'charset' ) ); |
|
267 | + $array = wp_array_slice_assoc((array) $this, array('id', 'description', 'priority', 'screen', 'type')); |
|
268 | + $array['title'] = html_entity_decode($this->title, ENT_QUOTES, get_bloginfo('charset')); |
|
269 | 269 | $array['content'] = $this->get_content(); |
270 | 270 | $array['active'] = $this->active(); |
271 | 271 | $array['instanceNumber'] = $this->instance_number; |
@@ -282,18 +282,18 @@ discard block |
||
282 | 282 | */ |
283 | 283 | public function check_capabilities() { |
284 | 284 | |
285 | - if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) ) { |
|
285 | + if ($this->capability && ! call_user_func_array('current_user_can', (array) $this->capability)) { |
|
286 | 286 | return false; |
287 | 287 | } |
288 | 288 | |
289 | - if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) ) { |
|
289 | + if ($this->theme_supports && ! call_user_func_array('current_theme_supports', (array) $this->theme_supports)) { |
|
290 | 290 | return false; |
291 | 291 | } |
292 | 292 | |
293 | 293 | $access = true; |
294 | 294 | |
295 | - if ( is_callable( $this->capabilities_callback ) ) { |
|
296 | - $access = call_user_func( $this->capabilities_callback, $this ); |
|
295 | + if (is_callable($this->capabilities_callback)) { |
|
296 | + $access = call_user_func($this->capabilities_callback, $this); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | return $access; |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | |
312 | 312 | $this->maybe_render(); |
313 | 313 | |
314 | - $template = trim( ob_get_contents() ); |
|
314 | + $template = trim(ob_get_contents()); |
|
315 | 315 | |
316 | 316 | ob_end_clean(); |
317 | 317 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | */ |
325 | 325 | final public function maybe_render() { |
326 | 326 | |
327 | - if ( ! $this->check_capabilities() ) { |
|
327 | + if ( ! $this->check_capabilities()) { |
|
328 | 328 | return; |
329 | 329 | } |
330 | 330 | |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | * |
337 | 337 | * @param WP_Fields_API_Section $this WP_Fields API_Section instance. |
338 | 338 | */ |
339 | - do_action( "fields_api_render_section_{$this->object_type}", $this ); |
|
339 | + do_action("fields_api_render_section_{$this->object_type}", $this); |
|
340 | 340 | |
341 | 341 | /** |
342 | 342 | * Fires before rendering a specific Fields API section. |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | * of the specific Fields API section to be rendered. |
349 | 349 | * |
350 | 350 | */ |
351 | - do_action( "fields_api_render_section_{$this->object_type}_{$this->object_name}_{$this->id}" ); |
|
351 | + do_action("fields_api_render_section_{$this->object_type}_{$this->object_name}_{$this->id}"); |
|
352 | 352 | |
353 | 353 | $this->render(); |
354 | 354 | |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * // @todo Merge render_template / print_template() from Customizer |
361 | 361 | */ |
362 | 362 | protected function render() { |
363 | - echo esc_html( $this->title ); |
|
363 | + echo esc_html($this->title); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | /** |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | |
150 | 150 | $args = func_get_args(); |
151 | 151 | |
152 | - call_user_func_array( array( $this, 'init' ), $args ); |
|
152 | + call_user_func_array(array($this, 'init'), $args); |
|
153 | 153 | |
154 | 154 | } |
155 | 155 | |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | * @param string $id A specific ID of the screen. |
161 | 161 | * @param array $args Screen arguments. |
162 | 162 | */ |
163 | - public function init( $object_type, $id, $args = array() ) { |
|
163 | + public function init($object_type, $id, $args = array()) { |
|
164 | 164 | |
165 | 165 | $this->object_type = $object_type; |
166 | 166 | |
167 | - if ( is_array( $id ) ) { |
|
167 | + if (is_array($id)) { |
|
168 | 168 | $args = $id; |
169 | 169 | |
170 | 170 | $id = ''; |
@@ -172,19 +172,19 @@ discard block |
||
172 | 172 | $this->id = $id; |
173 | 173 | } |
174 | 174 | |
175 | - $keys = array_keys( get_object_vars( $this ) ); |
|
175 | + $keys = array_keys(get_object_vars($this)); |
|
176 | 176 | |
177 | - foreach ( $keys as $key ) { |
|
178 | - if ( isset( $args[ $key ] ) ) { |
|
179 | - $this->$key = $args[ $key ]; |
|
177 | + foreach ($keys as $key) { |
|
178 | + if (isset($args[$key])) { |
|
179 | + $this->$key = $args[$key]; |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | |
183 | 183 | self::$instance_count += 1; |
184 | 184 | $this->instance_number = self::$instance_count; |
185 | 185 | |
186 | - if ( empty( $this->active_callback ) ) { |
|
187 | - $this->active_callback = array( $this, 'active_callback' ); |
|
186 | + if (empty($this->active_callback)) { |
|
187 | + $this->active_callback = array($this, 'active_callback'); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | $this->sections = array(); // Users cannot customize the $sections array. |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | $screen = $this; |
204 | 204 | $active = true; |
205 | 205 | |
206 | - if ( is_callable( $this->active_callback ) ) { |
|
207 | - $active = call_user_func( $this->active_callback, $this ); |
|
206 | + if (is_callable($this->active_callback)) { |
|
207 | + $active = call_user_func($this->active_callback, $this); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * @param bool $active Whether the Fields API screen is active. |
215 | 215 | * @param WP_Fields_API_Screen $screen {@see WP_Fields_API_Screen} instance. |
216 | 216 | */ |
217 | - $active = apply_filters( 'fields_api_screen_active_' . $this->object_type, $active, $screen ); |
|
217 | + $active = apply_filters('fields_api_screen_active_'.$this->object_type, $active, $screen); |
|
218 | 218 | |
219 | 219 | return $active; |
220 | 220 | |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | */ |
244 | 244 | public function json() { |
245 | 245 | |
246 | - $array = wp_array_slice_assoc( (array) $this, array( 'id', 'title', 'description', 'priority', 'type' ) ); |
|
246 | + $array = wp_array_slice_assoc((array) $this, array('id', 'title', 'description', 'priority', 'type')); |
|
247 | 247 | |
248 | 248 | $array['content'] = $this->get_content(); |
249 | 249 | $array['active'] = $this->active(); |
@@ -261,18 +261,18 @@ discard block |
||
261 | 261 | */ |
262 | 262 | public function check_capabilities() { |
263 | 263 | |
264 | - if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) ) { |
|
264 | + if ($this->capability && ! call_user_func_array('current_user_can', (array) $this->capability)) { |
|
265 | 265 | return false; |
266 | 266 | } |
267 | 267 | |
268 | - if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) ) { |
|
268 | + if ($this->theme_supports && ! call_user_func_array('current_theme_supports', (array) $this->theme_supports)) { |
|
269 | 269 | return false; |
270 | 270 | } |
271 | 271 | |
272 | 272 | $access = true; |
273 | 273 | |
274 | - if ( is_callable( $this->capabilities_callback ) ) { |
|
275 | - $access = call_user_func( $this->capabilities_callback, $this ); |
|
274 | + if (is_callable($this->capabilities_callback)) { |
|
275 | + $access = call_user_func($this->capabilities_callback, $this); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | return $access; |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | |
291 | 291 | $this->maybe_render(); |
292 | 292 | |
293 | - $template = trim( ob_get_contents() ); |
|
293 | + $template = trim(ob_get_contents()); |
|
294 | 294 | |
295 | 295 | ob_end_clean(); |
296 | 296 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | */ |
305 | 305 | final public function maybe_render() { |
306 | 306 | |
307 | - if ( ! $this->check_capabilities() ) { |
|
307 | + if ( ! $this->check_capabilities()) { |
|
308 | 308 | return; |
309 | 309 | } |
310 | 310 | |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | * |
314 | 314 | * @param WP_Fields_API_Screen $this WP_Fields_API_Screen instance. |
315 | 315 | */ |
316 | - do_action( "fields_api_render_screen_{$this->object_type}", $this ); |
|
316 | + do_action("fields_api_render_screen_{$this->object_type}", $this); |
|
317 | 317 | |
318 | 318 | /** |
319 | 319 | * Fires before rendering a specific Fields API screen. |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | * The dynamic portion of the hook name, `$this->id`, refers to |
322 | 322 | * the ID of the specific Fields API screen to be rendered. |
323 | 323 | */ |
324 | - do_action( "fields_api_render_screen_{$this->object_type}_{$this->object_name}_{$this->id}" ); |
|
324 | + do_action("fields_api_render_screen_{$this->object_type}_{$this->object_name}_{$this->id}"); |
|
325 | 325 | |
326 | 326 | $this->render(); |
327 | 327 | |
@@ -333,12 +333,12 @@ discard block |
||
333 | 333 | * @access protected |
334 | 334 | */ |
335 | 335 | protected function render() { |
336 | - $classes = 'accordion-section control-section control-screen control-screen-' . $this->type; |
|
336 | + $classes = 'accordion-section control-section control-screen control-screen-'.$this->type; |
|
337 | 337 | ?> |
338 | - <li id="accordion-screen-<?php echo esc_attr( $this->id ); ?>" class="<?php echo esc_attr( $classes ); ?>"> |
|
338 | + <li id="accordion-screen-<?php echo esc_attr($this->id); ?>" class="<?php echo esc_attr($classes); ?>"> |
|
339 | 339 | <h3 class="accordion-section-title" tabindex="0"> |
340 | - <?php echo esc_html( $this->title ); ?> |
|
341 | - <span class="screen-reader-text"><?php _e( 'Press return or enter to open this screen' ); ?></span> |
|
340 | + <?php echo esc_html($this->title); ?> |
|
341 | + <span class="screen-reader-text"><?php _e('Press return or enter to open this screen'); ?></span> |
|
342 | 342 | </h3> |
343 | 343 | <ul class="accordion-sub-container control-screen-content"> |
344 | 344 | <?php $this->render_content(); ?> |
@@ -401,14 +401,14 @@ discard block |
||
401 | 401 | */ |
402 | 402 | protected function render_content() { |
403 | 403 | ?> |
404 | - <li class="screen-meta accordion-section control-section<?php if ( empty( $this->description ) ) { echo ' cannot-expand'; } ?>"> |
|
404 | + <li class="screen-meta accordion-section control-section<?php if (empty($this->description)) { echo ' cannot-expand'; } ?>"> |
|
405 | 405 | <div class="accordion-section-title" tabindex="0"> |
406 | 406 | <span class="preview-notice"><?php |
407 | 407 | /* translators: %s is the site/screen title in the Fields API */ |
408 | - printf( __( 'You are editing %s' ), '<strong class="screen-title">' . esc_html( $this->title ) . '</strong>' ); |
|
408 | + printf(__('You are editing %s'), '<strong class="screen-title">'.esc_html($this->title).'</strong>'); |
|
409 | 409 | ?></span> |
410 | 410 | </div> |
411 | - <?php if ( ! empty( $this->description ) ) : ?> |
|
411 | + <?php if ( ! empty($this->description)) : ?> |
|
412 | 412 | <div class="accordion-section-content description"> |
413 | 413 | <?php echo $this->description; ?> |
414 | 414 | </div> |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | $args = func_get_args(); |
89 | 89 | |
90 | - call_user_func_array( array( $this, 'init' ), $args ); |
|
90 | + call_user_func_array(array($this, 'init'), $args); |
|
91 | 91 | |
92 | 92 | } |
93 | 93 | |
@@ -101,11 +101,11 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return WP_Fields_API_Field $field |
103 | 103 | */ |
104 | - public function init( $object_type, $id, $args = array() ) { |
|
104 | + public function init($object_type, $id, $args = array()) { |
|
105 | 105 | |
106 | 106 | $this->object_type = $object_type; |
107 | 107 | |
108 | - if ( is_array( $id ) ) { |
|
108 | + if (is_array($id)) { |
|
109 | 109 | $args = $id; |
110 | 110 | |
111 | 111 | $id = ''; |
@@ -113,31 +113,31 @@ discard block |
||
113 | 113 | $this->id = $id; |
114 | 114 | } |
115 | 115 | |
116 | - $keys = array_keys( get_object_vars( $this ) ); |
|
116 | + $keys = array_keys(get_object_vars($this)); |
|
117 | 117 | |
118 | - foreach ( $keys as $key ) { |
|
119 | - if ( isset( $args[ $key ] ) ) { |
|
120 | - $this->$key = $args[ $key ]; |
|
118 | + foreach ($keys as $key) { |
|
119 | + if (isset($args[$key])) { |
|
120 | + $this->$key = $args[$key]; |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 | |
124 | 124 | // Parse the ID for array keys. |
125 | - $this->id_data['keys'] = preg_split( '/\[/', str_replace( ']', '', $this->id ) ); |
|
126 | - $this->id_data['base'] = array_shift( $this->id_data['keys'] ); |
|
125 | + $this->id_data['keys'] = preg_split('/\[/', str_replace(']', '', $this->id)); |
|
126 | + $this->id_data['base'] = array_shift($this->id_data['keys']); |
|
127 | 127 | |
128 | 128 | // Rebuild the ID. |
129 | 129 | $this->id = $this->id_data['base']; |
130 | 130 | |
131 | - if ( ! empty( $this->id_data['keys'] ) ) { |
|
132 | - $this->id .= '[' . implode( '][', $this->id_data['keys'] ) . ']'; |
|
131 | + if ( ! empty($this->id_data['keys'])) { |
|
132 | + $this->id .= '['.implode('][', $this->id_data['keys']).']'; |
|
133 | 133 | } |
134 | 134 | |
135 | - if ( $this->sanitize_callback ) { |
|
136 | - add_filter( "fields_sanitize_{$this->object_type}_{$this->object_name}_{$this->id}", $this->sanitize_callback, 10, 2 ); |
|
135 | + if ($this->sanitize_callback) { |
|
136 | + add_filter("fields_sanitize_{$this->object_type}_{$this->object_name}_{$this->id}", $this->sanitize_callback, 10, 2); |
|
137 | 137 | } |
138 | 138 | |
139 | - if ( $this->sanitize_js_callback ) { |
|
140 | - add_filter( "fields_sanitize_js_{$this->object_type}_{$this->object_name}_{$this->id}", $this->sanitize_js_callback, 10, 2 ); |
|
139 | + if ($this->sanitize_js_callback) { |
|
140 | + add_filter("fields_sanitize_js_{$this->object_type}_{$this->object_name}_{$this->id}", $this->sanitize_js_callback, 10, 2); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $value = func_get_arg(0); |
157 | 157 | $item_id = func_get_arg(1); |
158 | 158 | |
159 | - if ( ! $this->check_capabilities() || false === $value ) { |
|
159 | + if ( ! $this->check_capabilities() || false === $value) { |
|
160 | 160 | return false; |
161 | 161 | } |
162 | 162 | |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @param WP_Fields_API_Field $this {@see WP_Fields_API_Field} instance. |
172 | 172 | */ |
173 | - do_action( 'field_save_' . $this->object_type . ' _' . $this->id_data[ 'base' ], $this, $value, $item_id ); |
|
173 | + do_action('field_save_'.$this->object_type.' _'.$this->id_data['base'], $this, $value, $item_id); |
|
174 | 174 | |
175 | - return $this->update( $value, $item_id ); |
|
175 | + return $this->update($value, $item_id); |
|
176 | 176 | |
177 | 177 | } |
178 | 178 | |
@@ -183,9 +183,9 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @return mixed Null if an input isn't valid, otherwise the sanitized value. |
185 | 185 | */ |
186 | - public function sanitize( $value ) { |
|
186 | + public function sanitize($value) { |
|
187 | 187 | |
188 | - $value = wp_unslash( $value ); |
|
188 | + $value = wp_unslash($value); |
|
189 | 189 | |
190 | 190 | /** |
191 | 191 | * Filter a Customize field value in un-slashed form. |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * @param mixed $value Value of the field. |
194 | 194 | * @param WP_Fields_API_Field $this WP_Fields_API_Field instance. |
195 | 195 | */ |
196 | - return apply_filters( "fields_sanitize_{$this->object_type}_{$this->object_name}_{$this->id}", $value, $this ); |
|
196 | + return apply_filters("fields_sanitize_{$this->object_type}_{$this->object_name}_{$this->id}", $value, $this); |
|
197 | 197 | |
198 | 198 | } |
199 | 199 | |
@@ -205,24 +205,24 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @return mixed The result of saving the value. |
207 | 207 | */ |
208 | - protected function update( $value ) { |
|
208 | + protected function update($value) { |
|
209 | 209 | |
210 | 210 | // @todo Support post / term / user / comment object field updates |
211 | 211 | |
212 | 212 | $item_id = func_get_arg(1); |
213 | 213 | |
214 | - switch ( $this->object_type ) { |
|
214 | + switch ($this->object_type) { |
|
215 | 215 | case 'customizer' : |
216 | - return $this->_update_theme_mod( $value ); |
|
216 | + return $this->_update_theme_mod($value); |
|
217 | 217 | |
218 | 218 | case 'settings' : |
219 | - return $this->_update_option( $value ); |
|
219 | + return $this->_update_option($value); |
|
220 | 220 | |
221 | 221 | case 'post' : |
222 | 222 | case 'term' : |
223 | 223 | case 'user' : |
224 | 224 | case 'comment' : |
225 | - return $this->_update_meta( $this->object_type, $value, $item_id ); |
|
225 | + return $this->_update_meta($this->object_type, $value, $item_id); |
|
226 | 226 | |
227 | 227 | default : |
228 | 228 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * @param int $item_id Item ID. |
237 | 237 | * @param WP_Fields_API_Field $this WP_Fields_API_Field instance. |
238 | 238 | */ |
239 | - do_action( "fields_update_{$this->object_type}", $value, $item_id, $this ); |
|
239 | + do_action("fields_update_{$this->object_type}", $value, $item_id, $this); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | return null; |
@@ -250,22 +250,22 @@ discard block |
||
250 | 250 | * |
251 | 251 | * @return null |
252 | 252 | */ |
253 | - protected function _update_theme_mod( $value ) { |
|
253 | + protected function _update_theme_mod($value) { |
|
254 | 254 | |
255 | - if ( is_null( $value ) ) { |
|
256 | - remove_theme_mod( $this->id_data['base'] ); |
|
255 | + if (is_null($value)) { |
|
256 | + remove_theme_mod($this->id_data['base']); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | // Handle non-array theme mod. |
260 | - if ( empty( $this->id_data['keys'] ) ) { |
|
261 | - set_theme_mod( $this->id_data['base'], $value ); |
|
260 | + if (empty($this->id_data['keys'])) { |
|
261 | + set_theme_mod($this->id_data['base'], $value); |
|
262 | 262 | } else { |
263 | 263 | // Handle array-based theme mod. |
264 | - $mods = get_theme_mod( $this->id_data['base'] ); |
|
265 | - $mods = $this->multidimensional_replace( $mods, $this->id_data['keys'], $value ); |
|
264 | + $mods = get_theme_mod($this->id_data['base']); |
|
265 | + $mods = $this->multidimensional_replace($mods, $this->id_data['keys'], $value); |
|
266 | 266 | |
267 | - if ( isset( $mods ) ) { |
|
268 | - set_theme_mod( $this->id_data['base'], $mods ); |
|
267 | + if (isset($mods)) { |
|
268 | + set_theme_mod($this->id_data['base'], $mods); |
|
269 | 269 | } |
270 | 270 | } |
271 | 271 | |
@@ -280,23 +280,23 @@ discard block |
||
280 | 280 | * |
281 | 281 | * @return bool|null The result of saving the value. |
282 | 282 | */ |
283 | - protected function _update_option( $value ) { |
|
283 | + protected function _update_option($value) { |
|
284 | 284 | |
285 | - if ( is_null( $value ) ) { |
|
286 | - delete_option( $this->id_data['base'] ); |
|
285 | + if (is_null($value)) { |
|
286 | + delete_option($this->id_data['base']); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | // Handle non-array option. |
290 | - if ( empty( $this->id_data['keys'] ) ) { |
|
291 | - return update_option( $this->id_data['base'], $value ); |
|
290 | + if (empty($this->id_data['keys'])) { |
|
291 | + return update_option($this->id_data['base'], $value); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | // Handle array-based options. |
295 | - $options = get_option( $this->id_data['base'] ); |
|
296 | - $options = $this->multidimensional_replace( $options, $this->id_data['keys'], $value ); |
|
295 | + $options = get_option($this->id_data['base']); |
|
296 | + $options = $this->multidimensional_replace($options, $this->id_data['keys'], $value); |
|
297 | 297 | |
298 | - if ( isset( $options ) ) { |
|
299 | - return update_option( $this->id_data['base'], $options ); |
|
298 | + if (isset($options)) { |
|
299 | + return update_option($this->id_data['base'], $options); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | return null; |
@@ -312,23 +312,23 @@ discard block |
||
312 | 312 | * |
313 | 313 | * @return bool|null The result of saving the value. |
314 | 314 | */ |
315 | - protected function _update_meta( $meta_type, $value, $item_id = 0 ) { |
|
315 | + protected function _update_meta($meta_type, $value, $item_id = 0) { |
|
316 | 316 | |
317 | - if ( is_null( $value ) ) { |
|
318 | - delete_metadata( $meta_type, $item_id, $this->id_data['base'] ); |
|
317 | + if (is_null($value)) { |
|
318 | + delete_metadata($meta_type, $item_id, $this->id_data['base']); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | // Handle non-array option. |
322 | - if ( empty( $this->id_data['keys'] ) ) { |
|
323 | - return update_metadata( $meta_type, $item_id, $this->id_data['base'], $value ); |
|
322 | + if (empty($this->id_data['keys'])) { |
|
323 | + return update_metadata($meta_type, $item_id, $this->id_data['base'], $value); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | // Handle array-based keys. |
327 | - $keys = get_metadata( $meta_type, 0, $this->id_data['base'] ); |
|
328 | - $keys = $this->multidimensional_replace( $keys, $this->id_data['keys'], $value ); |
|
327 | + $keys = get_metadata($meta_type, 0, $this->id_data['base']); |
|
328 | + $keys = $this->multidimensional_replace($keys, $this->id_data['keys'], $value); |
|
329 | 329 | |
330 | - if ( isset( $keys ) ) { |
|
331 | - return update_metadata( $meta_type, $item_id, $this->id_data['base'], $keys ); |
|
330 | + if (isset($keys)) { |
|
331 | + return update_metadata($meta_type, $item_id, $this->id_data['base'], $keys); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | return null; |
@@ -346,19 +346,19 @@ discard block |
||
346 | 346 | |
347 | 347 | $item_id = func_get_arg(0); |
348 | 348 | |
349 | - switch ( $this->object_type ) { |
|
349 | + switch ($this->object_type) { |
|
350 | 350 | case 'post' : |
351 | 351 | case 'term' : |
352 | 352 | case 'user' : |
353 | 353 | case 'comment' : |
354 | - $value = $this->get_object_value( $item_id ); |
|
355 | - $value = $this->multidimensional_get( $value, $this->id_data['keys'], $this->default ); |
|
354 | + $value = $this->get_object_value($item_id); |
|
355 | + $value = $this->multidimensional_get($value, $this->id_data['keys'], $this->default); |
|
356 | 356 | break; |
357 | 357 | |
358 | 358 | case 'customizer' : |
359 | 359 | case 'settings' : |
360 | 360 | $value = $this->get_option_value(); |
361 | - $value = $this->multidimensional_get( $value, $this->id_data['keys'], $this->default ); |
|
361 | + $value = $this->multidimensional_get($value, $this->id_data['keys'], $this->default); |
|
362 | 362 | break; |
363 | 363 | |
364 | 364 | default : |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | * @param mixed $default The field default value. Default empty. |
375 | 375 | * @param int $item_id (optional) The Item ID. |
376 | 376 | */ |
377 | - $value = apply_filters( 'fields_value_' . $this->object_type . '_' . $this->object_name . '_' . $this->id_data['base'], $this->default, $item_id ); |
|
377 | + $value = apply_filters('fields_value_'.$this->object_type.'_'.$this->object_name.'_'.$this->id_data['base'], $this->default, $item_id); |
|
378 | 378 | break; |
379 | 379 | } |
380 | 380 | |
@@ -389,37 +389,37 @@ discard block |
||
389 | 389 | * |
390 | 390 | * @return mixed|null |
391 | 391 | */ |
392 | - public function get_object_value( $item_id ) { |
|
392 | + public function get_object_value($item_id) { |
|
393 | 393 | |
394 | 394 | $value = null; |
395 | 395 | $object = null; |
396 | 396 | |
397 | 397 | $field_key = $this->id_data['base']; |
398 | 398 | |
399 | - switch ( $this->object_type ) { |
|
399 | + switch ($this->object_type) { |
|
400 | 400 | case 'post' : |
401 | - $object = get_post( $item_id ); |
|
401 | + $object = get_post($item_id); |
|
402 | 402 | break; |
403 | 403 | |
404 | 404 | case 'term' : |
405 | - $object = get_term( $item_id ); |
|
405 | + $object = get_term($item_id); |
|
406 | 406 | break; |
407 | 407 | |
408 | 408 | case 'user' : |
409 | - $object = get_userdata( $item_id ); |
|
409 | + $object = get_userdata($item_id); |
|
410 | 410 | break; |
411 | 411 | |
412 | 412 | case 'comment' : |
413 | - $object = get_comment( $item_id ); |
|
413 | + $object = get_comment($item_id); |
|
414 | 414 | break; |
415 | 415 | } |
416 | 416 | |
417 | - if ( $object && ! is_wp_error( $object ) && isset( $object->{$field_key} ) ) { |
|
417 | + if ($object && ! is_wp_error($object) && isset($object->{$field_key} )) { |
|
418 | 418 | // Get value from object |
419 | 419 | $value = $object->{$field_key}; |
420 | 420 | } else { |
421 | 421 | // Get value from meta |
422 | - $value = get_metadata( $this->object_type, $item_id, $field_key ); |
|
422 | + $value = get_metadata($this->object_type, $item_id, $field_key); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | return $value; |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | $function = ''; |
437 | 437 | $value = null; |
438 | 438 | |
439 | - switch ( $this->object_type ) { |
|
439 | + switch ($this->object_type) { |
|
440 | 440 | case 'customizer' : |
441 | 441 | $function = 'get_theme_mod'; |
442 | 442 | break; |
@@ -446,14 +446,14 @@ discard block |
||
446 | 446 | break; |
447 | 447 | } |
448 | 448 | |
449 | - if ( is_callable( $function ) ) { |
|
449 | + if (is_callable($function)) { |
|
450 | 450 | // Handle non-array value |
451 | - if ( empty( $this->id_data['keys'] ) ) { |
|
452 | - return $function( $this->id_data['base'], $this->default ); |
|
451 | + if (empty($this->id_data['keys'])) { |
|
452 | + return $function($this->id_data['base'], $this->default); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | // Handle array-based value |
456 | - $value = $function( $this->id_data['base'] ); |
|
456 | + $value = $function($this->id_data['base']); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | return $value; |
@@ -477,10 +477,10 @@ discard block |
||
477 | 477 | * @param mixed $value The field value. |
478 | 478 | * @param WP_Fields_API_Field $this {@see WP_Fields_API_Field} instance. |
479 | 479 | */ |
480 | - $value = apply_filters( "fields_sanitize_js_{$this->object_type}_{$this->object_name}_{$this->id}", $value, $this ); |
|
480 | + $value = apply_filters("fields_sanitize_js_{$this->object_type}_{$this->object_name}_{$this->id}", $value, $this); |
|
481 | 481 | |
482 | - if ( is_string( $value ) ) { |
|
483 | - return html_entity_decode( $value, ENT_QUOTES, 'UTF-8' ); |
|
482 | + if (is_string($value)) { |
|
483 | + return html_entity_decode($value, ENT_QUOTES, 'UTF-8'); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | return $value; |
@@ -494,18 +494,18 @@ discard block |
||
494 | 494 | */ |
495 | 495 | public function check_capabilities() { |
496 | 496 | |
497 | - if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) ) { |
|
497 | + if ($this->capability && ! call_user_func_array('current_user_can', (array) $this->capability)) { |
|
498 | 498 | return false; |
499 | 499 | } |
500 | 500 | |
501 | - if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) ) { |
|
501 | + if ($this->theme_supports && ! call_user_func_array('current_theme_supports', (array) $this->theme_supports)) { |
|
502 | 502 | return false; |
503 | 503 | } |
504 | 504 | |
505 | 505 | $access = true; |
506 | 506 | |
507 | - if ( is_callable( $this->capabilities_callback ) ) { |
|
508 | - $access = call_user_func( $this->capabilities_callback, $this ); |
|
507 | + if (is_callable($this->capabilities_callback)) { |
|
508 | + $access = call_user_func($this->capabilities_callback, $this); |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | return $access; |
@@ -521,42 +521,42 @@ discard block |
||
521 | 521 | * |
522 | 522 | * @return null|array Keys are 'root', 'node', and 'key'. |
523 | 523 | */ |
524 | - final protected function multidimensional( &$root, $keys, $create = false ) { |
|
524 | + final protected function multidimensional(&$root, $keys, $create = false) { |
|
525 | 525 | |
526 | - if ( $create && empty( $root ) ) { |
|
526 | + if ($create && empty($root)) { |
|
527 | 527 | $root = array(); |
528 | 528 | } |
529 | 529 | |
530 | - if ( ! isset( $root ) || empty( $keys ) ) { |
|
530 | + if ( ! isset($root) || empty($keys)) { |
|
531 | 531 | return null; |
532 | 532 | } |
533 | 533 | |
534 | - $last = array_pop( $keys ); |
|
534 | + $last = array_pop($keys); |
|
535 | 535 | $node = &$root; |
536 | 536 | |
537 | - foreach ( $keys as $key ) { |
|
538 | - if ( $create && ! isset( $node[ $key ] ) ) { |
|
539 | - $node[ $key ] = array(); |
|
537 | + foreach ($keys as $key) { |
|
538 | + if ($create && ! isset($node[$key])) { |
|
539 | + $node[$key] = array(); |
|
540 | 540 | } |
541 | 541 | |
542 | - if ( ! is_array( $node ) || ! isset( $node[ $key ] ) ) { |
|
542 | + if ( ! is_array($node) || ! isset($node[$key])) { |
|
543 | 543 | return null; |
544 | 544 | } |
545 | 545 | |
546 | - $node = &$node[ $key ]; |
|
546 | + $node = &$node[$key]; |
|
547 | 547 | } |
548 | 548 | |
549 | - if ( $create ) { |
|
550 | - if ( ! is_array( $node ) ) { |
|
549 | + if ($create) { |
|
550 | + if ( ! is_array($node)) { |
|
551 | 551 | // account for an array overriding a string or object value |
552 | 552 | $node = array(); |
553 | 553 | } |
554 | - if ( ! isset( $node[ $last ] ) ) { |
|
555 | - $node[ $last ] = array(); |
|
554 | + if ( ! isset($node[$last])) { |
|
555 | + $node[$last] = array(); |
|
556 | 556 | } |
557 | 557 | } |
558 | 558 | |
559 | - if ( ! isset( $node[ $last ] ) ) { |
|
559 | + if ( ! isset($node[$last])) { |
|
560 | 560 | return null; |
561 | 561 | } |
562 | 562 | |
@@ -577,19 +577,19 @@ discard block |
||
577 | 577 | * |
578 | 578 | * @return |
579 | 579 | */ |
580 | - final protected function multidimensional_replace( $root, $keys, $value ) { |
|
580 | + final protected function multidimensional_replace($root, $keys, $value) { |
|
581 | 581 | |
582 | - if ( ! isset( $value ) ) { |
|
582 | + if ( ! isset($value)) { |
|
583 | 583 | return $root; |
584 | - } elseif ( empty( $keys ) ) { |
|
584 | + } elseif (empty($keys)) { |
|
585 | 585 | // If there are no keys, we're replacing the root. |
586 | 586 | return $value; |
587 | 587 | } |
588 | 588 | |
589 | - $result = $this->multidimensional( $root, $keys, true ); |
|
589 | + $result = $this->multidimensional($root, $keys, true); |
|
590 | 590 | |
591 | - if ( isset( $result ) ) { |
|
592 | - $result['node'][ $result['key'] ] = $value; |
|
591 | + if (isset($result)) { |
|
592 | + $result['node'][$result['key']] = $value; |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | return $root; |
@@ -605,18 +605,18 @@ discard block |
||
605 | 605 | * |
606 | 606 | * @return mixed The requested value or the default value. |
607 | 607 | */ |
608 | - final protected function multidimensional_get( $root, $keys, $default = null ) { |
|
608 | + final protected function multidimensional_get($root, $keys, $default = null) { |
|
609 | 609 | |
610 | 610 | // If there are no keys, test the root. |
611 | - if ( empty( $keys ) ) { |
|
612 | - if ( isset( $root ) ) { |
|
611 | + if (empty($keys)) { |
|
612 | + if (isset($root)) { |
|
613 | 613 | return $root; |
614 | 614 | } |
615 | 615 | } else { |
616 | - $result = $this->multidimensional( $root, $keys ); |
|
616 | + $result = $this->multidimensional($root, $keys); |
|
617 | 617 | |
618 | - if ( isset( $result ) ) { |
|
619 | - return $result['node'][ $result['key'] ]; |
|
618 | + if (isset($result)) { |
|
619 | + return $result['node'][$result['key']]; |
|
620 | 620 | } |
621 | 621 | } |
622 | 622 | |
@@ -632,11 +632,11 @@ discard block |
||
632 | 632 | * |
633 | 633 | * @return bool True if value is set, false if not. |
634 | 634 | */ |
635 | - final protected function multidimensional_isset( $root, $keys ) { |
|
635 | + final protected function multidimensional_isset($root, $keys) { |
|
636 | 636 | |
637 | - $result = $this->multidimensional_get( $root, $keys ); |
|
637 | + $result = $this->multidimensional_get($root, $keys); |
|
638 | 638 | |
639 | - return isset( $result ); |
|
639 | + return isset($result); |
|
640 | 640 | |
641 | 641 | } |
642 | 642 | } |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | * |
659 | 659 | * @return mixed The result of saving the value. |
660 | 660 | */ |
661 | - public function update( $value ) { |
|
661 | + public function update($value) { |
|
662 | 662 | |
663 | 663 | return null; |
664 | 664 |