@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Bootstraps the CMB2 process |
|
4 | - * |
|
5 | - * @category WordPress_Plugin |
|
6 | - * @package CMB2 |
|
7 | - * @author WebDevStudios |
|
8 | - * @license GPL-2.0+ |
|
9 | - * @link http://webdevstudios.com |
|
10 | - */ |
|
3 | + * Bootstraps the CMB2 process |
|
4 | + * |
|
5 | + * @category WordPress_Plugin |
|
6 | + * @package CMB2 |
|
7 | + * @author WebDevStudios |
|
8 | + * @license GPL-2.0+ |
|
9 | + * @link http://webdevstudios.com |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * Function to encapsulate the CMB2 bootstrap process. |
@@ -74,7 +74,7 @@ |
||
74 | 74 | * Retrieve all CMB2 instances that have the specified property set. |
75 | 75 | * @since 2.2.0 |
76 | 76 | * @param string $property Property name. |
77 | - * @param mixed $ignore The value to ignore. |
|
77 | + * @param boolean $ignore The value to ignore. |
|
78 | 78 | * @return CMB2[] Array of matching cmb2 instances. |
79 | 79 | */ |
80 | 80 | public static function get_by_property( $property, $ignore = null ) { |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | /** |
153 | 153 | * Handler for updating custom field data. |
154 | 154 | * @since 2.2.0 |
155 | - * @param mixed $value The value of the field |
|
155 | + * @param mixed $values The value of the field |
|
156 | 156 | * @param object $object The object from the response |
157 | 157 | * @param string $field_id Name of field |
158 | 158 | * @return bool|int |
@@ -233,6 +233,9 @@ discard block |
||
233 | 233 | return $protected; |
234 | 234 | } |
235 | 235 | |
236 | + /** |
|
237 | + * @param string $field_id |
|
238 | + */ |
|
236 | 239 | public function field_can_update( $field_id ) { |
237 | 240 | |
238 | 241 | $field = $this->cmb->get_field( $field_id ); |
@@ -88,14 +88,14 @@ discard block |
||
88 | 88 | |
89 | 89 | protected function prepare_read_write_fields() { |
90 | 90 | foreach ( $this->cmb->prop( 'fields' ) as $field ) { |
91 | - $show_in_rest = isset( $field['show_in_rest'] ) ? $field['show_in_rest'] : null; |
|
91 | + $show_in_rest = isset( $field[ 'show_in_rest' ] ) ? $field[ 'show_in_rest' ] : null; |
|
92 | 92 | |
93 | 93 | if ( false === $show_in_rest ) { |
94 | 94 | continue; |
95 | 95 | } |
96 | 96 | |
97 | - $this->maybe_add_read_field( $field['id'], $show_in_rest ); |
|
98 | - $this->maybe_add_write_field( $field['id'], $show_in_rest ); |
|
97 | + $this->maybe_add_read_field( $field[ 'id' ], $show_in_rest ); |
|
98 | + $this->maybe_add_write_field( $field[ 'id' ], $show_in_rest ); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | : in_array( $show_in_rest, array( 'read_and_write', 'read_only' ), true ); |
106 | 106 | |
107 | 107 | if ( $can_read ) { |
108 | - self::$read_fields[ $this->cmb->cmb_id ][] = $field_id; |
|
108 | + self::$read_fields[ $this->cmb->cmb_id ][ ] = $field_id; |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | : in_array( $show_in_rest, array( 'read_and_write', 'write_only' ), true ); |
116 | 116 | |
117 | 117 | if ( $can_update ) { |
118 | - self::$write_fields[ $this->cmb->cmb_id ][] = $field_id; |
|
118 | + self::$write_fields[ $this->cmb->cmb_id ][ ] = $field_id; |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
@@ -129,14 +129,14 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public static function get_restable_field_values( $object, $field_id, $request ) { |
131 | 131 | $values = array(); |
132 | - if ( ! isset( $object['id'] ) ) { |
|
132 | + if ( ! isset( $object[ 'id' ] ) ) { |
|
133 | 133 | return; |
134 | 134 | } |
135 | 135 | |
136 | 136 | foreach ( self::$read_fields as $cmb_id => $fields ) { |
137 | 137 | foreach ( $fields as $field_id ) { |
138 | 138 | $field = self::$boxes[ $cmb_id ]->get_field( $field_id ); |
139 | - $field->object_id = $object['id']; |
|
139 | + $field->object_id = $object[ 'id' ]; |
|
140 | 140 | |
141 | 141 | if ( isset( $object->type ) ) { |
142 | 142 | $field->object_type = $object->type; |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | return; |
168 | 168 | } |
169 | 169 | |
170 | - $object_id = $data['object_id']; |
|
171 | - $object_type = $data['object_type']; |
|
170 | + $object_id = $data[ 'object_id' ]; |
|
171 | + $object_type = $data[ 'object_type' ]; |
|
172 | 172 | $updated = array(); |
173 | 173 | |
174 | 174 | foreach ( self::$write_fields as $cmb_id => $fields ) { |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | } elseif ( isset( $object->comment_ID ) ) { |
253 | 253 | $object_id = intval( $object->comment_ID ); |
254 | 254 | $object_type = 'comment'; |
255 | - } elseif ( is_array( $object ) && isset( $object['term_id'] ) ) { |
|
256 | - $object_id = intval( $object['term_id'] ); |
|
255 | + } elseif ( is_array( $object ) && isset( $object[ 'term_id' ] ) ) { |
|
256 | + $object_id = intval( $object[ 'term_id' ] ); |
|
257 | 257 | $object_type = 'term'; |
258 | 258 | } elseif ( isset( $object->term_id ) ) { |
259 | 259 | $object_id = intval( $object->term_id ); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | $cmb_demo = new_cmb2_box( array( |
79 | 79 | 'id' => $prefix . 'metabox', |
80 | 80 | 'title' => __( 'Test Metabox', 'cmb2' ), |
81 | - 'object_types' => array( 'page', ), // Post type |
|
81 | + 'object_types' => array( 'page',), // Post type |
|
82 | 82 | // 'show_on_cb' => 'yourprefix_show_if_front_page', // function should return a bool value |
83 | 83 | // 'context' => 'normal', |
84 | 84 | // 'priority' => 'high', |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | 'desc' => __( 'field description (optional)', 'cmb2' ), |
323 | 323 | 'id' => $prefix . 'wysiwyg', |
324 | 324 | 'type' => 'wysiwyg', |
325 | - 'options' => array( 'textarea_rows' => 5, ), |
|
325 | + 'options' => array( 'textarea_rows' => 5,), |
|
326 | 326 | ) ); |
327 | 327 | |
328 | 328 | $cmb_demo->add_field( array( |
@@ -374,11 +374,11 @@ discard block |
||
374 | 374 | $cmb_about_page = new_cmb2_box( array( |
375 | 375 | 'id' => $prefix . 'metabox', |
376 | 376 | 'title' => __( 'About Page Metabox', 'cmb2' ), |
377 | - 'object_types' => array( 'page', ), // Post type |
|
377 | + 'object_types' => array( 'page',), // Post type |
|
378 | 378 | 'context' => 'normal', |
379 | 379 | 'priority' => 'high', |
380 | 380 | 'show_names' => true, // Show field names on the left |
381 | - 'show_on' => array( 'id' => array( 2, ) ), // Specific post IDs to display this metabox |
|
381 | + 'show_on' => array( 'id' => array( 2,) ), // Specific post IDs to display this metabox |
|
382 | 382 | ) ); |
383 | 383 | |
384 | 384 | $cmb_about_page->add_field( array( |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | $cmb_group = new_cmb2_box( array( |
404 | 404 | 'id' => $prefix . 'metabox', |
405 | 405 | 'title' => __( 'Repeating Field Group', 'cmb2' ), |
406 | - 'object_types' => array( 'page', ), |
|
406 | + 'object_types' => array( 'page',), |
|
407 | 407 | ) ); |
408 | 408 | |
409 | 409 | // $group_field_id is the field id string, so in this case: $prefix . 'demo' |
@@ -121,19 +121,19 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function __construct( $meta_box, $object_id = 0 ) { |
123 | 123 | |
124 | - if ( empty( $meta_box['id'] ) ) { |
|
124 | + if ( empty( $meta_box[ 'id' ] ) ) { |
|
125 | 125 | wp_die( __( 'Metabox configuration is required to have an ID parameter', 'cmb2' ) ); |
126 | 126 | } |
127 | 127 | |
128 | 128 | $this->meta_box = wp_parse_args( $meta_box, $this->mb_defaults ); |
129 | - $this->meta_box['fields'] = array(); |
|
129 | + $this->meta_box[ 'fields' ] = array(); |
|
130 | 130 | |
131 | 131 | $this->object_id( $object_id ); |
132 | 132 | $this->mb_object_type(); |
133 | - $this->cmb_id = $meta_box['id']; |
|
133 | + $this->cmb_id = $meta_box[ 'id' ]; |
|
134 | 134 | |
135 | - if ( ! empty( $meta_box['fields'] ) && is_array( $meta_box['fields'] ) ) { |
|
136 | - $this->add_fields( $meta_box['fields'] ); |
|
135 | + if ( ! empty( $meta_box[ 'fields' ] ) && is_array( $meta_box[ 'fields' ] ) ) { |
|
136 | + $this->add_fields( $meta_box[ 'fields' ] ); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | CMB2_Boxes::add( $this ); |
@@ -264,16 +264,16 @@ discard block |
||
264 | 264 | * @return mixed CMB2_Field object if successful. |
265 | 265 | */ |
266 | 266 | public function render_field( $field_args ) { |
267 | - $field_args['context'] = $this->prop( 'context' ); |
|
267 | + $field_args[ 'context' ] = $this->prop( 'context' ); |
|
268 | 268 | |
269 | - if ( 'group' == $field_args['type'] ) { |
|
269 | + if ( 'group' == $field_args[ 'type' ] ) { |
|
270 | 270 | |
271 | - if ( ! isset( $field_args['show_names'] ) ) { |
|
272 | - $field_args['show_names'] = $this->prop( 'show_names' ); |
|
271 | + if ( ! isset( $field_args[ 'show_names' ] ) ) { |
|
272 | + $field_args[ 'show_names' ] = $this->prop( 'show_names' ); |
|
273 | 273 | } |
274 | 274 | $field = $this->render_group( $field_args ); |
275 | 275 | |
276 | - } elseif ( 'hidden' == $field_args['type'] && $this->get_field( $field_args )->should_show() ) { |
|
276 | + } elseif ( 'hidden' == $field_args[ 'type' ] && $this->get_field( $field_args )->should_show() ) { |
|
277 | 277 | // Save rendering for after the metabox |
278 | 278 | $field = $this->add_hidden_field( array( |
279 | 279 | 'field_args' => $field_args, |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | |
284 | 284 | } else { |
285 | 285 | |
286 | - $field_args['show_names'] = $this->prop( 'show_names' ); |
|
286 | + $field_args[ 'show_names' ] = $this->prop( 'show_names' ); |
|
287 | 287 | |
288 | 288 | // Render default fields |
289 | 289 | $field = $this->get_field( $field_args )->render_field(); |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | */ |
300 | 300 | public function render_group( $args ) { |
301 | 301 | |
302 | - if ( ! isset( $args['id'], $args['fields'] ) || ! is_array( $args['fields'] ) ) { |
|
302 | + if ( ! isset( $args[ 'id' ], $args[ 'fields' ] ) || ! is_array( $args[ 'fields' ] ) ) { |
|
303 | 303 | return; |
304 | 304 | } |
305 | 305 | |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | <div class="inside cmb-td cmb-nested cmb-field-list">'; |
382 | 382 | // Loop and render repeatable group fields |
383 | 383 | foreach ( array_values( $field_group->args( 'fields' ) ) as $field_args ) { |
384 | - if ( 'hidden' == $field_args['type'] ) { |
|
384 | + if ( 'hidden' == $field_args[ 'type' ] ) { |
|
385 | 385 | |
386 | 386 | // Save rendering for after the metabox |
387 | 387 | $this->add_hidden_field( array( |
@@ -391,8 +391,8 @@ discard block |
||
391 | 391 | |
392 | 392 | } else { |
393 | 393 | |
394 | - $field_args['show_names'] = $field_group->args( 'show_names' ); |
|
395 | - $field_args['context'] = $field_group->args( 'context' ); |
|
394 | + $field_args[ 'show_names' ] = $field_group->args( 'show_names' ); |
|
395 | + $field_args[ 'context' ] = $field_group->args( 'context' ); |
|
396 | 396 | |
397 | 397 | $field = $this->get_field( $field_args, $field_group )->render_field(); |
398 | 398 | } |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | */ |
422 | 422 | public function add_hidden_field( $args ) { |
423 | 423 | $field = new CMB2_Field( $args ); |
424 | - $this->hidden_fields[] = new CMB2_Types( $field ); |
|
424 | + $this->hidden_fields[ ] = new CMB2_Types( $field ); |
|
425 | 425 | |
426 | 426 | return $field; |
427 | 427 | } |
@@ -518,11 +518,11 @@ discard block |
||
518 | 518 | */ |
519 | 519 | public function process_field( $field_args ) { |
520 | 520 | |
521 | - switch ( $field_args['type'] ) { |
|
521 | + switch ( $field_args[ 'type' ] ) { |
|
522 | 522 | |
523 | 523 | case 'group': |
524 | 524 | if ( $this->save_group( $field_args ) ) { |
525 | - $this->updated[] = $field_args['id']; |
|
525 | + $this->updated[ ] = $field_args[ 'id' ]; |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | break; |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | ) ); |
542 | 542 | |
543 | 543 | if ( $field->save_field_from_data( $this->data_to_save ) ) { |
544 | - $this->updated[] = $field->id(); |
|
544 | + $this->updated[ ] = $field->id(); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | break; |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | * @return mixed Return of CMB2_Field::update_data() |
609 | 609 | */ |
610 | 610 | public function save_group( $args ) { |
611 | - if ( ! isset( $args['id'], $args['fields'] ) || ! is_array( $args['fields'] ) ) { |
|
611 | + if ( ! isset( $args[ 'id' ], $args[ 'fields' ] ) || ! is_array( $args[ 'fields' ] ) ) { |
|
612 | 612 | return; |
613 | 613 | } |
614 | 614 | |
@@ -662,16 +662,16 @@ discard block |
||
662 | 662 | $_new_val = array(); |
663 | 663 | foreach ( $new_val as $group_index => $grouped_data ) { |
664 | 664 | // Add the supporting data to the $saved array stack |
665 | - $saved[ $field_group->index ][ $grouped_data['supporting_field_id'] ][] = $grouped_data['supporting_field_value']; |
|
665 | + $saved[ $field_group->index ][ $grouped_data[ 'supporting_field_id' ] ][ ] = $grouped_data[ 'supporting_field_value' ]; |
|
666 | 666 | // Reset var to the actual value |
667 | - $_new_val[ $group_index ] = $grouped_data['value']; |
|
667 | + $_new_val[ $group_index ] = $grouped_data[ 'value' ]; |
|
668 | 668 | } |
669 | 669 | $new_val = $_new_val; |
670 | 670 | } else { |
671 | 671 | // Add the supporting data to the $saved array stack |
672 | - $saved[ $field_group->index ][ $new_val['supporting_field_id'] ] = $new_val['supporting_field_value']; |
|
672 | + $saved[ $field_group->index ][ $new_val[ 'supporting_field_id' ] ] = $new_val[ 'supporting_field_value' ]; |
|
673 | 673 | // Reset var to the actual value |
674 | - $new_val = $new_val['value']; |
|
674 | + $new_val = $new_val[ 'value' ]; |
|
675 | 675 | } |
676 | 676 | } |
677 | 677 | |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | $is_removed = ( empty( $new_val ) && ! empty( $old_val ) ); |
685 | 685 | // Compare values and add to `$updated` array |
686 | 686 | if ( $is_updated || $is_removed ) { |
687 | - $this->updated[] = $base_id . '::' . $field_group->index . '::' . $sub_id; |
|
687 | + $this->updated[ ] = $base_id . '::' . $field_group->index . '::' . $sub_id; |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | // Add to `$saved` array |
@@ -719,22 +719,22 @@ discard block |
||
719 | 719 | // Try to get our object ID from the global space |
720 | 720 | switch ( $this->object_type() ) { |
721 | 721 | case 'user': |
722 | - $object_id = isset( $_REQUEST['user_id'] ) ? $_REQUEST['user_id'] : $object_id; |
|
723 | - $object_id = ! $object_id && 'user-new.php' != $pagenow && isset( $GLOBALS['user_ID'] ) ? $GLOBALS['user_ID'] : $object_id; |
|
722 | + $object_id = isset( $_REQUEST[ 'user_id' ] ) ? $_REQUEST[ 'user_id' ] : $object_id; |
|
723 | + $object_id = ! $object_id && 'user-new.php' != $pagenow && isset( $GLOBALS[ 'user_ID' ] ) ? $GLOBALS[ 'user_ID' ] : $object_id; |
|
724 | 724 | break; |
725 | 725 | |
726 | 726 | case 'comment': |
727 | - $object_id = isset( $_REQUEST['c'] ) ? $_REQUEST['c'] : $object_id; |
|
728 | - $object_id = ! $object_id && isset( $GLOBALS['comments']->comment_ID ) ? $GLOBALS['comments']->comment_ID : $object_id; |
|
727 | + $object_id = isset( $_REQUEST[ 'c' ] ) ? $_REQUEST[ 'c' ] : $object_id; |
|
728 | + $object_id = ! $object_id && isset( $GLOBALS[ 'comments' ]->comment_ID ) ? $GLOBALS[ 'comments' ]->comment_ID : $object_id; |
|
729 | 729 | break; |
730 | 730 | |
731 | 731 | case 'term': |
732 | - $object_id = isset( $_REQUEST['tag_ID'] ) ? $_REQUEST['tag_ID'] : $object_id; |
|
732 | + $object_id = isset( $_REQUEST[ 'tag_ID' ] ) ? $_REQUEST[ 'tag_ID' ] : $object_id; |
|
733 | 733 | break; |
734 | 734 | |
735 | 735 | default: |
736 | - $object_id = isset( $GLOBALS['post']->ID ) ? $GLOBALS['post']->ID : $object_id; |
|
737 | - $object_id = isset( $_REQUEST['post'] ) ? $_REQUEST['post'] : $object_id; |
|
736 | + $object_id = isset( $GLOBALS[ 'post' ]->ID ) ? $GLOBALS[ 'post' ]->ID : $object_id; |
|
737 | + $object_id = isset( $_REQUEST[ 'post' ] ) ? $_REQUEST[ 'post' ] : $object_id; |
|
738 | 738 | break; |
739 | 739 | } |
740 | 740 | |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | * @return boolean True/False |
807 | 807 | */ |
808 | 808 | public function is_options_page_mb() { |
809 | - 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'] ) ); |
|
809 | + 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' ] ) ); |
|
810 | 810 | } |
811 | 811 | |
812 | 812 | /** |
@@ -872,7 +872,7 @@ discard block |
||
872 | 872 | return $field; |
873 | 873 | } |
874 | 874 | |
875 | - $field_id = is_string( $field ) ? $field : $field['id']; |
|
875 | + $field_id = is_string( $field ) ? $field : $field[ 'id' ]; |
|
876 | 876 | |
877 | 877 | $parent_field_id = ! empty( $field_group ) ? $field_group->id() : ''; |
878 | 878 | $ids = $this->get_field_ids( $field_id, $parent_field_id, true ); |
@@ -908,7 +908,7 @@ discard block |
||
908 | 908 | if ( $field_group && ( $sub_field_id || 0 === $sub_field_id ) ) { |
909 | 909 | |
910 | 910 | // Update the fields array w/ any modified properties inherited from the group field |
911 | - $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] = $field_args; |
|
911 | + $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] = $field_args; |
|
912 | 912 | |
913 | 913 | return array( |
914 | 914 | 'field_args' => $field_args, |
@@ -918,11 +918,11 @@ discard block |
||
918 | 918 | } |
919 | 919 | |
920 | 920 | if ( is_array( $field_args ) ) { |
921 | - $this->meta_box['fields'][ $field_id ] = array_merge( $field_args, $this->meta_box['fields'][ $field_id ] ); |
|
921 | + $this->meta_box[ 'fields' ][ $field_id ] = array_merge( $field_args, $this->meta_box[ 'fields' ][ $field_id ] ); |
|
922 | 922 | } |
923 | 923 | |
924 | 924 | return array( |
925 | - 'field_args' => $this->meta_box['fields'][ $field_id ], |
|
925 | + 'field_args' => $this->meta_box[ 'fields' ][ $field_id ], |
|
926 | 926 | 'object_type' => $this->object_type(), |
927 | 927 | 'object_id' => $this->object_id(), |
928 | 928 | ); |
@@ -939,8 +939,8 @@ discard block |
||
939 | 939 | |
940 | 940 | $sub_fields = false; |
941 | 941 | if ( array_key_exists( 'fields', $field ) ) { |
942 | - $sub_fields = $field['fields']; |
|
943 | - unset( $field['fields'] ); |
|
942 | + $sub_fields = $field[ 'fields' ]; |
|
943 | + unset( $field[ 'fields' ] ); |
|
944 | 944 | } |
945 | 945 | |
946 | 946 | $field_id = $parent_field_id |
@@ -967,11 +967,11 @@ discard block |
||
967 | 967 | |
968 | 968 | $this->_add_field_to_array( |
969 | 969 | $field, |
970 | - $this->meta_box['fields'], |
|
970 | + $this->meta_box[ 'fields' ], |
|
971 | 971 | $position |
972 | 972 | ); |
973 | 973 | |
974 | - return $field['id']; |
|
974 | + return $field[ 'id' ]; |
|
975 | 975 | } |
976 | 976 | |
977 | 977 | /** |
@@ -983,27 +983,27 @@ discard block |
||
983 | 983 | * @return mixed Array of parent/field ids or false |
984 | 984 | */ |
985 | 985 | public function add_group_field( $parent_field_id, array $field, $position = 0 ) { |
986 | - if ( ! array_key_exists( $parent_field_id, $this->meta_box['fields'] ) ) { |
|
986 | + if ( ! array_key_exists( $parent_field_id, $this->meta_box[ 'fields' ] ) ) { |
|
987 | 987 | return false; |
988 | 988 | } |
989 | 989 | |
990 | - $parent_field = $this->meta_box['fields'][ $parent_field_id ]; |
|
990 | + $parent_field = $this->meta_box[ 'fields' ][ $parent_field_id ]; |
|
991 | 991 | |
992 | - if ( 'group' !== $parent_field['type'] ) { |
|
992 | + if ( 'group' !== $parent_field[ 'type' ] ) { |
|
993 | 993 | return false; |
994 | 994 | } |
995 | 995 | |
996 | - if ( ! isset( $parent_field['fields'] ) ) { |
|
997 | - $this->meta_box['fields'][ $parent_field_id ]['fields'] = array(); |
|
996 | + if ( ! isset( $parent_field[ 'fields' ] ) ) { |
|
997 | + $this->meta_box[ 'fields' ][ $parent_field_id ][ 'fields' ] = array(); |
|
998 | 998 | } |
999 | 999 | |
1000 | 1000 | $this->_add_field_to_array( |
1001 | 1001 | $field, |
1002 | - $this->meta_box['fields'][ $parent_field_id ]['fields'], |
|
1002 | + $this->meta_box[ 'fields' ][ $parent_field_id ][ 'fields' ], |
|
1003 | 1003 | $position |
1004 | 1004 | ); |
1005 | 1005 | |
1006 | - return array( $parent_field_id, $field['id'] ); |
|
1006 | + return array( $parent_field_id, $field[ 'id' ] ); |
|
1007 | 1007 | } |
1008 | 1008 | |
1009 | 1009 | /** |
@@ -1015,9 +1015,9 @@ discard block |
||
1015 | 1015 | */ |
1016 | 1016 | protected function _add_field_to_array( $field, &$fields, $position = 0 ) { |
1017 | 1017 | if ( $position ) { |
1018 | - cmb2_utils()->array_insert( $fields, array( $field['id'] => $field ), $position ); |
|
1018 | + cmb2_utils()->array_insert( $fields, array( $field[ 'id' ] => $field ), $position ); |
|
1019 | 1019 | } else { |
1020 | - $fields[ $field['id'] ] = $field; |
|
1020 | + $fields[ $field[ 'id' ] ] = $field; |
|
1021 | 1021 | } |
1022 | 1022 | } |
1023 | 1023 | |
@@ -1040,12 +1040,12 @@ discard block |
||
1040 | 1040 | unset( $this->fields[ implode( '', $ids ) ] ); |
1041 | 1041 | |
1042 | 1042 | if ( ! $sub_field_id ) { |
1043 | - unset( $this->meta_box['fields'][ $field_id ] ); |
|
1043 | + unset( $this->meta_box[ 'fields' ][ $field_id ] ); |
|
1044 | 1044 | return true; |
1045 | 1045 | } |
1046 | 1046 | |
1047 | - unset( $this->fields[ $field_id ]->args['fields'][ $sub_field_id ] ); |
|
1048 | - unset( $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] ); |
|
1047 | + unset( $this->fields[ $field_id ]->args[ 'fields' ][ $sub_field_id ] ); |
|
1048 | + unset( $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] ); |
|
1049 | 1049 | return true; |
1050 | 1050 | } |
1051 | 1051 | |
@@ -1068,11 +1068,11 @@ discard block |
||
1068 | 1068 | list( $field_id, $sub_field_id ) = $ids; |
1069 | 1069 | |
1070 | 1070 | if ( ! $sub_field_id ) { |
1071 | - $this->meta_box['fields'][ $field_id ][ $property ] = $value; |
|
1071 | + $this->meta_box[ 'fields' ][ $field_id ][ $property ] = $value; |
|
1072 | 1072 | return $field_id; |
1073 | 1073 | } |
1074 | 1074 | |
1075 | - $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ][ $property ] = $value; |
|
1075 | + $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ][ $property ] = $value; |
|
1076 | 1076 | return $field_id; |
1077 | 1077 | } |
1078 | 1078 | |
@@ -1086,7 +1086,7 @@ discard block |
||
1086 | 1086 | public function get_field_ids( $field_id, $parent_field_id = '' ) { |
1087 | 1087 | $sub_field_id = $parent_field_id ? $field_id : ''; |
1088 | 1088 | $field_id = $parent_field_id ? $parent_field_id : $field_id; |
1089 | - $fields =& $this->meta_box['fields']; |
|
1089 | + $fields = & $this->meta_box[ 'fields' ]; |
|
1090 | 1090 | |
1091 | 1091 | if ( ! array_key_exists( $field_id, $fields ) ) { |
1092 | 1092 | $field_id = $this->search_old_school_array( $field_id, $fields ); |
@@ -1100,12 +1100,12 @@ discard block |
||
1100 | 1100 | return array( $field_id, $sub_field_id ); |
1101 | 1101 | } |
1102 | 1102 | |
1103 | - if ( 'group' !== $fields[ $field_id ]['type'] ) { |
|
1103 | + if ( 'group' !== $fields[ $field_id ][ 'type' ] ) { |
|
1104 | 1104 | return false; |
1105 | 1105 | } |
1106 | 1106 | |
1107 | - if ( ! array_key_exists( $sub_field_id, $fields[ $field_id ]['fields'] ) ) { |
|
1108 | - $sub_field_id = $this->search_old_school_array( $sub_field_id, $fields[ $field_id ]['fields'] ); |
|
1107 | + if ( ! array_key_exists( $sub_field_id, $fields[ $field_id ][ 'fields' ] ) ) { |
|
1108 | + $sub_field_id = $this->search_old_school_array( $sub_field_id, $fields[ $field_id ][ 'fields' ] ); |
|
1109 | 1109 | } |
1110 | 1110 | |
1111 | 1111 | return false === $sub_field_id ? false : array( $field_id, $sub_field_id ); |
@@ -54,7 +54,7 @@ |
||
54 | 54 | return; |
55 | 55 | } |
56 | 56 | |
57 | - self::$hooks_completed[] = $key; |
|
57 | + self::$hooks_completed[ ] = $key; |
|
58 | 58 | add_filter( $action, $hook, $priority, $accepted_args ); |
59 | 59 | } |
60 | 60 |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * @return array Modified array of classes |
258 | 258 | */ |
259 | 259 | public function close_metabox_class( $classes ) { |
260 | - $classes[] = 'closed'; |
|
260 | + $classes[ ] = 'closed'; |
|
261 | 261 | return $classes; |
262 | 262 | } |
263 | 263 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | public function user_new_metabox( $section ) { |
278 | 278 | if ( $section == $this->cmb->prop( 'new_user_section' ) ) { |
279 | 279 | $object_id = $this->cmb->object_id(); |
280 | - $this->cmb->object_id( isset( $_REQUEST['user_id'] ) ? $_REQUEST['user_id'] : $object_id ); |
|
280 | + $this->cmb->object_id( isset( $_REQUEST[ 'user_id' ] ) ? $_REQUEST[ 'user_id' ] : $object_id ); |
|
281 | 281 | $this->user_metabox(); |
282 | 282 | } |
283 | 283 | } |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | if ( $this->taxonomy_can_save( $taxonomy ) ) { |
429 | 429 | |
430 | 430 | foreach ( $this->cmb->prop( 'fields' ) as $field ) { |
431 | - $data_to_delete[ $field['id'] ] = ''; |
|
431 | + $data_to_delete[ $field[ 'id' ] ] = ''; |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | $this->cmb->save_fields( $term_id, 'term', $data_to_delete ); |
@@ -384,7 +384,6 @@ discard block |
||
384 | 384 | * |
385 | 385 | * @since 2.2.0 |
386 | 386 | * |
387 | - * @param mixed $data |
|
388 | 387 | * @return array $data |
389 | 388 | */ |
390 | 389 | public function prepare_item( $post ) { |
@@ -397,7 +396,7 @@ discard block |
||
397 | 396 | * @since 2.2.0 |
398 | 397 | * |
399 | 398 | * @param mixed $cb Callable function/method. |
400 | - * @return mixed Results of output buffer after calling function/method. |
|
399 | + * @return string Results of output buffer after calling function/method. |
|
401 | 400 | */ |
402 | 401 | public function get_cb_results( $cb ) { |
403 | 402 | $args = func_get_args(); |
@@ -170,12 +170,12 @@ discard block |
||
170 | 170 | if ( $cmb_id && ( $cmb = cmb2_get_metabox( $cmb_id, $this->object_id, $this->object_type ) ) ) { |
171 | 171 | $fields = array(); |
172 | 172 | foreach ( $cmb->prop( 'fields', array() ) as $field ) { |
173 | - $field = $this->get_rest_field( $cmb, $field['id'] ); |
|
173 | + $field = $this->get_rest_field( $cmb, $field[ 'id' ] ); |
|
174 | 174 | |
175 | 175 | if ( ! is_wp_error( $field ) ) { |
176 | - $fields[ $field['id'] ] = $field; |
|
176 | + $fields[ $field[ 'id' ] ] = $field; |
|
177 | 177 | } else { |
178 | - $fields[ $field['id'] ] = array( 'error' => $field->get_error_message() ); |
|
178 | + $fields[ $field[ 'id' ] ] = array( 'error' => $field->get_error_message() ); |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | |
200 | 200 | $boxes_data = $cmb->meta_box; |
201 | 201 | |
202 | - if ( isset( $_GET['rendered'] ) ) { |
|
203 | - $boxes_data['form_open'] = $this->get_cb_results( array( $cmb, 'render_form_open' ) ); |
|
204 | - $boxes_data['form_close'] = $this->get_cb_results( array( $cmb, 'render_form_close' ) ); |
|
202 | + if ( isset( $_GET[ 'rendered' ] ) ) { |
|
203 | + $boxes_data[ 'form_open' ] = $this->get_cb_results( array( $cmb, 'render_form_open' ) ); |
|
204 | + $boxes_data[ 'form_close' ] = $this->get_cb_results( array( $cmb, 'render_form_close' ) ); |
|
205 | 205 | |
206 | 206 | global $wp_scripts, $wp_styles; |
207 | 207 | $before_css = $wp_styles->queue; |
@@ -209,14 +209,14 @@ discard block |
||
209 | 209 | |
210 | 210 | CMB2_JS::enqueue(); |
211 | 211 | |
212 | - $boxes_data['js_dependencies'] = array_values( array_diff( $wp_scripts->queue, $before_js ) ); |
|
213 | - $boxes_data['css_dependencies'] = array_values( array_diff( $wp_styles->queue, $before_css ) ); |
|
212 | + $boxes_data[ 'js_dependencies' ] = array_values( array_diff( $wp_scripts->queue, $before_js ) ); |
|
213 | + $boxes_data[ 'css_dependencies' ] = array_values( array_diff( $wp_styles->queue, $before_css ) ); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | // TODO: look into 'embed' parameter. |
217 | - unset( $boxes_data['fields'] ); |
|
217 | + unset( $boxes_data[ 'fields' ] ); |
|
218 | 218 | // Handle callable properties. |
219 | - unset( $boxes_data['show_on_cb'] ); |
|
219 | + unset( $boxes_data[ 'show_on_cb' ] ); |
|
220 | 220 | |
221 | 221 | $base = $this->namespace . '/boxes/' . $cmb->cmb_id; |
222 | 222 | $boxbase = $base . '/' . $cmb->cmb_id; |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | ), |
235 | 235 | ) ); |
236 | 236 | |
237 | - $boxes_data['_links'] = $response->get_links(); |
|
237 | + $boxes_data[ '_links' ] = $response->get_links(); |
|
238 | 238 | |
239 | 239 | return $boxes_data; |
240 | 240 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | public function get_field( $request ) { |
251 | 251 | $this->initiate_request( $request ); |
252 | 252 | |
253 | - $cmb = cmb2_get_metabox( $this->request->get_param( 'cmb_id' ), $this->object_id, $this->object_type ); |
|
253 | + $cmb = cmb2_get_metabox( $this->request->get_param( 'cmb_id' ), $this->object_id, $this->object_type ); |
|
254 | 254 | |
255 | 255 | if ( ! $cmb ) { |
256 | 256 | return $this->prepare_item( array( 'error' => __( 'No box found by that id.', 'cmb2' ) ) ); |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | |
302 | 302 | // TODO: Use request get object |
303 | 303 | // Run this first so the js_dependencies arg is populated. |
304 | - $rendered = isset( $_GET['rendered'] ) && ( $cb = $field->maybe_callback( 'render_row_cb' ) ) |
|
304 | + $rendered = isset( $_GET[ 'rendered' ] ) && ( $cb = $field->maybe_callback( 'render_row_cb' ) ) |
|
305 | 305 | // Ok, callback is good, let's run it. |
306 | 306 | ? $this->get_cb_results( $cb, $field->args(), $field ) |
307 | 307 | : false; |
@@ -330,11 +330,11 @@ discard block |
||
330 | 330 | } |
331 | 331 | } |
332 | 332 | |
333 | - if ( isset( $_GET['rendered'] ) ) { |
|
334 | - $field_data['rendered'] = $rendered; |
|
333 | + if ( isset( $_GET[ 'rendered' ] ) ) { |
|
334 | + $field_data[ 'rendered' ] = $rendered; |
|
335 | 335 | } |
336 | 336 | |
337 | - $field_data['value'] = $field->get_data(); |
|
337 | + $field_data[ 'value' ] = $field->get_data(); |
|
338 | 338 | |
339 | 339 | $base = $this->namespace . '/boxes/' . $cmb->cmb_id; |
340 | 340 | |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | ), |
352 | 352 | ) ); |
353 | 353 | |
354 | - $field_data['_links'] = $response->get_links(); |
|
354 | + $field_data[ '_links' ] = $response->get_links(); |
|
355 | 355 | |
356 | 356 | return $field_data; |
357 | 357 | } |
@@ -411,12 +411,12 @@ discard block |
||
411 | 411 | public function initiate_request( $request ) { |
412 | 412 | $this->request = $request; |
413 | 413 | |
414 | - if ( isset( $_REQUEST['object_id'] ) ) { |
|
415 | - $this->object_id = absint( $_REQUEST['object_id'] ); |
|
414 | + if ( isset( $_REQUEST[ 'object_id' ] ) ) { |
|
415 | + $this->object_id = absint( $_REQUEST[ 'object_id' ] ); |
|
416 | 416 | } |
417 | 417 | |
418 | - if ( isset( $_REQUEST['object_type'] ) ) { |
|
419 | - $this->object_type = absint( $_REQUEST['object_type'] ); |
|
418 | + if ( isset( $_REQUEST[ 'object_type' ] ) ) { |
|
419 | + $this->object_type = absint( $_REQUEST[ 'object_type' ] ); |
|
420 | 420 | } |
421 | 421 | } |
422 | 422 | |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | */ |
432 | 432 | public function prepare_item_for_response( $data, $request ) { |
433 | 433 | |
434 | - $context = ! empty( $this->request['context'] ) ? $this->request['context'] : 'view'; |
|
434 | + $context = ! empty( $this->request[ 'context' ] ) ? $this->request[ 'context' ] : 'view'; |
|
435 | 435 | $data = $this->filter_response_by_context( $data, $context ); |
436 | 436 | |
437 | 437 | /** |
@@ -117,16 +117,16 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function __construct( $args ) { |
119 | 119 | |
120 | - if ( ! empty( $args['group_field'] ) ) { |
|
121 | - $this->group = $args['group_field']; |
|
120 | + if ( ! empty( $args[ 'group_field' ] ) ) { |
|
121 | + $this->group = $args[ 'group_field' ]; |
|
122 | 122 | $this->object_id = $this->group->object_id; |
123 | 123 | $this->object_type = $this->group->object_type; |
124 | 124 | } else { |
125 | - $this->object_id = isset( $args['object_id'] ) && '_' !== $args['object_id'] ? $args['object_id'] : 0; |
|
126 | - $this->object_type = isset( $args['object_type'] ) ? $args['object_type'] : 'post'; |
|
125 | + $this->object_id = isset( $args[ 'object_id' ] ) && '_' !== $args[ 'object_id' ] ? $args[ 'object_id' ] : 0; |
|
126 | + $this->object_type = isset( $args[ 'object_type' ] ) ? $args[ 'object_type' ] : 'post'; |
|
127 | 127 | } |
128 | 128 | |
129 | - $this->args = $this->_set_field_defaults( $args['field_args'] ); |
|
129 | + $this->args = $this->_set_field_defaults( $args[ 'field_args' ] ); |
|
130 | 130 | |
131 | 131 | if ( $this->object_id ) { |
132 | 132 | $this->value = $this->get_data(); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @return mixed Value of field argument |
142 | 142 | */ |
143 | 143 | public function __call( $name, $arguments ) { |
144 | - $key = isset( $arguments[0] ) ? $arguments[0] : false; |
|
144 | + $key = isset( $arguments[ 0 ] ) ? $arguments[ 0 ] : false; |
|
145 | 145 | return $this->args( $name, $key ); |
146 | 146 | } |
147 | 147 | |
@@ -212,9 +212,9 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public function get_data( $field_id = '', $args = array() ) { |
214 | 214 | if ( $field_id ) { |
215 | - $args['field_id'] = $field_id; |
|
215 | + $args[ 'field_id' ] = $field_id; |
|
216 | 216 | } else if ( $this->group ) { |
217 | - $args['field_id'] = $this->group->id(); |
|
217 | + $args[ 'field_id' ] = $this->group->id(); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | $a = $this->data_args( $args ); |
@@ -255,13 +255,13 @@ discard block |
||
255 | 255 | * |
256 | 256 | * @since 2.0.0 |
257 | 257 | */ |
258 | - $data = apply_filters( "cmb2_override_{$a['field_id']}_meta_value", $data, $this->object_id, $a, $this ); |
|
258 | + $data = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_value", $data, $this->object_id, $a, $this ); |
|
259 | 259 | |
260 | 260 | // If no override, get value normally |
261 | 261 | if ( 'cmb2_field_no_override_val' === $data ) { |
262 | - $data = 'options-page' === $a['type'] |
|
263 | - ? cmb2_options( $a['id'] )->get( $a['field_id'] ) |
|
264 | - : get_metadata( $a['type'], $a['id'], $a['field_id'], ( $a['single'] || $a['repeat'] ) ); |
|
262 | + $data = 'options-page' === $a[ 'type' ] |
|
263 | + ? cmb2_options( $a[ 'id' ] )->get( $a[ 'field_id' ] ) |
|
264 | + : get_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], ( $a[ 'single' ] || $a[ 'repeat' ] ) ); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | if ( $this->group ) { |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | public function update_data( $new_value, $single = true ) { |
284 | 284 | $a = $this->data_args( array( 'single' => $single ) ); |
285 | 285 | |
286 | - $a['value'] = $a['repeat'] ? array_values( $new_value ) : $new_value; |
|
286 | + $a[ 'value' ] = $a[ 'repeat' ] ? array_values( $new_value ) : $new_value; |
|
287 | 287 | |
288 | 288 | /** |
289 | 289 | * Filter whether to override saving of meta value. |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * |
320 | 320 | * @since 2.0.0 |
321 | 321 | */ |
322 | - $override = apply_filters( "cmb2_override_{$a['field_id']}_meta_save", $override, $a, $this->args(), $this ); |
|
322 | + $override = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_save", $override, $a, $this->args(), $this ); |
|
323 | 323 | |
324 | 324 | // If override, return that |
325 | 325 | if ( null !== $override ) { |
@@ -327,22 +327,22 @@ discard block |
||
327 | 327 | } |
328 | 328 | |
329 | 329 | // Options page handling (or temp data store) |
330 | - if ( 'options-page' === $a['type'] || empty( $a['id'] ) ) { |
|
331 | - return cmb2_options( $a['id'] )->update( $a['field_id'], $a['value'], false, $a['single'] ); |
|
330 | + if ( 'options-page' === $a[ 'type' ] || empty( $a[ 'id' ] ) ) { |
|
331 | + return cmb2_options( $a[ 'id' ] )->update( $a[ 'field_id' ], $a[ 'value' ], false, $a[ 'single' ] ); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | // Add metadata if not single |
335 | - if ( ! $a['single'] ) { |
|
336 | - return add_metadata( $a['type'], $a['id'], $a['field_id'], $a['value'], false ); |
|
335 | + if ( ! $a[ 'single' ] ) { |
|
336 | + return add_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $a[ 'value' ], false ); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | // Delete meta if we have an empty array |
340 | - if ( is_array( $a['value'] ) && empty( $a['value'] ) ) { |
|
341 | - return delete_metadata( $a['type'], $a['id'], $a['field_id'], $this->value ); |
|
340 | + if ( is_array( $a[ 'value' ] ) && empty( $a[ 'value' ] ) ) { |
|
341 | + return delete_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $this->value ); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | // Update metadata |
345 | - return update_metadata( $a['type'], $a['id'], $a['field_id'], $a['value'] ); |
|
345 | + return update_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $a[ 'value' ] ); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
@@ -392,19 +392,19 @@ discard block |
||
392 | 392 | * @param array $field_args All field arguments |
393 | 393 | * @param CMB2_Field object $field This field object |
394 | 394 | */ |
395 | - $override = apply_filters( "cmb2_override_{$a['field_id']}_meta_remove", $override, $a, $this->args(), $this ); |
|
395 | + $override = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_remove", $override, $a, $this->args(), $this ); |
|
396 | 396 | |
397 | 397 | // If no override, remove as usual |
398 | 398 | if ( null !== $override ) { |
399 | 399 | return $override; |
400 | 400 | } |
401 | 401 | // Option page handling |
402 | - elseif ( 'options-page' === $a['type'] || empty( $a['id'] ) ) { |
|
403 | - return cmb2_options( $a['id'] )->remove( $a['field_id'] ); |
|
402 | + elseif ( 'options-page' === $a[ 'type' ] || empty( $a[ 'id' ] ) ) { |
|
403 | + return cmb2_options( $a[ 'id' ] )->remove( $a[ 'field_id' ] ); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | // Remove metadata |
407 | - return delete_metadata( $a['type'], $a['id'], $a['field_id'], $old ); |
|
407 | + return delete_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $old ); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | /** |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | |
877 | 877 | foreach ( $conditional_classes as $class => $condition ) { |
878 | 878 | if ( $condition ) { |
879 | - $classes[] = $class; |
|
879 | + $classes[ ] = $class; |
|
880 | 880 | } |
881 | 881 | } |
882 | 882 | |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | } |
886 | 886 | |
887 | 887 | if ( $added_classes ) { |
888 | - $classes[] = esc_attr( $added_classes ); |
|
888 | + $classes[ ] = esc_attr( $added_classes ); |
|
889 | 889 | } |
890 | 890 | |
891 | 891 | /** |
@@ -990,10 +990,10 @@ discard block |
||
990 | 990 | return $this->field_options; |
991 | 991 | } |
992 | 992 | |
993 | - $this->field_options = (array) $this->args['options']; |
|
993 | + $this->field_options = (array) $this->args[ 'options' ]; |
|
994 | 994 | |
995 | - if ( is_callable( $this->args['options_cb'] ) ) { |
|
996 | - $options = call_user_func( $this->args['options_cb'], $this ); |
|
995 | + if ( is_callable( $this->args[ 'options_cb' ] ) ) { |
|
996 | + $options = call_user_func( $this->args[ 'options_cb' ], $this ); |
|
997 | 997 | |
998 | 998 | if ( $options && is_array( $options ) ) { |
999 | 999 | $this->field_options += $options; |
@@ -1014,7 +1014,7 @@ discard block |
||
1014 | 1014 | */ |
1015 | 1015 | public function add_js_dependencies( $dependencies = array() ) { |
1016 | 1016 | foreach ( (array) $dependencies as $dependency ) { |
1017 | - $this->args['js_dependencies'][ $dependency ] = $dependency; |
|
1017 | + $this->args[ 'js_dependencies' ][ $dependency ] = $dependency; |
|
1018 | 1018 | } |
1019 | 1019 | |
1020 | 1020 | CMB2_JS::add_dependencies( $dependencies ); |
@@ -1041,66 +1041,66 @@ discard block |
||
1041 | 1041 | 'default' => null, |
1042 | 1042 | 'select_all_button' => true, |
1043 | 1043 | 'multiple' => false, |
1044 | - 'repeatable' => isset( $args['type'] ) && 'group' == $args['type'], |
|
1044 | + 'repeatable' => isset( $args[ 'type' ] ) && 'group' == $args[ 'type' ], |
|
1045 | 1045 | 'inline' => false, |
1046 | 1046 | 'on_front' => true, |
1047 | 1047 | 'show_names' => true, |
1048 | 1048 | 'date_format' => 'm\/d\/Y', |
1049 | 1049 | 'time_format' => 'h:i A', |
1050 | - 'description' => isset( $args['desc'] ) ? $args['desc'] : '', |
|
1051 | - 'preview_size' => 'file' == $args['type'] ? array( 350, 350 ) : array( 50, 50 ), |
|
1050 | + 'description' => isset( $args[ 'desc' ] ) ? $args[ 'desc' ] : '', |
|
1051 | + 'preview_size' => 'file' == $args[ 'type' ] ? array( 350, 350 ) : array( 50, 50 ), |
|
1052 | 1052 | 'render_row_cb' => array( $this, 'render_field_callback' ), |
1053 | - 'label_cb' => 'title' != $args['type'] ? array( $this, 'label' ) : '', |
|
1053 | + 'label_cb' => 'title' != $args[ 'type' ] ? array( $this, 'label' ) : '', |
|
1054 | 1054 | 'show_in_rest' => null, |
1055 | 1055 | 'js_dependencies' => array(), |
1056 | 1056 | ) ); |
1057 | 1057 | |
1058 | 1058 | // Allow a filter override of the default value |
1059 | - $args['default'] = apply_filters( 'cmb2_default_filter', $args['default'], $this ); |
|
1060 | - $args['repeatable'] = $args['repeatable'] && ! $this->repeatable_exception( $args['type'] ); |
|
1061 | - $args['inline'] = $args['inline'] || false !== stripos( $args['type'], '_inline' ); |
|
1059 | + $args[ 'default' ] = apply_filters( 'cmb2_default_filter', $args[ 'default' ], $this ); |
|
1060 | + $args[ 'repeatable' ] = $args[ 'repeatable' ] && ! $this->repeatable_exception( $args[ 'type' ] ); |
|
1061 | + $args[ 'inline' ] = $args[ 'inline' ] || false !== stripos( $args[ 'type' ], '_inline' ); |
|
1062 | 1062 | |
1063 | 1063 | // options param can be passed a callback as well |
1064 | - if ( is_callable( $args['options'] ) ) { |
|
1065 | - $args['options_cb'] = $args['options']; |
|
1066 | - $args['options'] = array(); |
|
1064 | + if ( is_callable( $args[ 'options' ] ) ) { |
|
1065 | + $args[ 'options_cb' ] = $args[ 'options' ]; |
|
1066 | + $args[ 'options' ] = array(); |
|
1067 | 1067 | } |
1068 | 1068 | |
1069 | - $args['options'] = 'group' == $args['type'] ? wp_parse_args( $args['options'], array( |
|
1069 | + $args[ 'options' ] = 'group' == $args[ 'type' ] ? wp_parse_args( $args[ 'options' ], array( |
|
1070 | 1070 | 'add_button' => __( 'Add Group', 'cmb2' ), |
1071 | 1071 | 'remove_button' => __( 'Remove Group', 'cmb2' ), |
1072 | - ) ) : $args['options']; |
|
1072 | + ) ) : $args[ 'options' ]; |
|
1073 | 1073 | |
1074 | - $args['_id'] = $args['id']; |
|
1075 | - $args['_name'] = $args['id']; |
|
1074 | + $args[ '_id' ] = $args[ 'id' ]; |
|
1075 | + $args[ '_name' ] = $args[ 'id' ]; |
|
1076 | 1076 | |
1077 | 1077 | if ( $this->group ) { |
1078 | 1078 | |
1079 | - $args['id'] = $this->group->args( 'id' ) . '_' . $this->group->index . '_' . $args['id']; |
|
1080 | - $args['_name'] = $this->group->args( 'id' ) . '[' . $this->group->index . '][' . $args['_name'] . ']'; |
|
1079 | + $args[ 'id' ] = $this->group->args( 'id' ) . '_' . $this->group->index . '_' . $args[ 'id' ]; |
|
1080 | + $args[ '_name' ] = $this->group->args( 'id' ) . '[' . $this->group->index . '][' . $args[ '_name' ] . ']'; |
|
1081 | 1081 | } |
1082 | 1082 | |
1083 | - if ( 'wysiwyg' == $args['type'] ) { |
|
1084 | - $args['id'] = strtolower( str_ireplace( '-', '_', $args['id'] ) ); |
|
1085 | - $args['options']['textarea_name'] = $args['_name']; |
|
1083 | + if ( 'wysiwyg' == $args[ 'type' ] ) { |
|
1084 | + $args[ 'id' ] = strtolower( str_ireplace( '-', '_', $args[ 'id' ] ) ); |
|
1085 | + $args[ 'options' ][ 'textarea_name' ] = $args[ '_name' ]; |
|
1086 | 1086 | } |
1087 | 1087 | |
1088 | 1088 | $option_types = apply_filters( 'cmb2_all_or_nothing_types', array( 'select', 'radio', 'radio_inline', 'taxonomy_select', 'taxonomy_radio', 'taxonomy_radio_inline' ), $this ); |
1089 | 1089 | |
1090 | - if ( in_array( $args['type'], $option_types, true ) ) { |
|
1090 | + if ( in_array( $args[ 'type' ], $option_types, true ) ) { |
|
1091 | 1091 | |
1092 | - $args['show_option_none'] = isset( $args['show_option_none'] ) ? $args['show_option_none'] : null; |
|
1093 | - $args['show_option_none'] = true === $args['show_option_none'] ? __( 'None', 'cmb2' ) : $args['show_option_none']; |
|
1092 | + $args[ 'show_option_none' ] = isset( $args[ 'show_option_none' ] ) ? $args[ 'show_option_none' ] : null; |
|
1093 | + $args[ 'show_option_none' ] = true === $args[ 'show_option_none' ] ? __( 'None', 'cmb2' ) : $args[ 'show_option_none' ]; |
|
1094 | 1094 | |
1095 | - if ( null === $args['show_option_none'] ) { |
|
1096 | - $off_by_default = in_array( $args['type'], array( 'select', 'radio', 'radio_inline' ), true ); |
|
1097 | - $args['show_option_none'] = $off_by_default ? false : __( 'None', 'cmb2' ); |
|
1095 | + if ( null === $args[ 'show_option_none' ] ) { |
|
1096 | + $off_by_default = in_array( $args[ 'type' ], array( 'select', 'radio', 'radio_inline' ), true ); |
|
1097 | + $args[ 'show_option_none' ] = $off_by_default ? false : __( 'None', 'cmb2' ); |
|
1098 | 1098 | } |
1099 | 1099 | |
1100 | 1100 | } |
1101 | 1101 | |
1102 | - $args['has_supporting_data'] = in_array( |
|
1103 | - $args['type'], |
|
1102 | + $args[ 'has_supporting_data' ] = in_array( |
|
1103 | + $args[ 'type' ], |
|
1104 | 1104 | array( |
1105 | 1105 | // See CMB2_Sanitize::_save_utc_value() |
1106 | 1106 | 'file', |
@@ -1119,7 +1119,7 @@ discard block |
||
1119 | 1119 | * @param array $attrs Array of attributes to update |
1120 | 1120 | */ |
1121 | 1121 | public function maybe_set_attributes( $attrs = array() ) { |
1122 | - return wp_parse_args( $this->args['attributes'], $attrs ); |
|
1122 | + return wp_parse_args( $this->args[ 'attributes' ], $attrs ); |
|
1123 | 1123 | } |
1124 | 1124 | |
1125 | 1125 | } |