@@ -403,11 +403,11 @@ |
||
| 403 | 403 | switch ( $message ) { |
| 404 | 404 | |
| 405 | 405 | case self::DEPRECATED_PARAM: |
| 406 | - $message = sprintf( __( 'The "%1$s" field parameter has been deprecated in favor of the "%1$s" parameter.', 'cmb2' ), $args[3], $args[4] ); |
|
| 406 | + $message = sprintf( __( 'The "%1$s" field parameter has been deprecated in favor of the "%1$s" parameter.', 'cmb2' ), $args[ 3 ], $args[ 4 ] ); |
|
| 407 | 407 | break; |
| 408 | 408 | |
| 409 | 409 | case self::DEPRECATED_CB_PARAM: |
| 410 | - $message = sprintf( __( 'Using the "%1$s" field parameter as a callback has been deprecated in favor of the "%1$s" parameter.', 'cmb2' ), $args[3], $args[4] ); |
|
| 410 | + $message = sprintf( __( 'Using the "%1$s" field parameter as a callback has been deprecated in favor of the "%1$s" parameter.', 'cmb2' ), $args[ 3 ], $args[ 4 ] ); |
|
| 411 | 411 | break; |
| 412 | 412 | |
| 413 | 413 | default: |
@@ -276,25 +276,25 @@ discard block |
||
| 276 | 276 | $fields = $this->cmb->prop( 'fields' ); |
| 277 | 277 | |
| 278 | 278 | foreach ( $fields as $key => $field ) { |
| 279 | - if ( ! isset( $field['column'] ) ) { |
|
| 279 | + if ( ! isset( $field[ 'column' ] ) ) { |
|
| 280 | 280 | continue; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - $column = $field['column']; |
|
| 283 | + $column = $field[ 'column' ]; |
|
| 284 | 284 | |
| 285 | - if ( false === $column['position'] ) { |
|
| 285 | + if ( false === $column[ 'position' ] ) { |
|
| 286 | 286 | |
| 287 | - $columns[ $field['id'] ] = $column['name']; |
|
| 287 | + $columns[ $field[ 'id' ] ] = $column[ 'name' ]; |
|
| 288 | 288 | |
| 289 | 289 | } else { |
| 290 | 290 | |
| 291 | - $before = array_slice( $columns, 0, absint( $column['position'] ) ); |
|
| 292 | - $before[ $field['id'] ] = $column['name']; |
|
| 291 | + $before = array_slice( $columns, 0, absint( $column[ 'position' ] ) ); |
|
| 292 | + $before[ $field[ 'id' ] ] = $column[ 'name' ]; |
|
| 293 | 293 | $columns = $before + $columns; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - $column['field'] = $field; |
|
| 297 | - $this->columns[ $field['id'] ] = $column; |
|
| 296 | + $column[ 'field' ] = $field; |
|
| 297 | + $this->columns[ $field[ 'id' ] ] = $column; |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | return $columns; |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | public function column_display( $column_name, $object_id ) { |
| 309 | 309 | if ( isset( $this->columns[ $column_name ] ) ) { |
| 310 | 310 | $field = new CMB2_Field( array( |
| 311 | - 'field_args' => $this->columns[ $column_name ]['field'], |
|
| 311 | + 'field_args' => $this->columns[ $column_name ][ 'field' ], |
|
| 312 | 312 | 'object_type' => $this->object_type, |
| 313 | 313 | 'object_id' => $this->cmb->object_id( $object_id ), |
| 314 | 314 | 'cmb_id' => $this->cmb->cmb_id, |
@@ -488,13 +488,13 @@ discard block |
||
| 488 | 488 | */ |
| 489 | 489 | public function postbox_classes( $classes ) { |
| 490 | 490 | if ( $this->cmb->prop( 'closed' ) && ! in_array( 'closed', $classes ) ) { |
| 491 | - $classes[] = 'closed'; |
|
| 491 | + $classes[ ] = 'closed'; |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | if ( $this->cmb->is_alternate_context_box() ) { |
| 495 | 495 | $classes = $this->alternate_context_postbox_classes( $classes ); |
| 496 | 496 | } else { |
| 497 | - $classes[] = 'cmb2-postbox'; |
|
| 497 | + $classes[ ] = 'cmb2-postbox'; |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | return $classes; |
@@ -508,19 +508,19 @@ discard block |
||
| 508 | 508 | * @return array Modified array of classes |
| 509 | 509 | */ |
| 510 | 510 | protected function alternate_context_postbox_classes( $classes ) { |
| 511 | - $classes[] = 'context-box'; |
|
| 512 | - $classes[] = 'context-' . $this->cmb->prop( 'context' ) . '-box'; |
|
| 511 | + $classes[ ] = 'context-box'; |
|
| 512 | + $classes[ ] = 'context-' . $this->cmb->prop( 'context' ) . '-box'; |
|
| 513 | 513 | |
| 514 | 514 | if ( in_array( $this->cmb->cmb_id, get_hidden_meta_boxes( get_current_screen() ) ) ) { |
| 515 | - $classes[] = 'hide-if-js'; |
|
| 515 | + $classes[ ] = 'hide-if-js'; |
|
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | $add_wrap = $this->cmb->prop( 'title' ) || ! $this->cmb->prop( 'remove_box_wrap' ); |
| 519 | 519 | |
| 520 | 520 | if ( $add_wrap ) { |
| 521 | - $classes[] = 'cmb2-postbox postbox'; |
|
| 521 | + $classes[ ] = 'cmb2-postbox postbox'; |
|
| 522 | 522 | } else { |
| 523 | - $classes[] = 'cmb2-no-box-wrap'; |
|
| 523 | + $classes[ ] = 'cmb2-no-box-wrap'; |
|
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | return $classes; |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | public function user_new_metabox( $section ) { |
| 545 | 545 | if ( $section == $this->cmb->prop( 'new_user_section' ) ) { |
| 546 | 546 | $object_id = $this->cmb->object_id(); |
| 547 | - $this->cmb->object_id( isset( $_REQUEST['user_id'] ) ? $_REQUEST['user_id'] : $object_id ); |
|
| 547 | + $this->cmb->object_id( isset( $_REQUEST[ 'user_id' ] ) ? $_REQUEST[ 'user_id' ] : $object_id ); |
|
| 548 | 548 | $this->user_metabox(); |
| 549 | 549 | } |
| 550 | 550 | } |
@@ -735,7 +735,7 @@ discard block |
||
| 735 | 735 | |
| 736 | 736 | $data_to_delete = array(); |
| 737 | 737 | foreach ( $this->cmb->prop( 'fields' ) as $field ) { |
| 738 | - $data_to_delete[ $field['id'] ] = ''; |
|
| 738 | + $data_to_delete[ $field[ 'id' ] ] = ''; |
|
| 739 | 739 | } |
| 740 | 740 | |
| 741 | 741 | $this->cmb->save_fields( $term_id, 'term', $data_to_delete ); |
@@ -139,19 +139,19 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | public function __construct( $config, $object_id = 0 ) { |
| 141 | 141 | |
| 142 | - if ( empty( $config['id'] ) ) { |
|
| 142 | + if ( empty( $config[ 'id' ] ) ) { |
|
| 143 | 143 | wp_die( esc_html__( 'Metabox configuration is required to have an ID parameter.', 'cmb2' ) ); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | $this->meta_box = wp_parse_args( $config, $this->mb_defaults ); |
| 147 | - $this->meta_box['fields'] = array(); |
|
| 147 | + $this->meta_box[ 'fields' ] = array(); |
|
| 148 | 148 | |
| 149 | 149 | $this->object_id( $object_id ); |
| 150 | 150 | $this->mb_object_type(); |
| 151 | - $this->cmb_id = $config['id']; |
|
| 151 | + $this->cmb_id = $config[ 'id' ]; |
|
| 152 | 152 | |
| 153 | - if ( ! empty( $config['fields'] ) && is_array( $config['fields'] ) ) { |
|
| 154 | - $this->add_fields( $config['fields'] ); |
|
| 153 | + if ( ! empty( $config[ 'fields' ] ) && is_array( $config[ 'fields' ] ) ) { |
|
| 154 | + $this->add_fields( $config[ 'fields' ] ); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | CMB2_Boxes::add( $this ); |
@@ -261,17 +261,17 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | // Include custom class if requesting no title. |
| 263 | 263 | if ( ! $this->prop( 'title' ) && ! $this->prop( 'remove_box_wrap' ) ) { |
| 264 | - $context[] = 'cmb2-context-wrap-no-title'; |
|
| 264 | + $context[ ] = 'cmb2-context-wrap-no-title'; |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | // Include a generic context wrapper. |
| 268 | - $context[] = 'cmb2-context-wrap'; |
|
| 268 | + $context[ ] = 'cmb2-context-wrap'; |
|
| 269 | 269 | |
| 270 | 270 | // Include a context-type based context wrapper. |
| 271 | - $context[] = 'cmb2-context-wrap-' . $this->prop( 'context' ); |
|
| 271 | + $context[ ] = 'cmb2-context-wrap-' . $this->prop( 'context' ); |
|
| 272 | 272 | |
| 273 | 273 | // Include an ID based context wrapper as well. |
| 274 | - $context[] = 'cmb2-context-wrap-' . $this->prop( 'id' ); |
|
| 274 | + $context[ ] = 'cmb2-context-wrap-' . $this->prop( 'id' ); |
|
| 275 | 275 | |
| 276 | 276 | // And merge all the classes back into the array. |
| 277 | 277 | $classes = array_merge( $classes, $context ); |
@@ -352,22 +352,22 @@ discard block |
||
| 352 | 352 | * @return mixed CMB2_Field object if successful. |
| 353 | 353 | */ |
| 354 | 354 | public function render_field( $field_args ) { |
| 355 | - $field_args['context'] = $this->prop( 'context' ); |
|
| 355 | + $field_args[ 'context' ] = $this->prop( 'context' ); |
|
| 356 | 356 | |
| 357 | - if ( 'group' === $field_args['type'] ) { |
|
| 357 | + if ( 'group' === $field_args[ 'type' ] ) { |
|
| 358 | 358 | |
| 359 | - if ( ! isset( $field_args['show_names'] ) ) { |
|
| 360 | - $field_args['show_names'] = $this->prop( 'show_names' ); |
|
| 359 | + if ( ! isset( $field_args[ 'show_names' ] ) ) { |
|
| 360 | + $field_args[ 'show_names' ] = $this->prop( 'show_names' ); |
|
| 361 | 361 | } |
| 362 | 362 | $field = $this->render_group( $field_args ); |
| 363 | 363 | |
| 364 | - } elseif ( 'hidden' === $field_args['type'] && $this->get_field( $field_args )->should_show() ) { |
|
| 364 | + } elseif ( 'hidden' === $field_args[ 'type' ] && $this->get_field( $field_args )->should_show() ) { |
|
| 365 | 365 | // Save rendering for after the metabox. |
| 366 | 366 | $field = $this->add_hidden_field( $field_args ); |
| 367 | 367 | |
| 368 | 368 | } else { |
| 369 | 369 | |
| 370 | - $field_args['show_names'] = $this->prop( 'show_names' ); |
|
| 370 | + $field_args[ 'show_names' ] = $this->prop( 'show_names' ); |
|
| 371 | 371 | |
| 372 | 372 | // Render default fields. |
| 373 | 373 | $field = $this->get_field( $field_args )->render_field(); |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | */ |
| 385 | 385 | public function render_group( $args ) { |
| 386 | 386 | |
| 387 | - if ( ! isset( $args['id'], $args['fields'] ) || ! is_array( $args['fields'] ) ) { |
|
| 387 | + if ( ! isset( $args[ 'id' ], $args[ 'fields' ] ) || ! is_array( $args[ 'fields' ] ) ) { |
|
| 388 | 388 | return; |
| 389 | 389 | } |
| 390 | 390 | |
@@ -496,15 +496,15 @@ discard block |
||
| 496 | 496 | <div class="inside cmb-td cmb-nested cmb-field-list">'; |
| 497 | 497 | // Loop and render repeatable group fields. |
| 498 | 498 | foreach ( array_values( $field_group->args( 'fields' ) ) as $field_args ) { |
| 499 | - if ( 'hidden' === $field_args['type'] ) { |
|
| 499 | + if ( 'hidden' === $field_args[ 'type' ] ) { |
|
| 500 | 500 | |
| 501 | 501 | // Save rendering for after the metabox. |
| 502 | 502 | $this->add_hidden_field( $field_args, $field_group ); |
| 503 | 503 | |
| 504 | 504 | } else { |
| 505 | 505 | |
| 506 | - $field_args['show_names'] = $field_group->args( 'show_names' ); |
|
| 507 | - $field_args['context'] = $field_group->args( 'context' ); |
|
| 506 | + $field_args[ 'show_names' ] = $field_group->args( 'show_names' ); |
|
| 507 | + $field_args[ 'context' ] = $field_group->args( 'context' ); |
|
| 508 | 508 | |
| 509 | 509 | $field = $this->get_field( $field_args, $field_group )->render_field(); |
| 510 | 510 | } |
@@ -534,7 +534,7 @@ discard block |
||
| 534 | 534 | * @param CMB2_Field|null $field_group CMB2_Field group field object. |
| 535 | 535 | */ |
| 536 | 536 | public function add_hidden_field( $field_args, $field_group = null ) { |
| 537 | - if ( isset( $field_args['field_args'] ) ) { |
|
| 537 | + if ( isset( $field_args[ 'field_args' ] ) ) { |
|
| 538 | 538 | // For back-compatibility. |
| 539 | 539 | $field = new CMB2_Field( $field_args ); |
| 540 | 540 | } else { |
@@ -547,7 +547,7 @@ discard block |
||
| 547 | 547 | $types->iterator = $field_group->index; |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | - $this->hidden_fields[] = $types; |
|
| 550 | + $this->hidden_fields[ ] = $types; |
|
| 551 | 551 | |
| 552 | 552 | return $field; |
| 553 | 553 | } |
@@ -655,11 +655,11 @@ discard block |
||
| 655 | 655 | */ |
| 656 | 656 | public function process_field( $field_args ) { |
| 657 | 657 | |
| 658 | - switch ( $field_args['type'] ) { |
|
| 658 | + switch ( $field_args[ 'type' ] ) { |
|
| 659 | 659 | |
| 660 | 660 | case 'group': |
| 661 | 661 | if ( $this->save_group( $field_args ) ) { |
| 662 | - $this->updated[] = $field_args['id']; |
|
| 662 | + $this->updated[ ] = $field_args[ 'id' ]; |
|
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | break; |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | $field = $this->get_new_field( $field_args ); |
| 674 | 674 | |
| 675 | 675 | if ( $field->save_field_from_data( $this->data_to_save ) ) { |
| 676 | - $this->updated[] = $field->id(); |
|
| 676 | + $this->updated[ ] = $field->id(); |
|
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | break; |
@@ -756,7 +756,7 @@ discard block |
||
| 756 | 756 | * @return mixed Return of CMB2_Field::update_data(). |
| 757 | 757 | */ |
| 758 | 758 | public function save_group( $args ) { |
| 759 | - if ( ! isset( $args['id'], $args['fields'] ) || ! is_array( $args['fields'] ) ) { |
|
| 759 | + if ( ! isset( $args[ 'id' ], $args[ 'fields' ] ) || ! is_array( $args[ 'fields' ] ) ) { |
|
| 760 | 760 | return; |
| 761 | 761 | } |
| 762 | 762 | |
@@ -786,7 +786,7 @@ discard block |
||
| 786 | 786 | $field_group->data_to_save = $this->data_to_save; |
| 787 | 787 | |
| 788 | 788 | foreach ( array_values( $field_group->fields() ) as $field_args ) { |
| 789 | - if ( 'title' === $field_args['type'] ) { |
|
| 789 | + if ( 'title' === $field_args[ 'type' ] ) { |
|
| 790 | 790 | // Don't process title fields. |
| 791 | 791 | continue; |
| 792 | 792 | } |
@@ -809,16 +809,16 @@ discard block |
||
| 809 | 809 | $_new_val = array(); |
| 810 | 810 | foreach ( $new_val as $group_index => $grouped_data ) { |
| 811 | 811 | // Add the supporting data to the $saved array stack. |
| 812 | - $saved[ $field_group->index ][ $grouped_data['supporting_field_id'] ][] = $grouped_data['supporting_field_value']; |
|
| 812 | + $saved[ $field_group->index ][ $grouped_data[ 'supporting_field_id' ] ][ ] = $grouped_data[ 'supporting_field_value' ]; |
|
| 813 | 813 | // Reset var to the actual value. |
| 814 | - $_new_val[ $group_index ] = $grouped_data['value']; |
|
| 814 | + $_new_val[ $group_index ] = $grouped_data[ 'value' ]; |
|
| 815 | 815 | } |
| 816 | 816 | $new_val = $_new_val; |
| 817 | 817 | } else { |
| 818 | 818 | // Add the supporting data to the $saved array stack. |
| 819 | - $saved[ $field_group->index ][ $new_val['supporting_field_id'] ] = $new_val['supporting_field_value']; |
|
| 819 | + $saved[ $field_group->index ][ $new_val[ 'supporting_field_id' ] ] = $new_val[ 'supporting_field_value' ]; |
|
| 820 | 820 | // Reset var to the actual value. |
| 821 | - $new_val = $new_val['value']; |
|
| 821 | + $new_val = $new_val[ 'value' ]; |
|
| 822 | 822 | } |
| 823 | 823 | } |
| 824 | 824 | |
@@ -832,7 +832,7 @@ discard block |
||
| 832 | 832 | |
| 833 | 833 | // Compare values and add to `$updated` array. |
| 834 | 834 | if ( $is_updated || $is_removed ) { |
| 835 | - $this->updated[] = $base_id . '::' . $field_group->index . '::' . $sub_id; |
|
| 835 | + $this->updated[ ] = $base_id . '::' . $field_group->index . '::' . $sub_id; |
|
| 836 | 836 | } |
| 837 | 837 | |
| 838 | 838 | // Add to `$saved` array. |
@@ -870,22 +870,22 @@ discard block |
||
| 870 | 870 | // Try to get our object ID from the global space. |
| 871 | 871 | switch ( $this->object_type() ) { |
| 872 | 872 | case 'user': |
| 873 | - $object_id = isset( $_REQUEST['user_id'] ) ? wp_unslash( $_REQUEST['user_id'] ) : $object_id; |
|
| 874 | - $object_id = ! $object_id && 'user-new.php' !== $pagenow && isset( $GLOBALS['user_ID'] ) ? $GLOBALS['user_ID'] : $object_id; |
|
| 873 | + $object_id = isset( $_REQUEST[ 'user_id' ] ) ? wp_unslash( $_REQUEST[ 'user_id' ] ) : $object_id; |
|
| 874 | + $object_id = ! $object_id && 'user-new.php' !== $pagenow && isset( $GLOBALS[ 'user_ID' ] ) ? $GLOBALS[ 'user_ID' ] : $object_id; |
|
| 875 | 875 | break; |
| 876 | 876 | |
| 877 | 877 | case 'comment': |
| 878 | - $object_id = isset( $_REQUEST['c'] ) ? wp_unslash( $_REQUEST['c'] ) : $object_id; |
|
| 879 | - $object_id = ! $object_id && isset( $GLOBALS['comments']->comment_ID ) ? $GLOBALS['comments']->comment_ID : $object_id; |
|
| 878 | + $object_id = isset( $_REQUEST[ 'c' ] ) ? wp_unslash( $_REQUEST[ 'c' ] ) : $object_id; |
|
| 879 | + $object_id = ! $object_id && isset( $GLOBALS[ 'comments' ]->comment_ID ) ? $GLOBALS[ 'comments' ]->comment_ID : $object_id; |
|
| 880 | 880 | break; |
| 881 | 881 | |
| 882 | 882 | case 'term': |
| 883 | - $object_id = isset( $_REQUEST['tag_ID'] ) ? wp_unslash( $_REQUEST['tag_ID'] ) : $object_id; |
|
| 883 | + $object_id = isset( $_REQUEST[ 'tag_ID' ] ) ? wp_unslash( $_REQUEST[ 'tag_ID' ] ) : $object_id; |
|
| 884 | 884 | break; |
| 885 | 885 | |
| 886 | 886 | default: |
| 887 | - $object_id = isset( $GLOBALS['post']->ID ) ? $GLOBALS['post']->ID : $object_id; |
|
| 888 | - $object_id = isset( $_REQUEST['post'] ) ? wp_unslash( $_REQUEST['post'] ) : $object_id; |
|
| 887 | + $object_id = isset( $GLOBALS[ 'post' ]->ID ) ? $GLOBALS[ 'post' ]->ID : $object_id; |
|
| 888 | + $object_id = isset( $_REQUEST[ 'post' ] ) ? wp_unslash( $_REQUEST[ 'post' ] ) : $object_id; |
|
| 889 | 889 | break; |
| 890 | 890 | } |
| 891 | 891 | |
@@ -959,7 +959,7 @@ discard block |
||
| 959 | 959 | * @return boolean True/False. |
| 960 | 960 | */ |
| 961 | 961 | public function is_options_page_mb() { |
| 962 | - return ( isset( $this->meta_box['show_on']['key'] ) && 'options-page' === $this->meta_box['show_on']['key'] || array_key_exists( 'options-page', $this->meta_box['show_on'] ) ); |
|
| 962 | + return ( isset( $this->meta_box[ 'show_on' ][ 'key' ] ) && 'options-page' === $this->meta_box[ 'show_on' ][ 'key' ] || array_key_exists( 'options-page', $this->meta_box[ 'show_on' ] ) ); |
|
| 963 | 963 | } |
| 964 | 964 | |
| 965 | 965 | /** |
@@ -1006,7 +1006,7 @@ discard block |
||
| 1006 | 1006 | $type = 'term'; |
| 1007 | 1007 | } |
| 1008 | 1008 | |
| 1009 | - if ( defined( 'DOING_AJAX' ) && isset( $_POST['action'] ) && 'add-tag' === $_POST['action'] ) { |
|
| 1009 | + if ( defined( 'DOING_AJAX' ) && isset( $_POST[ 'action' ] ) && 'add-tag' === $_POST[ 'action' ] ) { |
|
| 1010 | 1010 | $type = 'term'; |
| 1011 | 1011 | } |
| 1012 | 1012 | |
@@ -1056,7 +1056,7 @@ discard block |
||
| 1056 | 1056 | return $field; |
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | - $field_id = is_string( $field ) ? $field : $field['id']; |
|
| 1059 | + $field_id = is_string( $field ) ? $field : $field[ 'id' ]; |
|
| 1060 | 1060 | |
| 1061 | 1061 | $parent_field_id = ! empty( $field_group ) ? $field_group->id() : ''; |
| 1062 | 1062 | $ids = $this->get_field_ids( $field_id, $parent_field_id ); |
@@ -1093,16 +1093,16 @@ discard block |
||
| 1093 | 1093 | if ( $field_group && ( $sub_field_id || 0 === $sub_field_id ) ) { |
| 1094 | 1094 | |
| 1095 | 1095 | // Update the fields array w/ any modified properties inherited from the group field. |
| 1096 | - $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] = $field_args; |
|
| 1096 | + $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] = $field_args; |
|
| 1097 | 1097 | |
| 1098 | 1098 | return $this->get_default_args( $field_args, $field_group ); |
| 1099 | 1099 | } |
| 1100 | 1100 | |
| 1101 | 1101 | if ( is_array( $field_args ) ) { |
| 1102 | - $this->meta_box['fields'][ $field_id ] = array_merge( $field_args, $this->meta_box['fields'][ $field_id ] ); |
|
| 1102 | + $this->meta_box[ 'fields' ][ $field_id ] = array_merge( $field_args, $this->meta_box[ 'fields' ][ $field_id ] ); |
|
| 1103 | 1103 | } |
| 1104 | 1104 | |
| 1105 | - return $this->get_default_args( $this->meta_box['fields'][ $field_id ] ); |
|
| 1105 | + return $this->get_default_args( $this->meta_box[ 'fields' ][ $field_id ] ); |
|
| 1106 | 1106 | } |
| 1107 | 1107 | |
| 1108 | 1108 | /** |
@@ -1155,8 +1155,8 @@ discard block |
||
| 1155 | 1155 | |
| 1156 | 1156 | $sub_fields = false; |
| 1157 | 1157 | if ( array_key_exists( 'fields', $field ) ) { |
| 1158 | - $sub_fields = $field['fields']; |
|
| 1159 | - unset( $field['fields'] ); |
|
| 1158 | + $sub_fields = $field[ 'fields' ]; |
|
| 1159 | + unset( $field[ 'fields' ] ); |
|
| 1160 | 1160 | } |
| 1161 | 1161 | |
| 1162 | 1162 | $field_id = $parent_field_id |
@@ -1183,7 +1183,7 @@ discard block |
||
| 1183 | 1183 | } |
| 1184 | 1184 | |
| 1185 | 1185 | // Perform some field-type-specific initiation actions. |
| 1186 | - switch ( $field['type'] ) { |
|
| 1186 | + switch ( $field[ 'type' ] ) { |
|
| 1187 | 1187 | case 'file': |
| 1188 | 1188 | case 'file_list': |
| 1189 | 1189 | |
@@ -1198,21 +1198,21 @@ discard block |
||
| 1198 | 1198 | break; |
| 1199 | 1199 | } |
| 1200 | 1200 | |
| 1201 | - if ( isset( $field['column'] ) && false !== $field['column'] ) { |
|
| 1201 | + if ( isset( $field[ 'column' ] ) && false !== $field[ 'column' ] ) { |
|
| 1202 | 1202 | $field = $this->define_field_column( $field ); |
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | - if ( isset( $field['taxonomy'] ) && ! empty( $field['remove_default'] ) ) { |
|
| 1206 | - $this->tax_metaboxes_to_remove[ $field['taxonomy'] ] = $field['taxonomy']; |
|
| 1205 | + if ( isset( $field[ 'taxonomy' ] ) && ! empty( $field[ 'remove_default' ] ) ) { |
|
| 1206 | + $this->tax_metaboxes_to_remove[ $field[ 'taxonomy' ] ] = $field[ 'taxonomy' ]; |
|
| 1207 | 1207 | } |
| 1208 | 1208 | |
| 1209 | 1209 | $this->_add_field_to_array( |
| 1210 | 1210 | $field, |
| 1211 | - $this->meta_box['fields'], |
|
| 1211 | + $this->meta_box[ 'fields' ], |
|
| 1212 | 1212 | $position |
| 1213 | 1213 | ); |
| 1214 | 1214 | |
| 1215 | - return $field['id']; |
|
| 1215 | + return $field[ 'id' ]; |
|
| 1216 | 1216 | } |
| 1217 | 1217 | |
| 1218 | 1218 | /** |
@@ -1225,10 +1225,10 @@ discard block |
||
| 1225 | 1225 | protected function define_field_column( array $field ) { |
| 1226 | 1226 | $this->has_columns = true; |
| 1227 | 1227 | |
| 1228 | - $column = is_array( $field['column'] ) ? $field['column'] : array(); |
|
| 1228 | + $column = is_array( $field[ 'column' ] ) ? $field[ 'column' ] : array(); |
|
| 1229 | 1229 | |
| 1230 | - $field['column'] = wp_parse_args( $column, array( |
|
| 1231 | - 'name' => isset( $field['name'] ) ? $field['name'] : '', |
|
| 1230 | + $field[ 'column' ] = wp_parse_args( $column, array( |
|
| 1231 | + 'name' => isset( $field[ 'name' ] ) ? $field[ 'name' ] : '', |
|
| 1232 | 1232 | 'position' => false, |
| 1233 | 1233 | ) ); |
| 1234 | 1234 | |
@@ -1245,27 +1245,27 @@ discard block |
||
| 1245 | 1245 | * @return mixed Array of parent/field ids or false. |
| 1246 | 1246 | */ |
| 1247 | 1247 | public function add_group_field( $parent_field_id, array $field, $position = 0 ) { |
| 1248 | - if ( ! array_key_exists( $parent_field_id, $this->meta_box['fields'] ) ) { |
|
| 1248 | + if ( ! array_key_exists( $parent_field_id, $this->meta_box[ 'fields' ] ) ) { |
|
| 1249 | 1249 | return false; |
| 1250 | 1250 | } |
| 1251 | 1251 | |
| 1252 | - $parent_field = $this->meta_box['fields'][ $parent_field_id ]; |
|
| 1252 | + $parent_field = $this->meta_box[ 'fields' ][ $parent_field_id ]; |
|
| 1253 | 1253 | |
| 1254 | - if ( 'group' !== $parent_field['type'] ) { |
|
| 1254 | + if ( 'group' !== $parent_field[ 'type' ] ) { |
|
| 1255 | 1255 | return false; |
| 1256 | 1256 | } |
| 1257 | 1257 | |
| 1258 | - if ( ! isset( $parent_field['fields'] ) ) { |
|
| 1259 | - $this->meta_box['fields'][ $parent_field_id ]['fields'] = array(); |
|
| 1258 | + if ( ! isset( $parent_field[ 'fields' ] ) ) { |
|
| 1259 | + $this->meta_box[ 'fields' ][ $parent_field_id ][ 'fields' ] = array(); |
|
| 1260 | 1260 | } |
| 1261 | 1261 | |
| 1262 | 1262 | $this->_add_field_to_array( |
| 1263 | 1263 | $field, |
| 1264 | - $this->meta_box['fields'][ $parent_field_id ]['fields'], |
|
| 1264 | + $this->meta_box[ 'fields' ][ $parent_field_id ][ 'fields' ], |
|
| 1265 | 1265 | $position |
| 1266 | 1266 | ); |
| 1267 | 1267 | |
| 1268 | - return array( $parent_field_id, $field['id'] ); |
|
| 1268 | + return array( $parent_field_id, $field[ 'id' ] ); |
|
| 1269 | 1269 | } |
| 1270 | 1270 | |
| 1271 | 1271 | /** |
@@ -1278,9 +1278,9 @@ discard block |
||
| 1278 | 1278 | */ |
| 1279 | 1279 | protected function _add_field_to_array( $field, &$fields, $position = 0 ) { |
| 1280 | 1280 | if ( $position ) { |
| 1281 | - CMB2_Utils::array_insert( $fields, array( $field['id'] => $field ), $position ); |
|
| 1281 | + CMB2_Utils::array_insert( $fields, array( $field[ 'id' ] => $field ), $position ); |
|
| 1282 | 1282 | } else { |
| 1283 | - $fields[ $field['id'] ] = $field; |
|
| 1283 | + $fields[ $field[ 'id' ] ] = $field; |
|
| 1284 | 1284 | } |
| 1285 | 1285 | } |
| 1286 | 1286 | |
@@ -1304,15 +1304,15 @@ discard block |
||
| 1304 | 1304 | unset( $this->fields[ implode( '', $ids ) ] ); |
| 1305 | 1305 | |
| 1306 | 1306 | if ( ! $sub_field_id ) { |
| 1307 | - unset( $this->meta_box['fields'][ $field_id ] ); |
|
| 1307 | + unset( $this->meta_box[ 'fields' ][ $field_id ] ); |
|
| 1308 | 1308 | return true; |
| 1309 | 1309 | } |
| 1310 | 1310 | |
| 1311 | - if ( isset( $this->fields[ $field_id ]->args['fields'][ $sub_field_id ] ) ) { |
|
| 1312 | - unset( $this->fields[ $field_id ]->args['fields'][ $sub_field_id ] ); |
|
| 1311 | + if ( isset( $this->fields[ $field_id ]->args[ 'fields' ][ $sub_field_id ] ) ) { |
|
| 1312 | + unset( $this->fields[ $field_id ]->args[ 'fields' ][ $sub_field_id ] ); |
|
| 1313 | 1313 | } |
| 1314 | - if ( isset( $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] ) ) { |
|
| 1315 | - unset( $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] ); |
|
| 1314 | + if ( isset( $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] ) ) { |
|
| 1315 | + unset( $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] ); |
|
| 1316 | 1316 | } |
| 1317 | 1317 | return true; |
| 1318 | 1318 | } |
@@ -1337,11 +1337,11 @@ discard block |
||
| 1337 | 1337 | list( $field_id, $sub_field_id ) = $ids; |
| 1338 | 1338 | |
| 1339 | 1339 | if ( ! $sub_field_id ) { |
| 1340 | - $this->meta_box['fields'][ $field_id ][ $property ] = $value; |
|
| 1340 | + $this->meta_box[ 'fields' ][ $field_id ][ $property ] = $value; |
|
| 1341 | 1341 | return $field_id; |
| 1342 | 1342 | } |
| 1343 | 1343 | |
| 1344 | - $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ][ $property ] = $value; |
|
| 1344 | + $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ][ $property ] = $value; |
|
| 1345 | 1345 | return $field_id; |
| 1346 | 1346 | } |
| 1347 | 1347 | |
@@ -1356,7 +1356,7 @@ discard block |
||
| 1356 | 1356 | public function get_field_ids( $field_id, $parent_field_id = '' ) { |
| 1357 | 1357 | $sub_field_id = $parent_field_id ? $field_id : ''; |
| 1358 | 1358 | $field_id = $parent_field_id ? $parent_field_id : $field_id; |
| 1359 | - $fields =& $this->meta_box['fields']; |
|
| 1359 | + $fields = & $this->meta_box[ 'fields' ]; |
|
| 1360 | 1360 | |
| 1361 | 1361 | if ( ! array_key_exists( $field_id, $fields ) ) { |
| 1362 | 1362 | $field_id = $this->search_old_school_array( $field_id, $fields ); |
@@ -1370,12 +1370,12 @@ discard block |
||
| 1370 | 1370 | return array( $field_id, $sub_field_id ); |
| 1371 | 1371 | } |
| 1372 | 1372 | |
| 1373 | - if ( 'group' !== $fields[ $field_id ]['type'] ) { |
|
| 1373 | + if ( 'group' !== $fields[ $field_id ][ 'type' ] ) { |
|
| 1374 | 1374 | return false; |
| 1375 | 1375 | } |
| 1376 | 1376 | |
| 1377 | - if ( ! array_key_exists( $sub_field_id, $fields[ $field_id ]['fields'] ) ) { |
|
| 1378 | - $sub_field_id = $this->search_old_school_array( $sub_field_id, $fields[ $field_id ]['fields'] ); |
|
| 1377 | + if ( ! array_key_exists( $sub_field_id, $fields[ $field_id ][ 'fields' ] ) ) { |
|
| 1378 | + $sub_field_id = $this->search_old_school_array( $sub_field_id, $fields[ $field_id ][ 'fields' ] ); |
|
| 1379 | 1379 | } |
| 1380 | 1380 | |
| 1381 | 1381 | return false === $sub_field_id ? false : array( $field_id, $sub_field_id ); |
@@ -205,8 +205,8 @@ discard block |
||
| 205 | 205 | $options = $this->field->options(); |
| 206 | 206 | |
| 207 | 207 | $fallback = $this->field->args( 'show_option_none' ); |
| 208 | - if ( ! $fallback && isset( $options[''] ) ) { |
|
| 209 | - $fallback = $options['']; |
|
| 208 | + if ( ! $fallback && isset( $options[ '' ] ) ) { |
|
| 209 | + $fallback = $options[ '' ]; |
|
| 210 | 210 | } |
| 211 | 211 | if ( ! $this->value && $fallback ) { |
| 212 | 212 | echo $fallback; |
@@ -234,9 +234,9 @@ discard block |
||
| 234 | 234 | $output = array(); |
| 235 | 235 | foreach ( $this->value as $val ) { |
| 236 | 236 | if ( isset( $options[ $val ] ) ) { |
| 237 | - $output[] = $options[ $val ]; |
|
| 237 | + $output[ ] = $options[ $val ]; |
|
| 238 | 238 | } else { |
| 239 | - $output[] = esc_attr( $val ); |
|
| 239 | + $output[ ] = esc_attr( $val ); |
|
| 240 | 240 | } |
| 241 | 241 | } |
| 242 | 242 | |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | if ( $datetime && $datetime instanceof DateTime ) { |
| 308 | 308 | $tz = $datetime->getTimezone(); |
| 309 | 309 | $tzstring = $tz->getName(); |
| 310 | - $this->value = $datetime->getTimestamp(); |
|
| 310 | + $this->value = $datetime->getTimestamp(); |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | $date = $this->field->get_timestamp_format( 'date_format', $this->value ); |
@@ -359,10 +359,10 @@ discard block |
||
| 359 | 359 | $terms = array(); |
| 360 | 360 | if ( is_array( $default ) ) { |
| 361 | 361 | foreach ( $default as $slug ) { |
| 362 | - $terms[] = get_term_by( 'slug', $slug, $taxonomy ); |
|
| 362 | + $terms[ ] = get_term_by( 'slug', $slug, $taxonomy ); |
|
| 363 | 363 | } |
| 364 | 364 | } else { |
| 365 | - $terms[] = get_term_by( 'slug', $default, $taxonomy ); |
|
| 365 | + $terms[ ] = get_term_by( 'slug', $default, $taxonomy ); |
|
| 366 | 366 | } |
| 367 | 367 | } |
| 368 | 368 | |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | $links = array(); |
| 372 | 372 | foreach ( $terms as $term ) { |
| 373 | 373 | $link = get_edit_term_link( $term->term_id, $taxonomy ); |
| 374 | - $links[] = '<a href="' . esc_url( $link ) . '">' . esc_html( $term->name ) . '</a>'; |
|
| 374 | + $links[ ] = '<a href="' . esc_url( $link ) . '">' . esc_html( $term->name ) . '</a>'; |
|
| 375 | 375 | } |
| 376 | 376 | // Then loop and output. |
| 377 | 377 | echo '<div class="cmb2-taxonomy-terms-', esc_attr( $taxonomy ), '">'; |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | 'class' => 'cmb-image-display', |
| 419 | 419 | ) ); |
| 420 | 420 | } else { |
| 421 | - $size = is_array( $img_size ) ? $img_size[0] : 200; |
|
| 421 | + $size = is_array( $img_size ) ? $img_size[ 0 ] : 200; |
|
| 422 | 422 | $image = '<img class="cmb-image-display" style="max-width: ' . absint( $size ) . 'px; width: 100%; height: auto;" src="' . $url_value . '" alt="" />'; |
| 423 | 423 | } |
| 424 | 424 | |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | ) ); |
| 50 | 50 | |
| 51 | 51 | $delete_args = $args; |
| 52 | - $delete_args['object_id']['required'] = true; |
|
| 53 | - $delete_args['object_type']['required'] = true; |
|
| 52 | + $delete_args[ 'object_id' ][ 'required' ] = true; |
|
| 53 | + $delete_args[ 'object_type' ][ 'required' ] = true; |
|
| 54 | 54 | |
| 55 | 55 | // Returns specific field data. |
| 56 | 56 | register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<cmb_id>[\w-]+)/fields/(?P<field_id>[\w-]+)', array( |
@@ -122,13 +122,13 @@ discard block |
||
| 122 | 122 | foreach ( $this->rest_box->cmb->prop( 'fields', array() ) as $field ) { |
| 123 | 123 | |
| 124 | 124 | // Make sure this field can be read. |
| 125 | - $this->field = $this->rest_box->field_can_read( $field['id'], true ); |
|
| 125 | + $this->field = $this->rest_box->field_can_read( $field[ 'id' ], true ); |
|
| 126 | 126 | |
| 127 | 127 | // And make sure current user can view this box. |
| 128 | 128 | if ( $this->field && $this->get_item_permissions_check_filter() ) { |
| 129 | - $fields[ $field['id'] ] = $this->server->response_to_data( |
|
| 129 | + $fields[ $field[ 'id' ] ] = $this->server->response_to_data( |
|
| 130 | 130 | $this->prepare_field_response(), |
| 131 | - isset( $this->request['_embed'] ) |
|
| 131 | + isset( $this->request[ '_embed' ] ) |
|
| 132 | 132 | ); |
| 133 | 133 | } |
| 134 | 134 | } |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | public function update_item( $request ) { |
| 233 | 233 | $this->initiate_rest_read_box( $request, 'field_value_update' ); |
| 234 | 234 | |
| 235 | - if ( ! $this->request['value'] ) { |
|
| 235 | + if ( ! $this->request[ 'value' ] ) { |
|
| 236 | 236 | return new WP_Error( 'cmb2_rest_update_field_error', __( 'CMB2 Field value cannot be updated without the value parameter specified.', 'cmb2' ), array( |
| 237 | 237 | 'status' => 400, |
| 238 | 238 | ) ); |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | */ |
| 294 | 294 | public function modify_field_value( $activity ) { |
| 295 | 295 | |
| 296 | - if ( ! $this->request['object_id'] || ! $this->request['object_type'] ) { |
|
| 296 | + if ( ! $this->request[ 'object_id' ] || ! $this->request[ 'object_type' ] ) { |
|
| 297 | 297 | return new WP_Error( 'cmb2_rest_modify_field_value_error', __( 'CMB2 Field value cannot be modified without the object_id and object_type parameters specified.', 'cmb2' ), array( |
| 298 | 298 | 'status' => 400, |
| 299 | 299 | ) ); |
@@ -316,11 +316,11 @@ discard block |
||
| 316 | 316 | |
| 317 | 317 | $this->field->args[ "value_{$activity}" ] = (bool) 'deleted' === $activity |
| 318 | 318 | ? $this->field->remove_data() |
| 319 | - : $this->field->save_field( $this->request['value'] ); |
|
| 319 | + : $this->field->save_field( $this->request[ 'value' ] ); |
|
| 320 | 320 | |
| 321 | 321 | // If options page, save the $activity options |
| 322 | - if ( 'options-page' == $this->request['object_type'] ) { |
|
| 323 | - $this->field->args[ "value_{$activity}" ] = cmb2_options( $this->request['object_id'] )->set(); |
|
| 322 | + if ( 'options-page' == $this->request[ 'object_type' ] ) { |
|
| 323 | + $this->field->args[ "value_{$activity}" ] = cmb2_options( $this->request[ 'object_id' ] )->set(); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | return $this->prepare_read_field( $this->field ); |
@@ -397,13 +397,13 @@ discard block |
||
| 397 | 397 | $value = $field->options(); |
| 398 | 398 | } elseif ( in_array( $key, CMB2_Field::$callable_fields, true ) ) { |
| 399 | 399 | |
| 400 | - if ( isset( $this->request['_rendered'] ) ) { |
|
| 400 | + if ( isset( $this->request[ '_rendered' ] ) ) { |
|
| 401 | 401 | $value = $key === 'render_row_cb' ? $rendered : $field->get_param_callback_result( $key ); |
| 402 | 402 | } elseif ( is_array( $value ) ) { |
| 403 | 403 | // We need to rewrite callbacks as string as they will cause |
| 404 | 404 | // JSON recursion errors. |
| 405 | - $class = is_string( $value[0] ) ? $value[0] : get_class( $value[0] ); |
|
| 406 | - $value = $class . '::' . $value[1]; |
|
| 405 | + $class = is_string( $value[ 0 ] ) ? $value[ 0 ] : get_class( $value[ 0 ] ); |
|
| 406 | + $value = $class . '::' . $value[ 1 ]; |
|
| 407 | 407 | } |
| 408 | 408 | } |
| 409 | 409 | |
@@ -416,8 +416,8 @@ discard block |
||
| 416 | 416 | } |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - if ( $this->request['object_id'] && $this->request['object_type'] ) { |
|
| 420 | - $field_data['value'] = $field->get_data(); |
|
| 419 | + if ( $this->request[ 'object_id' ] && $this->request[ 'object_type' ] ) { |
|
| 420 | + $field_data[ 'value' ] = $field->get_data(); |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | return $field_data; |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | if ( ! empty( $links ) ) { |
| 193 | - $data['_links'] = $links; |
|
| 193 | + $data[ '_links' ] = $links; |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | return $data; |
@@ -207,21 +207,21 @@ discard block |
||
| 207 | 207 | |
| 208 | 208 | $schema = $this->get_item_schema(); |
| 209 | 209 | foreach ( $data as $key => $value ) { |
| 210 | - if ( empty( $schema['properties'][ $key ] ) || empty( $schema['properties'][ $key ]['context'] ) ) { |
|
| 210 | + if ( empty( $schema[ 'properties' ][ $key ] ) || empty( $schema[ 'properties' ][ $key ][ 'context' ] ) ) { |
|
| 211 | 211 | continue; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - if ( ! in_array( $context, $schema['properties'][ $key ]['context'] ) ) { |
|
| 214 | + if ( ! in_array( $context, $schema[ 'properties' ][ $key ][ 'context' ] ) ) { |
|
| 215 | 215 | unset( $data[ $key ] ); |
| 216 | 216 | continue; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - if ( 'object' === $schema['properties'][ $key ]['type'] && ! empty( $schema['properties'][ $key ]['properties'] ) ) { |
|
| 220 | - foreach ( $schema['properties'][ $key ]['properties'] as $attribute => $details ) { |
|
| 221 | - if ( empty( $details['context'] ) ) { |
|
| 219 | + if ( 'object' === $schema[ 'properties' ][ $key ][ 'type' ] && ! empty( $schema[ 'properties' ][ $key ][ 'properties' ] ) ) { |
|
| 220 | + foreach ( $schema[ 'properties' ][ $key ][ 'properties' ] as $attribute => $details ) { |
|
| 221 | + if ( empty( $details[ 'context' ] ) ) { |
|
| 222 | 222 | continue; |
| 223 | 223 | } |
| 224 | - if ( ! in_array( $context, $details['context'] ) ) { |
|
| 224 | + if ( ! in_array( $context, $details[ 'context' ] ) ) { |
|
| 225 | 225 | if ( isset( $data[ $key ][ $attribute ] ) ) { |
| 226 | 226 | unset( $data[ $key ][ $attribute ] ); |
| 227 | 227 | } |
@@ -251,9 +251,9 @@ discard block |
||
| 251 | 251 | |
| 252 | 252 | $schema = $this->get_item_schema(); |
| 253 | 253 | |
| 254 | - foreach ( $schema['properties'] as &$property ) { |
|
| 255 | - if ( isset( $property['arg_options'] ) ) { |
|
| 256 | - unset( $property['arg_options'] ); |
|
| 254 | + foreach ( $schema[ 'properties' ] as &$property ) { |
|
| 255 | + if ( isset( $property[ 'arg_options' ] ) ) { |
|
| 256 | + unset( $property[ 'arg_options' ] ); |
|
| 257 | 257 | } |
| 258 | 258 | } |
| 259 | 259 | |
@@ -310,18 +310,18 @@ discard block |
||
| 310 | 310 | 'validate_callback' => 'rest_validate_request_arg', |
| 311 | 311 | ); |
| 312 | 312 | $schema = $this->get_item_schema(); |
| 313 | - if ( empty( $schema['properties'] ) ) { |
|
| 313 | + if ( empty( $schema[ 'properties' ] ) ) { |
|
| 314 | 314 | return array_merge( $param_details, $args ); |
| 315 | 315 | } |
| 316 | 316 | $contexts = array(); |
| 317 | - foreach ( $schema['properties'] as $attributes ) { |
|
| 318 | - if ( ! empty( $attributes['context'] ) ) { |
|
| 319 | - $contexts = array_merge( $contexts, $attributes['context'] ); |
|
| 317 | + foreach ( $schema[ 'properties' ] as $attributes ) { |
|
| 318 | + if ( ! empty( $attributes[ 'context' ] ) ) { |
|
| 319 | + $contexts = array_merge( $contexts, $attributes[ 'context' ] ); |
|
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | 322 | if ( ! empty( $contexts ) ) { |
| 323 | - $param_details['enum'] = array_unique( $contexts ); |
|
| 324 | - rsort( $param_details['enum'] ); |
|
| 323 | + $param_details[ 'enum' ] = array_unique( $contexts ); |
|
| 324 | + rsort( $param_details[ 'enum' ] ); |
|
| 325 | 325 | } |
| 326 | 326 | return array_merge( $param_details, $args ); |
| 327 | 327 | } |
@@ -339,11 +339,11 @@ discard block |
||
| 339 | 339 | |
| 340 | 340 | foreach ( $additional_fields as $field_name => $field_options ) { |
| 341 | 341 | |
| 342 | - if ( ! $field_options['get_callback'] ) { |
|
| 342 | + if ( ! $field_options[ 'get_callback' ] ) { |
|
| 343 | 343 | continue; |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | - $object[ $field_name ] = call_user_func( $field_options['get_callback'], $object, $field_name, $request, $this->get_object_type() ); |
|
| 346 | + $object[ $field_name ] = call_user_func( $field_options[ 'get_callback' ], $object, $field_name, $request, $this->get_object_type() ); |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | return $object; |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | |
| 362 | 362 | foreach ( $additional_fields as $field_name => $field_options ) { |
| 363 | 363 | |
| 364 | - if ( ! $field_options['update_callback'] ) { |
|
| 364 | + if ( ! $field_options[ 'update_callback' ] ) { |
|
| 365 | 365 | continue; |
| 366 | 366 | } |
| 367 | 367 | |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | continue; |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - call_user_func( $field_options['update_callback'], $request[ $field_name ], $object, $field_name, $request, $this->get_object_type() ); |
|
| 373 | + call_user_func( $field_options[ 'update_callback' ], $request[ $field_name ], $object, $field_name, $request, $this->get_object_type() ); |
|
| 374 | 374 | } |
| 375 | 375 | } |
| 376 | 376 | |
@@ -382,23 +382,23 @@ discard block |
||
| 382 | 382 | * @param array $schema Schema array. |
| 383 | 383 | */ |
| 384 | 384 | protected function add_additional_fields_schema( $schema ) { |
| 385 | - if ( empty( $schema['title'] ) ) { |
|
| 385 | + if ( empty( $schema[ 'title' ] ) ) { |
|
| 386 | 386 | return $schema; |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | /** |
| 390 | 390 | * Can't use $this->get_object_type otherwise we cause an inf loop. |
| 391 | 391 | */ |
| 392 | - $object_type = $schema['title']; |
|
| 392 | + $object_type = $schema[ 'title' ]; |
|
| 393 | 393 | |
| 394 | 394 | $additional_fields = $this->get_additional_fields( $object_type ); |
| 395 | 395 | |
| 396 | 396 | foreach ( $additional_fields as $field_name => $field_options ) { |
| 397 | - if ( ! $field_options['schema'] ) { |
|
| 397 | + if ( ! $field_options[ 'schema' ] ) { |
|
| 398 | 398 | continue; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - $schema['properties'][ $field_name ] = $field_options['schema']; |
|
| 401 | + $schema[ 'properties' ][ $field_name ] = $field_options[ 'schema' ]; |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | return $schema; |
@@ -437,11 +437,11 @@ discard block |
||
| 437 | 437 | protected function get_object_type() { |
| 438 | 438 | $schema = $this->get_item_schema(); |
| 439 | 439 | |
| 440 | - if ( ! $schema || ! isset( $schema['title'] ) ) { |
|
| 440 | + if ( ! $schema || ! isset( $schema[ 'title' ] ) ) { |
|
| 441 | 441 | return null; |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - return $schema['title']; |
|
| 444 | + return $schema[ 'title' ]; |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | /** |
@@ -457,13 +457,13 @@ discard block |
||
| 457 | 457 | public function get_endpoint_args_for_item_schema( $method = WP_REST_Server::CREATABLE ) { |
| 458 | 458 | |
| 459 | 459 | $schema = $this->get_item_schema(); |
| 460 | - $schema_properties = ! empty( $schema['properties'] ) ? $schema['properties'] : array(); |
|
| 460 | + $schema_properties = ! empty( $schema[ 'properties' ] ) ? $schema[ 'properties' ] : array(); |
|
| 461 | 461 | $endpoint_args = array(); |
| 462 | 462 | |
| 463 | 463 | foreach ( $schema_properties as $field_id => $params ) { |
| 464 | 464 | |
| 465 | 465 | // Arguments specified as `readonly` are not allowed to be set. |
| 466 | - if ( ! empty( $params['readonly'] ) ) { |
|
| 466 | + if ( ! empty( $params[ 'readonly' ] ) ) { |
|
| 467 | 467 | continue; |
| 468 | 468 | } |
| 469 | 469 | |
@@ -472,16 +472,16 @@ discard block |
||
| 472 | 472 | 'sanitize_callback' => 'rest_sanitize_request_arg', |
| 473 | 473 | ); |
| 474 | 474 | |
| 475 | - if ( isset( $params['description'] ) ) { |
|
| 476 | - $endpoint_args[ $field_id ]['description'] = $params['description']; |
|
| 475 | + if ( isset( $params[ 'description' ] ) ) { |
|
| 476 | + $endpoint_args[ $field_id ][ 'description' ] = $params[ 'description' ]; |
|
| 477 | 477 | } |
| 478 | 478 | |
| 479 | - if ( WP_REST_Server::CREATABLE === $method && isset( $params['default'] ) ) { |
|
| 480 | - $endpoint_args[ $field_id ]['default'] = $params['default']; |
|
| 479 | + if ( WP_REST_Server::CREATABLE === $method && isset( $params[ 'default' ] ) ) { |
|
| 480 | + $endpoint_args[ $field_id ][ 'default' ] = $params[ 'default' ]; |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | - if ( WP_REST_Server::CREATABLE === $method && ! empty( $params['required'] ) ) { |
|
| 484 | - $endpoint_args[ $field_id ]['required'] = true; |
|
| 483 | + if ( WP_REST_Server::CREATABLE === $method && ! empty( $params[ 'required' ] ) ) { |
|
| 484 | + $endpoint_args[ $field_id ][ 'required' ] = true; |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | foreach ( array( 'type', 'format', 'enum' ) as $schema_prop ) { |
@@ -491,17 +491,17 @@ discard block |
||
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | // Merge in any options provided by the schema property. |
| 494 | - if ( isset( $params['arg_options'] ) ) { |
|
| 494 | + if ( isset( $params[ 'arg_options' ] ) ) { |
|
| 495 | 495 | |
| 496 | 496 | // Only use required / default from arg_options on CREATABLE endpoints. |
| 497 | 497 | if ( WP_REST_Server::CREATABLE !== $method ) { |
| 498 | - $params['arg_options'] = array_diff_key( $params['arg_options'], array( |
|
| 498 | + $params[ 'arg_options' ] = array_diff_key( $params[ 'arg_options' ], array( |
|
| 499 | 499 | 'required' => '', |
| 500 | 500 | 'default' => '', |
| 501 | 501 | ) ); |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | - $endpoint_args[ $field_id ] = array_merge( $endpoint_args[ $field_id ], $params['arg_options'] ); |
|
| 504 | + $endpoint_args[ $field_id ] = array_merge( $endpoint_args[ $field_id ], $params[ 'arg_options' ] ); |
|
| 505 | 505 | } |
| 506 | 506 | }// End foreach(). |
| 507 | 507 | |
@@ -24,15 +24,15 @@ discard block |
||
| 24 | 24 | $img_size_data = parent::get_image_size_data( $img_size, 'large' ); |
| 25 | 25 | |
| 26 | 26 | // if options array and 'url' => false, then hide the url field |
| 27 | - $input_type = array_key_exists( 'url', $options ) && false === $options['url'] ? 'hidden' : 'text'; |
|
| 27 | + $input_type = array_key_exists( 'url', $options ) && false === $options[ 'url' ] ? 'hidden' : 'text'; |
|
| 28 | 28 | |
| 29 | 29 | $output .= parent::render( array( |
| 30 | 30 | 'type' => $input_type, |
| 31 | 31 | 'class' => 'cmb2-upload-file regular-text', |
| 32 | 32 | 'size' => 45, |
| 33 | 33 | 'desc' => '', |
| 34 | - 'data-previewsize' => sprintf( '[%d,%d]', $img_size_data['width'], $img_size_data['height'] ), |
|
| 35 | - 'data-sizename' => $img_size_data['name'], |
|
| 34 | + 'data-previewsize' => sprintf( '[%d,%d]', $img_size_data[ 'width' ], $img_size_data[ 'height' ] ), |
|
| 35 | + 'data-sizename' => $img_size_data[ 'name' ], |
|
| 36 | 36 | 'data-queryargs' => ! empty( $query_args ) ? json_encode( $query_args ) : '', |
| 37 | 37 | 'js_dependencies' => 'media-editor', |
| 38 | 38 | ) ); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | 'class' => 'cmb-file-field-image', |
| 83 | 83 | ) ); |
| 84 | 84 | } else { |
| 85 | - $image = '<img style="max-width: ' . absint( $img_size_data['width'] ) . 'px; width: 100%;" src="' . $meta_value . '" class="cmb-file-field-image" alt="" />'; |
|
| 85 | + $image = '<img style="max-width: ' . absint( $img_size_data[ 'width' ] ) . 'px; width: 100%;" src="' . $meta_value . '" class="cmb-file-field-image" alt="" />'; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | $output .= $this->img_status_output( array( |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | ) ); |
| 31 | 31 | |
| 32 | 32 | if ( ! $field->group ) { |
| 33 | - return $this->rendered( $this->get_wp_editor( $a ) . $a['desc'] ); |
|
| 33 | + return $this->rendered( $this->get_wp_editor( $a ) . $a[ 'desc' ] ); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | // wysiwyg fields in a group need some special handling. |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | protected function get_wp_editor( $args ) { |
| 56 | 56 | ob_start(); |
| 57 | - wp_editor( $args['value'], $args['id'], $args['options'] ); |
|
| 57 | + wp_editor( $args[ 'value' ], $args[ 'id' ], $args[ 'options' ] ); |
|
| 58 | 58 | return ob_get_clean(); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $group_id = $this->field->group->id(); |
| 63 | 63 | $field_id = $this->field->id( true ); |
| 64 | 64 | $options = $this->field->options(); |
| 65 | - $options['textarea_name'] = 'cmb2_n_' . $group_id . $field_id; |
|
| 65 | + $options[ 'textarea_name' ] = 'cmb2_n_' . $group_id . $field_id; |
|
| 66 | 66 | |
| 67 | 67 | // Initate the editor with special id/value/name so we can retrieve the options in JS. |
| 68 | 68 | $editor = $this->get_wp_editor( array( |
@@ -122,21 +122,21 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | public function __construct( $args ) { |
| 124 | 124 | |
| 125 | - if ( ! empty( $args['group_field'] ) ) { |
|
| 126 | - $this->group = $args['group_field']; |
|
| 125 | + if ( ! empty( $args[ 'group_field' ] ) ) { |
|
| 126 | + $this->group = $args[ 'group_field' ]; |
|
| 127 | 127 | $this->object_id = $this->group->object_id; |
| 128 | 128 | $this->object_type = $this->group->object_type; |
| 129 | 129 | $this->cmb_id = $this->group->cmb_id; |
| 130 | 130 | } else { |
| 131 | - $this->object_id = isset( $args['object_id'] ) && '_' !== $args['object_id'] ? $args['object_id'] : 0; |
|
| 132 | - $this->object_type = isset( $args['object_type'] ) ? $args['object_type'] : 'post'; |
|
| 131 | + $this->object_id = isset( $args[ 'object_id' ] ) && '_' !== $args[ 'object_id' ] ? $args[ 'object_id' ] : 0; |
|
| 132 | + $this->object_type = isset( $args[ 'object_type' ] ) ? $args[ 'object_type' ] : 'post'; |
|
| 133 | 133 | |
| 134 | - if ( isset( $args['cmb_id'] ) ) { |
|
| 135 | - $this->cmb_id = $args['cmb_id']; |
|
| 134 | + if ( isset( $args[ 'cmb_id' ] ) ) { |
|
| 135 | + $this->cmb_id = $args[ 'cmb_id' ]; |
|
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - $this->args = $this->_set_field_defaults( $args['field_args'], $args ); |
|
| 139 | + $this->args = $this->_set_field_defaults( $args[ 'field_args' ], $args ); |
|
| 140 | 140 | |
| 141 | 141 | if ( $this->object_id ) { |
| 142 | 142 | $this->value = $this->get_data(); |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | return call_user_func_array( array( $this, 'get_string' ), $arguments ); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - $key = isset( $arguments[0] ) ? $arguments[0] : false; |
|
| 159 | + $key = isset( $arguments[ 0 ] ) ? $arguments[ 0 ] : false; |
|
| 160 | 160 | return $this->args( $name, $key ); |
| 161 | 161 | } |
| 162 | 162 | |
@@ -232,9 +232,9 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | public function get_data( $field_id = '', $args = array() ) { |
| 234 | 234 | if ( $field_id ) { |
| 235 | - $args['field_id'] = $field_id; |
|
| 235 | + $args[ 'field_id' ] = $field_id; |
|
| 236 | 236 | } elseif ( $this->group ) { |
| 237 | - $args['field_id'] = $this->group->id(); |
|
| 237 | + $args[ 'field_id' ] = $this->group->id(); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | $a = $this->data_args( $args ); |
@@ -275,13 +275,13 @@ discard block |
||
| 275 | 275 | * |
| 276 | 276 | * @since 2.0.0 |
| 277 | 277 | */ |
| 278 | - $data = apply_filters( "cmb2_override_{$a['field_id']}_meta_value", $data, $this->object_id, $a, $this ); |
|
| 278 | + $data = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_value", $data, $this->object_id, $a, $this ); |
|
| 279 | 279 | |
| 280 | 280 | // If no override, get value normally |
| 281 | 281 | if ( 'cmb2_field_no_override_val' === $data ) { |
| 282 | - $data = 'options-page' === $a['type'] |
|
| 283 | - ? cmb2_options( $a['id'] )->get( $a['field_id'] ) |
|
| 284 | - : get_metadata( $a['type'], $a['id'], $a['field_id'], ( $a['single'] || $a['repeat'] ) ); |
|
| 282 | + $data = 'options-page' === $a[ 'type' ] |
|
| 283 | + ? cmb2_options( $a[ 'id' ] )->get( $a[ 'field_id' ] ) |
|
| 284 | + : get_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], ( $a[ 'single' ] || $a[ 'repeat' ] ) ); |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | if ( $this->group ) { |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | 'single' => $single, |
| 307 | 307 | ) ); |
| 308 | 308 | |
| 309 | - $a['value'] = $a['repeat'] ? array_values( $new_value ) : $new_value; |
|
| 309 | + $a[ 'value' ] = $a[ 'repeat' ] ? array_values( $new_value ) : $new_value; |
|
| 310 | 310 | |
| 311 | 311 | /** |
| 312 | 312 | * Filter whether to override saving of meta value. |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | * |
| 343 | 343 | * @since 2.0.0 |
| 344 | 344 | */ |
| 345 | - $override = apply_filters( "cmb2_override_{$a['field_id']}_meta_save", $override, $a, $this->args(), $this ); |
|
| 345 | + $override = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_save", $override, $a, $this->args(), $this ); |
|
| 346 | 346 | |
| 347 | 347 | // If override, return that |
| 348 | 348 | if ( null !== $override ) { |
@@ -350,22 +350,22 @@ discard block |
||
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | // Options page handling (or temp data store) |
| 353 | - if ( 'options-page' === $a['type'] || empty( $a['id'] ) ) { |
|
| 354 | - return cmb2_options( $a['id'] )->update( $a['field_id'], $a['value'], false, $a['single'] ); |
|
| 353 | + if ( 'options-page' === $a[ 'type' ] || empty( $a[ 'id' ] ) ) { |
|
| 354 | + return cmb2_options( $a[ 'id' ] )->update( $a[ 'field_id' ], $a[ 'value' ], false, $a[ 'single' ] ); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | // Add metadata if not single |
| 358 | - if ( ! $a['single'] ) { |
|
| 359 | - return add_metadata( $a['type'], $a['id'], $a['field_id'], $a['value'], false ); |
|
| 358 | + if ( ! $a[ 'single' ] ) { |
|
| 359 | + return add_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $a[ 'value' ], false ); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | // Delete meta if we have an empty array |
| 363 | - if ( is_array( $a['value'] ) && empty( $a['value'] ) ) { |
|
| 364 | - return delete_metadata( $a['type'], $a['id'], $a['field_id'], $this->value ); |
|
| 363 | + if ( is_array( $a[ 'value' ] ) && empty( $a[ 'value' ] ) ) { |
|
| 364 | + return delete_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $this->value ); |
|
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | // Update metadata |
| 368 | - return update_metadata( $a['type'], $a['id'], $a['field_id'], $a['value'] ); |
|
| 368 | + return update_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $a[ 'value' ] ); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | /** |
@@ -418,19 +418,19 @@ discard block |
||
| 418 | 418 | * @param array $field_args All field arguments |
| 419 | 419 | * @param CMB2_Field object $field This field object |
| 420 | 420 | */ |
| 421 | - $override = apply_filters( "cmb2_override_{$a['field_id']}_meta_remove", $override, $a, $this->args(), $this ); |
|
| 421 | + $override = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_remove", $override, $a, $this->args(), $this ); |
|
| 422 | 422 | |
| 423 | 423 | // If no override, remove as usual |
| 424 | 424 | if ( null !== $override ) { |
| 425 | 425 | return $override; |
| 426 | 426 | } // End if(). |
| 427 | 427 | // Option page handling. |
| 428 | - elseif ( 'options-page' === $a['type'] || empty( $a['id'] ) ) { |
|
| 429 | - return cmb2_options( $a['id'] )->remove( $a['field_id'] ); |
|
| 428 | + elseif ( 'options-page' === $a[ 'type' ] || empty( $a[ 'id' ] ) ) { |
|
| 429 | + return cmb2_options( $a[ 'id' ] )->remove( $a[ 'field_id' ] ); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | // Remove metadata |
| 433 | - return delete_metadata( $a['type'], $a['id'], $a['field_id'], $old ); |
|
| 433 | + return delete_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $old ); |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | /** |
@@ -897,7 +897,7 @@ discard block |
||
| 897 | 897 | |
| 898 | 898 | foreach ( $conditional_classes as $class => $condition ) { |
| 899 | 899 | if ( $condition ) { |
| 900 | - $classes[] = $class; |
|
| 900 | + $classes[ ] = $class; |
|
| 901 | 901 | } |
| 902 | 902 | } |
| 903 | 903 | |
@@ -908,7 +908,7 @@ discard block |
||
| 908 | 908 | } |
| 909 | 909 | |
| 910 | 910 | if ( $added_classes ) { |
| 911 | - $classes[] = esc_attr( $added_classes ); |
|
| 911 | + $classes[ ] = esc_attr( $added_classes ); |
|
| 912 | 912 | } |
| 913 | 913 | |
| 914 | 914 | /** |
@@ -1011,10 +1011,10 @@ discard block |
||
| 1011 | 1011 | public function get_string( $text_key, $fallback ) { |
| 1012 | 1012 | // If null, populate with our field strings values. |
| 1013 | 1013 | if ( null === $this->strings ) { |
| 1014 | - $this->strings = (array) $this->args['text']; |
|
| 1014 | + $this->strings = (array) $this->args[ 'text' ]; |
|
| 1015 | 1015 | |
| 1016 | - if ( is_callable( $this->args['text_cb'] ) ) { |
|
| 1017 | - $strings = call_user_func( $this->args['text_cb'], $this ); |
|
| 1016 | + if ( is_callable( $this->args[ 'text_cb' ] ) ) { |
|
| 1017 | + $strings = call_user_func( $this->args[ 'text_cb' ], $this ); |
|
| 1018 | 1018 | |
| 1019 | 1019 | if ( $strings && is_array( $strings ) ) { |
| 1020 | 1020 | $this->strings += $strings; |
@@ -1049,10 +1049,10 @@ discard block |
||
| 1049 | 1049 | return $this->field_options; |
| 1050 | 1050 | } |
| 1051 | 1051 | |
| 1052 | - $this->field_options = (array) $this->args['options']; |
|
| 1052 | + $this->field_options = (array) $this->args[ 'options' ]; |
|
| 1053 | 1053 | |
| 1054 | - if ( is_callable( $this->args['options_cb'] ) ) { |
|
| 1055 | - $options = call_user_func( $this->args['options_cb'], $this ); |
|
| 1054 | + if ( is_callable( $this->args[ 'options_cb' ] ) ) { |
|
| 1055 | + $options = call_user_func( $this->args[ 'options_cb' ], $this ); |
|
| 1056 | 1056 | |
| 1057 | 1057 | if ( $options && is_array( $options ) ) { |
| 1058 | 1058 | $this->field_options = $options + $this->field_options; |
@@ -1074,7 +1074,7 @@ discard block |
||
| 1074 | 1074 | */ |
| 1075 | 1075 | public function add_js_dependencies( $dependencies = array() ) { |
| 1076 | 1076 | foreach ( (array) $dependencies as $dependency ) { |
| 1077 | - $this->args['js_dependencies'][ $dependency ] = $dependency; |
|
| 1077 | + $this->args[ 'js_dependencies' ][ $dependency ] = $dependency; |
|
| 1078 | 1078 | } |
| 1079 | 1079 | |
| 1080 | 1080 | CMB2_JS::add_dependencies( $dependencies ); |
@@ -1088,17 +1088,17 @@ discard block |
||
| 1088 | 1088 | * @return mixed Default field value |
| 1089 | 1089 | */ |
| 1090 | 1090 | public function get_default() { |
| 1091 | - if ( null !== $this->args['default'] ) { |
|
| 1092 | - return $this->args['default']; |
|
| 1091 | + if ( null !== $this->args[ 'default' ] ) { |
|
| 1092 | + return $this->args[ 'default' ]; |
|
| 1093 | 1093 | } |
| 1094 | 1094 | |
| 1095 | - $param = is_callable( $this->args['default_cb'] ) ? 'default_cb' : 'default'; |
|
| 1095 | + $param = is_callable( $this->args[ 'default_cb' ] ) ? 'default_cb' : 'default'; |
|
| 1096 | 1096 | $default = $this->get_param_callback_result( $param ); |
| 1097 | 1097 | |
| 1098 | 1098 | // Allow a filter override of the default value |
| 1099 | - $this->args['default'] = apply_filters( 'cmb2_default_filter', $default, $this ); |
|
| 1099 | + $this->args[ 'default' ] = apply_filters( 'cmb2_default_filter', $default, $this ); |
|
| 1100 | 1100 | |
| 1101 | - return $this->args['default']; |
|
| 1101 | + return $this->args[ 'default' ]; |
|
| 1102 | 1102 | } |
| 1103 | 1103 | |
| 1104 | 1104 | /** |
@@ -1129,18 +1129,18 @@ discard block |
||
| 1129 | 1129 | 'classes_cb' => '', |
| 1130 | 1130 | 'select_all_button' => true, |
| 1131 | 1131 | 'multiple' => false, |
| 1132 | - 'repeatable' => isset( $args['type'] ) && 'group' == $args['type'], |
|
| 1132 | + 'repeatable' => isset( $args[ 'type' ] ) && 'group' == $args[ 'type' ], |
|
| 1133 | 1133 | 'inline' => false, |
| 1134 | 1134 | 'on_front' => true, |
| 1135 | 1135 | 'show_names' => true, |
| 1136 | 1136 | 'save_field' => true, // Will not save if false |
| 1137 | 1137 | 'date_format' => 'm\/d\/Y', |
| 1138 | 1138 | 'time_format' => 'h:i A', |
| 1139 | - 'description' => isset( $args['desc'] ) ? $args['desc'] : '', |
|
| 1140 | - 'preview_size' => 'file' == $args['type'] ? array( 350, 350 ) : array( 50, 50 ), |
|
| 1139 | + 'description' => isset( $args[ 'desc' ] ) ? $args[ 'desc' ] : '', |
|
| 1140 | + 'preview_size' => 'file' == $args[ 'type' ] ? array( 350, 350 ) : array( 50, 50 ), |
|
| 1141 | 1141 | 'render_row_cb' => array( $this, 'render_field_callback' ), |
| 1142 | 1142 | 'display_cb' => array( $this, 'display_value_callback' ), |
| 1143 | - 'label_cb' => 'title' != $args['type'] ? array( $this, 'label' ) : '', |
|
| 1143 | + 'label_cb' => 'title' != $args[ 'type' ] ? array( $this, 'label' ) : '', |
|
| 1144 | 1144 | 'column' => false, |
| 1145 | 1145 | 'js_dependencies' => array(), |
| 1146 | 1146 | 'show_in_rest' => null, |
@@ -1155,43 +1155,43 @@ discard block |
||
| 1155 | 1155 | */ |
| 1156 | 1156 | $args = $this->convert_deprecated_params( $args ); |
| 1157 | 1157 | |
| 1158 | - $args['repeatable'] = $args['repeatable'] && ! $this->repeatable_exception( $args['type'] ); |
|
| 1159 | - $args['inline'] = $args['inline'] || false !== stripos( $args['type'], '_inline' ); |
|
| 1158 | + $args[ 'repeatable' ] = $args[ 'repeatable' ] && ! $this->repeatable_exception( $args[ 'type' ] ); |
|
| 1159 | + $args[ 'inline' ] = $args[ 'inline' ] || false !== stripos( $args[ 'type' ], '_inline' ); |
|
| 1160 | 1160 | |
| 1161 | - $args['options'] = 'group' == $args['type'] ? wp_parse_args( $args['options'], array( |
|
| 1161 | + $args[ 'options' ] = 'group' == $args[ 'type' ] ? wp_parse_args( $args[ 'options' ], array( |
|
| 1162 | 1162 | 'add_button' => esc_html__( 'Add Group', 'cmb2' ), |
| 1163 | 1163 | 'remove_button' => esc_html__( 'Remove Group', 'cmb2' ), |
| 1164 | - ) ) : $args['options']; |
|
| 1164 | + ) ) : $args[ 'options' ]; |
|
| 1165 | 1165 | |
| 1166 | - $args['_id'] = $args['id']; |
|
| 1167 | - $args['_name'] = $args['id']; |
|
| 1166 | + $args[ '_id' ] = $args[ 'id' ]; |
|
| 1167 | + $args[ '_name' ] = $args[ 'id' ]; |
|
| 1168 | 1168 | |
| 1169 | 1169 | if ( $this->group ) { |
| 1170 | 1170 | |
| 1171 | - $args['id'] = $this->group->args( 'id' ) . '_' . $this->group->index . '_' . $args['id']; |
|
| 1172 | - $args['_name'] = $this->group->args( 'id' ) . '[' . $this->group->index . '][' . $args['_name'] . ']'; |
|
| 1171 | + $args[ 'id' ] = $this->group->args( 'id' ) . '_' . $this->group->index . '_' . $args[ 'id' ]; |
|
| 1172 | + $args[ '_name' ] = $this->group->args( 'id' ) . '[' . $this->group->index . '][' . $args[ '_name' ] . ']'; |
|
| 1173 | 1173 | } |
| 1174 | 1174 | |
| 1175 | - if ( 'wysiwyg' == $args['type'] ) { |
|
| 1176 | - $args['id'] = strtolower( str_ireplace( '-', '_', $args['id'] ) ); |
|
| 1177 | - $args['options']['textarea_name'] = $args['_name']; |
|
| 1175 | + if ( 'wysiwyg' == $args[ 'type' ] ) { |
|
| 1176 | + $args[ 'id' ] = strtolower( str_ireplace( '-', '_', $args[ 'id' ] ) ); |
|
| 1177 | + $args[ 'options' ][ 'textarea_name' ] = $args[ '_name' ]; |
|
| 1178 | 1178 | } |
| 1179 | 1179 | |
| 1180 | 1180 | $option_types = apply_filters( 'cmb2_all_or_nothing_types', array( 'select', 'radio', 'radio_inline', 'taxonomy_select', 'taxonomy_radio', 'taxonomy_radio_inline' ), $this ); |
| 1181 | 1181 | |
| 1182 | - if ( in_array( $args['type'], $option_types, true ) ) { |
|
| 1182 | + if ( in_array( $args[ 'type' ], $option_types, true ) ) { |
|
| 1183 | 1183 | |
| 1184 | - $args['show_option_none'] = isset( $args['show_option_none'] ) ? $args['show_option_none'] : null; |
|
| 1185 | - $args['show_option_none'] = true === $args['show_option_none'] ? esc_html__( 'None', 'cmb2' ) : $args['show_option_none']; |
|
| 1184 | + $args[ 'show_option_none' ] = isset( $args[ 'show_option_none' ] ) ? $args[ 'show_option_none' ] : null; |
|
| 1185 | + $args[ 'show_option_none' ] = true === $args[ 'show_option_none' ] ? esc_html__( 'None', 'cmb2' ) : $args[ 'show_option_none' ]; |
|
| 1186 | 1186 | |
| 1187 | - if ( null === $args['show_option_none'] ) { |
|
| 1188 | - $off_by_default = in_array( $args['type'], array( 'select', 'radio', 'radio_inline' ), true ); |
|
| 1189 | - $args['show_option_none'] = $off_by_default ? false : esc_html__( 'None', 'cmb2' ); |
|
| 1187 | + if ( null === $args[ 'show_option_none' ] ) { |
|
| 1188 | + $off_by_default = in_array( $args[ 'type' ], array( 'select', 'radio', 'radio_inline' ), true ); |
|
| 1189 | + $args[ 'show_option_none' ] = $off_by_default ? false : esc_html__( 'None', 'cmb2' ); |
|
| 1190 | 1190 | } |
| 1191 | 1191 | } |
| 1192 | 1192 | |
| 1193 | - $args['has_supporting_data'] = in_array( |
|
| 1194 | - $args['type'], |
|
| 1193 | + $args[ 'has_supporting_data' ] = in_array( |
|
| 1194 | + $args[ 'type' ], |
|
| 1195 | 1195 | array( |
| 1196 | 1196 | // CMB2_Sanitize::_save_file_id_value()/CMB2_Sanitize::_get_group_file_value_array() |
| 1197 | 1197 | 'file', |
@@ -1215,10 +1215,10 @@ discard block |
||
| 1215 | 1215 | protected function get_default_args( $field_args, $field_group = null ) { |
| 1216 | 1216 | $args = parent::get_default_args( array(), $this->group ); |
| 1217 | 1217 | |
| 1218 | - if ( isset( $field_args['field_args'] ) ) { |
|
| 1218 | + if ( isset( $field_args[ 'field_args' ] ) ) { |
|
| 1219 | 1219 | $args = wp_parse_args( $field_args, $args ); |
| 1220 | 1220 | } else { |
| 1221 | - $args['field_args'] = wp_parse_args( $field_args, $this->args ); |
|
| 1221 | + $args[ 'field_args' ] = wp_parse_args( $field_args, $this->args ); |
|
| 1222 | 1222 | } |
| 1223 | 1223 | |
| 1224 | 1224 | return $args; |
@@ -1262,41 +1262,41 @@ discard block |
||
| 1262 | 1262 | */ |
| 1263 | 1263 | protected function convert_deprecated_params( $args ) { |
| 1264 | 1264 | |
| 1265 | - if ( isset( $args['row_classes'] ) ) { |
|
| 1265 | + if ( isset( $args[ 'row_classes' ] ) ) { |
|
| 1266 | 1266 | |
| 1267 | 1267 | // We'll let this one be. |
| 1268 | 1268 | // $this->deprecated_param( __CLASS__ . '::__construct()', '2.2.3', self::DEPRECATED_PARAM, 'row_classes', 'classes' ); |
| 1269 | 1269 | // row_classes param could be a callback. This is definitely deprecated. |
| 1270 | - if ( is_callable( $args['row_classes'] ) ) { |
|
| 1270 | + if ( is_callable( $args[ 'row_classes' ] ) ) { |
|
| 1271 | 1271 | |
| 1272 | 1272 | $this->deprecated_param( __CLASS__ . '::__construct()', '2.2.3', self::DEPRECATED_CB_PARAM, 'row_classes', 'classes_cb' ); |
| 1273 | 1273 | |
| 1274 | - $args['classes_cb'] = $args['row_classes']; |
|
| 1275 | - $args['classes'] = null; |
|
| 1274 | + $args[ 'classes_cb' ] = $args[ 'row_classes' ]; |
|
| 1275 | + $args[ 'classes' ] = null; |
|
| 1276 | 1276 | } else { |
| 1277 | 1277 | |
| 1278 | - $args['classes'] = $args['row_classes']; |
|
| 1278 | + $args[ 'classes' ] = $args[ 'row_classes' ]; |
|
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | - unset( $args['row_classes'] ); |
|
| 1281 | + unset( $args[ 'row_classes' ] ); |
|
| 1282 | 1282 | } |
| 1283 | 1283 | |
| 1284 | 1284 | // default param can be passed a callback as well |
| 1285 | - if ( is_callable( $args['default'] ) ) { |
|
| 1285 | + if ( is_callable( $args[ 'default' ] ) ) { |
|
| 1286 | 1286 | |
| 1287 | 1287 | $this->deprecated_param( __CLASS__ . '::__construct()', '2.2.3', self::DEPRECATED_CB_PARAM, 'default', 'default_cb' ); |
| 1288 | 1288 | |
| 1289 | - $args['default_cb'] = $args['default']; |
|
| 1290 | - $args['default'] = null; |
|
| 1289 | + $args[ 'default_cb' ] = $args[ 'default' ]; |
|
| 1290 | + $args[ 'default' ] = null; |
|
| 1291 | 1291 | } |
| 1292 | 1292 | |
| 1293 | 1293 | // options param can be passed a callback as well |
| 1294 | - if ( is_callable( $args['options'] ) ) { |
|
| 1294 | + if ( is_callable( $args[ 'options' ] ) ) { |
|
| 1295 | 1295 | |
| 1296 | 1296 | $this->deprecated_param( __CLASS__ . '::__construct()', '2.2.3', self::DEPRECATED_CB_PARAM, 'options', 'options_cb' ); |
| 1297 | 1297 | |
| 1298 | - $args['options_cb'] = $args['options']; |
|
| 1299 | - $args['options'] = array(); |
|
| 1298 | + $args[ 'options_cb' ] = $args[ 'options' ]; |
|
| 1299 | + $args[ 'options' ] = array(); |
|
| 1300 | 1300 | } |
| 1301 | 1301 | |
| 1302 | 1302 | return $args; |