@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | |
145 | 145 | $args = func_get_args(); |
146 | 146 | |
147 | - call_user_func_array( array( $this, 'init' ), $args ); |
|
147 | + call_user_func_array(array($this, 'init'), $args); |
|
148 | 148 | |
149 | 149 | } |
150 | 150 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @param string $id A specific ID of the control. |
156 | 156 | * @param array $args Control arguments. |
157 | 157 | */ |
158 | - public function init( $object_type, $id, $args = array() ) { |
|
158 | + public function init($object_type, $id, $args = array()) { |
|
159 | 159 | |
160 | 160 | /** |
161 | 161 | * @var $wp_fields WP_Fields_API |
@@ -164,7 +164,7 @@ discard block |
||
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,11 +172,11 @@ 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 | |
@@ -184,24 +184,24 @@ discard block |
||
184 | 184 | $this->instance_number = self::$instance_count; |
185 | 185 | |
186 | 186 | // Process fields. |
187 | - if ( empty( $this->fields ) ) { |
|
187 | + if (empty($this->fields)) { |
|
188 | 188 | $this->fields = $id; |
189 | 189 | } |
190 | 190 | |
191 | 191 | $fields = array(); |
192 | 192 | |
193 | - if ( is_array( $this->fields ) ) { |
|
194 | - foreach ( $this->fields as $key => $field ) { |
|
195 | - $field_obj = $wp_fields->get_field( $this->object_type, $field, $this->object_name ); |
|
193 | + if (is_array($this->fields)) { |
|
194 | + foreach ($this->fields as $key => $field) { |
|
195 | + $field_obj = $wp_fields->get_field($this->object_type, $field, $this->object_name); |
|
196 | 196 | |
197 | - if ( $field_obj ) { |
|
198 | - $fields[ $key ] = $field_obj; |
|
197 | + if ($field_obj) { |
|
198 | + $fields[$key] = $field_obj; |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 | } else { |
202 | - $field_obj = $wp_fields->get_field( $this->object_type, $this->fields, $this->object_name ); |
|
202 | + $field_obj = $wp_fields->get_field($this->object_type, $this->fields, $this->object_name); |
|
203 | 203 | |
204 | - if ( $field_obj ) { |
|
204 | + if ($field_obj) { |
|
205 | 205 | $this->field = $field_obj; |
206 | 206 | $fields['default'] = $field_obj; |
207 | 207 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | */ |
217 | 217 | public function setup_choices() { |
218 | 218 | |
219 | - if ( ! isset( $this->choices ) ) { |
|
219 | + if ( ! isset($this->choices)) { |
|
220 | 220 | $choices = $this->choices(); |
221 | 221 | |
222 | 222 | $this->choices = $choices; |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | final public function active() { |
249 | 249 | |
250 | 250 | $control = $this; |
251 | - $active = call_user_func( $this->active_callback, $this ); |
|
251 | + $active = call_user_func($this->active_callback, $this); |
|
252 | 252 | |
253 | 253 | /** |
254 | 254 | * Filter response of WP_Fields_API_Control::active(). |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * @param bool $active Whether the Field control is active. |
257 | 257 | * @param WP_Fields_API_Control $control WP_Fields_API_Control instance. |
258 | 258 | */ |
259 | - $active = apply_filters( 'fields_control_active_' . $this->object_type, $active, $control ); |
|
259 | + $active = apply_filters('fields_control_active_'.$this->object_type, $active, $control); |
|
260 | 260 | |
261 | 261 | return $active; |
262 | 262 | |
@@ -285,15 +285,15 @@ discard block |
||
285 | 285 | * @param string $field_key |
286 | 286 | * @return mixed The requested field's value, if the field exists. |
287 | 287 | */ |
288 | - final public function value( $field_key = 'default' ) { |
|
288 | + final public function value($field_key = 'default') { |
|
289 | 289 | |
290 | - if ( isset( $this->fields[ $field_key ] ) ) { |
|
290 | + if (isset($this->fields[$field_key])) { |
|
291 | 291 | /** |
292 | 292 | * @var $field WP_Fields_API_Field |
293 | 293 | */ |
294 | - $field = $this->fields[ $field_key ]; |
|
294 | + $field = $this->fields[$field_key]; |
|
295 | 295 | |
296 | - return $field->value( $this->item_id ); |
|
296 | + return $field->value($this->item_id); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | return null; |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | |
310 | 310 | $array = array(); |
311 | 311 | |
312 | - $array['fields'] = wp_list_pluck( $this->fields, 'id' ); |
|
312 | + $array['fields'] = wp_list_pluck($this->fields, 'id'); |
|
313 | 313 | $array['type'] = $this->type; |
314 | 314 | $array['priority'] = $this->priority; |
315 | 315 | $array['active'] = $this->active(); |
@@ -338,15 +338,15 @@ discard block |
||
338 | 338 | /** |
339 | 339 | * @var $field WP_Fields_API_Field |
340 | 340 | */ |
341 | - foreach ( $this->fields as $field ) { |
|
342 | - if ( ! $field || ! $field->check_capabilities() ) { |
|
341 | + foreach ($this->fields as $field) { |
|
342 | + if ( ! $field || ! $field->check_capabilities()) { |
|
343 | 343 | return false; |
344 | 344 | } |
345 | 345 | } |
346 | 346 | |
347 | - $section = $wp_fields->get_section( $this->object_type, $this->section, $this->object_name ); |
|
347 | + $section = $wp_fields->get_section($this->object_type, $this->section, $this->object_name); |
|
348 | 348 | |
349 | - if ( isset( $section ) && ! $section->check_capabilities() ) { |
|
349 | + if (isset($section) && ! $section->check_capabilities()) { |
|
350 | 350 | return false; |
351 | 351 | } |
352 | 352 | |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | |
366 | 366 | $this->maybe_render(); |
367 | 367 | |
368 | - $template = trim( ob_get_clean() ); |
|
368 | + $template = trim(ob_get_clean()); |
|
369 | 369 | |
370 | 370 | return $template; |
371 | 371 | |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | */ |
379 | 379 | final public function maybe_render() { |
380 | 380 | |
381 | - if ( ! $this->check_capabilities() ) { |
|
381 | + if ( ! $this->check_capabilities()) { |
|
382 | 382 | return; |
383 | 383 | } |
384 | 384 | |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | * |
388 | 388 | * @param WP_Fields_API_Control $this WP_Fields_API_Control instance. |
389 | 389 | */ |
390 | - do_action( 'fields_render_control_' . $this->object_type, $this ); |
|
390 | + do_action('fields_render_control_'.$this->object_type, $this); |
|
391 | 391 | |
392 | 392 | /** |
393 | 393 | * Fires just before a specific control is rendered. |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | * |
398 | 398 | * @param WP_Fields_API_Control $this {@see WP_Fields_API_Control} instance. |
399 | 399 | */ |
400 | - do_action( 'fields_render_control_' . $this->object_type . '_' . $this->object_name . '_' . $this->id, $this ); |
|
400 | + do_action('fields_render_control_'.$this->object_type.'_'.$this->object_name.'_'.$this->id, $this); |
|
401 | 401 | |
402 | 402 | $this->render(); |
403 | 403 | |
@@ -409,10 +409,10 @@ discard block |
||
409 | 409 | */ |
410 | 410 | protected function render() { |
411 | 411 | |
412 | - $id = 'fields-control-' . str_replace( '[', '-', str_replace( ']', '', $this->id ) ); |
|
413 | - $class = 'fields-control fields-control-' . $this->type; |
|
412 | + $id = 'fields-control-'.str_replace('[', '-', str_replace(']', '', $this->id)); |
|
413 | + $class = 'fields-control fields-control-'.$this->type; |
|
414 | 414 | |
415 | - ?><li id="<?php echo esc_attr( $id ); ?>" class="<?php echo esc_attr( $class ); ?>"> |
|
415 | + ?><li id="<?php echo esc_attr($id); ?>" class="<?php echo esc_attr($class); ?>"> |
|
416 | 416 | <?php $this->render_content(); ?> |
417 | 417 | </li><?php |
418 | 418 | |
@@ -425,13 +425,13 @@ discard block |
||
425 | 425 | * @param string $field_key |
426 | 426 | * @return string Data link parameter, if $field_key is a valid field, empty string otherwise. |
427 | 427 | */ |
428 | - public function get_link( $field_key = 'default' ) { |
|
428 | + public function get_link($field_key = 'default') { |
|
429 | 429 | |
430 | - if ( ! isset( $this->fields[ $field_key ] ) ) { |
|
430 | + if ( ! isset($this->fields[$field_key])) { |
|
431 | 431 | return ''; |
432 | 432 | } |
433 | 433 | |
434 | - return 'data-fields-field-link="' . esc_attr( $this->fields[ $field_key ]->id ) . '"'; |
|
434 | + return 'data-fields-field-link="'.esc_attr($this->fields[$field_key]->id).'"'; |
|
435 | 435 | |
436 | 436 | } |
437 | 437 | |
@@ -442,9 +442,9 @@ discard block |
||
442 | 442 | * |
443 | 443 | * @param string $field_key |
444 | 444 | */ |
445 | - public function link( $field_key = 'default' ) { |
|
445 | + public function link($field_key = 'default') { |
|
446 | 446 | |
447 | - echo $this->get_link( $field_key ); |
|
447 | + echo $this->get_link($field_key); |
|
448 | 448 | |
449 | 449 | } |
450 | 450 | |
@@ -455,8 +455,8 @@ discard block |
||
455 | 455 | */ |
456 | 456 | public function input_attrs() { |
457 | 457 | |
458 | - foreach ( $this->input_attrs as $attr => $value ) { |
|
459 | - echo $attr . '="' . esc_attr( $value ) . '" '; |
|
458 | + foreach ($this->input_attrs as $attr => $value) { |
|
459 | + echo $attr.'="'.esc_attr($value).'" '; |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | } |
@@ -475,13 +475,13 @@ discard block |
||
475 | 475 | |
476 | 476 | ?> |
477 | 477 | <label> |
478 | - <?php if ( ! empty( $this->label ) ) : ?> |
|
479 | - <span class="fields-control-title"><?php echo esc_html( $this->label ); ?></span> |
|
478 | + <?php if ( ! empty($this->label)) : ?> |
|
479 | + <span class="fields-control-title"><?php echo esc_html($this->label); ?></span> |
|
480 | 480 | <?php endif; |
481 | - if ( ! empty( $this->description ) ) : ?> |
|
481 | + if ( ! empty($this->description)) : ?> |
|
482 | 482 | <span class="description fields-control-description"><?php echo $this->description; ?></span> |
483 | 483 | <?php endif; ?> |
484 | - <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(); ?> /> |
|
484 | + <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(); ?> /> |
|
485 | 485 | </label> |
486 | 486 | <?php |
487 | 487 | |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | public function print_template() { |
500 | 500 | |
501 | 501 | ?> |
502 | - <script type="text/html" id="tmpl-fields-<?php echo esc_attr( $this->object_type ); ?>-control-<?php echo esc_attr( $this->type ); ?>-content"> |
|
502 | + <script type="text/html" id="tmpl-fields-<?php echo esc_attr($this->object_type); ?>-control-<?php echo esc_attr($this->type); ?>-content"> |
|
503 | 503 | <?php $this->content_template(); ?> |
504 | 504 | </script> |
505 | 505 | <?php |
@@ -527,10 +527,10 @@ discard block |
||
527 | 527 | * |
528 | 528 | * @return mixed|null |
529 | 529 | */ |
530 | - public function &__get( $name ) { |
|
530 | + public function &__get($name) { |
|
531 | 531 | |
532 | 532 | // Map $this->choices to $this->choices() for dynamic choice handling |
533 | - if ( 'choices' == $name ) { |
|
533 | + if ('choices' == $name) { |
|
534 | 534 | $this->setup_choices(); |
535 | 535 | |
536 | 536 | return $this->choices; |