@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | public function oembed_handler() { |
54 | 54 | |
55 | 55 | // Verify our nonce |
56 | - if ( ! ( isset( $_REQUEST['cmb2_ajax_nonce'], $_REQUEST['oembed_url'] ) && wp_verify_nonce( $_REQUEST['cmb2_ajax_nonce'], 'ajax_nonce' ) ) ) { |
|
56 | + if ( ! ( isset( $_REQUEST[ 'cmb2_ajax_nonce' ], $_REQUEST[ 'oembed_url' ] ) && wp_verify_nonce( $_REQUEST[ 'cmb2_ajax_nonce' ], 'ajax_nonce' ) ) ) { |
|
57 | 57 | die(); |
58 | 58 | } |
59 | 59 | |
60 | 60 | // Sanitize our search string |
61 | - $oembed_string = sanitize_text_field( $_REQUEST['oembed_url'] ); |
|
61 | + $oembed_string = sanitize_text_field( $_REQUEST[ 'oembed_url' ] ); |
|
62 | 62 | |
63 | 63 | // Send back error if empty |
64 | 64 | if ( empty( $oembed_string ) ) { |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | // Set width of embed |
69 | - $embed_width = isset( $_REQUEST['oembed_width'] ) && intval( $_REQUEST['oembed_width'] ) < 640 ? intval( $_REQUEST['oembed_width'] ) : '640'; |
|
69 | + $embed_width = isset( $_REQUEST[ 'oembed_width' ] ) && intval( $_REQUEST[ 'oembed_width' ] ) < 640 ? intval( $_REQUEST[ 'oembed_width' ] ) : '640'; |
|
70 | 70 | |
71 | 71 | // Set url |
72 | 72 | $oembed_url = esc_url( $oembed_string ); |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | // Get embed code (or fallback link) |
80 | 80 | $html = $this->get_oembed( array( |
81 | 81 | 'url' => $oembed_url, |
82 | - 'object_id' => $_REQUEST['object_id'], |
|
83 | - 'object_type' => isset( $_REQUEST['object_type'] ) ? $_REQUEST['object_type'] : 'post', |
|
82 | + 'object_id' => $_REQUEST[ 'object_id' ], |
|
83 | + 'object_type' => isset( $_REQUEST[ 'object_type' ] ) ? $_REQUEST[ 'object_type' ] : 'post', |
|
84 | 84 | 'oembed_args' => $embed_args, |
85 | - 'field_id' => $_REQUEST['field_id'], |
|
85 | + 'field_id' => $_REQUEST[ 'field_id' ], |
|
86 | 86 | ) ); |
87 | 87 | |
88 | 88 | wp_send_json_success( $html ); |
@@ -98,10 +98,10 @@ discard block |
||
98 | 98 | |
99 | 99 | global $wp_embed; |
100 | 100 | |
101 | - $oembed_url = esc_url( $args['url'] ); |
|
101 | + $oembed_url = esc_url( $args[ 'url' ] ); |
|
102 | 102 | |
103 | 103 | // Sanitize object_id |
104 | - $this->object_id = is_numeric( $args['object_id'] ) ? absint( $args['object_id'] ) : sanitize_text_field( $args['object_id'] ); |
|
104 | + $this->object_id = is_numeric( $args[ 'object_id' ] ) ? absint( $args[ 'object_id' ] ) : sanitize_text_field( $args[ 'object_id' ] ); |
|
105 | 105 | |
106 | 106 | $args = wp_parse_args( $args, array( |
107 | 107 | 'object_type' => 'post', |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | 'field_id' => false, |
110 | 110 | ) ); |
111 | 111 | |
112 | - $this->embed_args =& $args; |
|
112 | + $this->embed_args = & $args; |
|
113 | 113 | |
114 | 114 | /** |
115 | 115 | * Set the post_ID so oEmbed won't fail |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | $wp_embed->post_ID = $this->object_id; |
119 | 119 | |
120 | 120 | // Special scenario if NOT a post object |
121 | - if ( isset( $args['object_type'] ) && 'post' != $args['object_type'] ) { |
|
121 | + if ( isset( $args[ 'object_type' ] ) && 'post' != $args[ 'object_type' ] ) { |
|
122 | 122 | |
123 | - if ( 'options-page' == $args['object_type'] ) { |
|
123 | + if ( 'options-page' == $args[ 'object_type' ] ) { |
|
124 | 124 | |
125 | 125 | // Bogus id to pass some numeric checks. Issue with a VERY large WP install? |
126 | 126 | $wp_embed->post_ID = 1987645321; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | |
129 | 129 | // Ok, we need to hijack the oembed cache system |
130 | 130 | $this->hijack = true; |
131 | - $this->object_type = $args['object_type']; |
|
131 | + $this->object_type = $args[ 'object_type' ]; |
|
132 | 132 | |
133 | 133 | // Gets ombed cache from our object's meta (vs postmeta) |
134 | 134 | add_filter( 'get_post_metadata', array( $this, 'hijack_oembed_cache_get' ), 10, 3 ); |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | |
141 | 141 | $embed_args = ''; |
142 | 142 | |
143 | - foreach ( $args['oembed_args'] as $key => $val ) { |
|
143 | + foreach ( $args[ 'oembed_args' ] as $key => $val ) { |
|
144 | 144 | $embed_args .= " $key=\"$val\""; |
145 | 145 | } |
146 | 146 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | |
153 | 153 | // Send back our embed |
154 | 154 | if ( $check_embed && $check_embed != $fallback ) { |
155 | - return '<div class="embed-status">' . $check_embed . '<p class="cmb2-remove-wrapper"><a href="#" class="cmb2-remove-file-button" rel="' . $args['field_id'] . '">' . __( 'Remove Embed', 'cmb2' ) . '</a></p></div>'; |
|
155 | + return '<div class="embed-status">' . $check_embed . '<p class="cmb2-remove-wrapper"><a href="#" class="cmb2-remove-file-button" rel="' . $args[ 'field_id' ] . '">' . __( 'Remove Embed', 'cmb2' ) . '</a></p></div>'; |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | // Otherwise, send back error info that no oEmbeds were found |
@@ -219,15 +219,15 @@ discard block |
||
219 | 219 | */ |
220 | 220 | protected function cache_action( $meta_key ) { |
221 | 221 | $func_args = func_get_args(); |
222 | - $action = isset( $func_args[1] ) ? 'update' : 'get'; |
|
222 | + $action = isset( $func_args[ 1 ] ) ? 'update' : 'get'; |
|
223 | 223 | |
224 | 224 | if ( 'options-page' === $this->object_type ) { |
225 | 225 | |
226 | 226 | $args = array( $meta_key ); |
227 | 227 | |
228 | 228 | if ( 'update' === $action ) { |
229 | - $args[] = $func_args[1]; |
|
230 | - $args[] = true; |
|
229 | + $args[ ] = $func_args[ 1 ]; |
|
230 | + $args[ ] = true; |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | // Cache the result to our options |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | } else { |
236 | 236 | |
237 | 237 | $args = array( $this->object_type, $this->object_id, $meta_key ); |
238 | - $args[] = 'update' === $action ? $func_args : true; |
|
238 | + $args[ ] = 'update' === $action ? $func_args : true; |
|
239 | 239 | |
240 | 240 | // Cache the result to our metadata |
241 | 241 | $status = call_user_func_array( $action . '_metadata', $args ); |
@@ -118,19 +118,19 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function __construct( $meta_box, $object_id = 0 ) { |
120 | 120 | |
121 | - if ( empty( $meta_box['id'] ) ) { |
|
121 | + if ( empty( $meta_box[ 'id' ] ) ) { |
|
122 | 122 | wp_die( __( 'Metabox configuration is required to have an ID parameter', 'cmb2' ) ); |
123 | 123 | } |
124 | 124 | |
125 | 125 | $this->meta_box = wp_parse_args( $meta_box, $this->mb_defaults ); |
126 | - $this->meta_box['fields'] = array(); |
|
126 | + $this->meta_box[ 'fields' ] = array(); |
|
127 | 127 | |
128 | 128 | $this->object_id( $object_id ); |
129 | 129 | $this->mb_object_type(); |
130 | - $this->cmb_id = $meta_box['id']; |
|
130 | + $this->cmb_id = $meta_box[ 'id' ]; |
|
131 | 131 | |
132 | - if ( ! empty( $meta_box['fields'] ) && is_array( $meta_box['fields'] ) ) { |
|
133 | - $this->add_fields( $meta_box['fields'] ); |
|
132 | + if ( ! empty( $meta_box[ 'fields' ] ) && is_array( $meta_box[ 'fields' ] ) ) { |
|
133 | + $this->add_fields( $meta_box[ 'fields' ] ); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | CMB2_Boxes::add( $this ); |
@@ -261,16 +261,16 @@ discard block |
||
261 | 261 | * @return mixed CMB2_Field object if successful. |
262 | 262 | */ |
263 | 263 | public function render_field( $field_args ) { |
264 | - $field_args['context'] = $this->prop( 'context' ); |
|
264 | + $field_args[ 'context' ] = $this->prop( 'context' ); |
|
265 | 265 | |
266 | - if ( 'group' == $field_args['type'] ) { |
|
266 | + if ( 'group' == $field_args[ 'type' ] ) { |
|
267 | 267 | |
268 | - if ( ! isset( $field_args['show_names'] ) ) { |
|
269 | - $field_args['show_names'] = $this->prop( 'show_names' ); |
|
268 | + if ( ! isset( $field_args[ 'show_names' ] ) ) { |
|
269 | + $field_args[ 'show_names' ] = $this->prop( 'show_names' ); |
|
270 | 270 | } |
271 | 271 | $field = $this->render_group( $field_args ); |
272 | 272 | |
273 | - } elseif ( 'hidden' == $field_args['type'] && $this->get_field( $field_args )->should_show() ) { |
|
273 | + } elseif ( 'hidden' == $field_args[ 'type' ] && $this->get_field( $field_args )->should_show() ) { |
|
274 | 274 | // Save rendering for after the metabox |
275 | 275 | $field = $this->add_hidden_field( array( |
276 | 276 | 'field_args' => $field_args, |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | |
281 | 281 | } else { |
282 | 282 | |
283 | - $field_args['show_names'] = $this->prop( 'show_names' ); |
|
283 | + $field_args[ 'show_names' ] = $this->prop( 'show_names' ); |
|
284 | 284 | |
285 | 285 | // Render default fields |
286 | 286 | $field = $this->get_field( $field_args )->render_field(); |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | */ |
297 | 297 | public function render_group( $args ) { |
298 | 298 | |
299 | - if ( ! isset( $args['id'], $args['fields'] ) || ! is_array( $args['fields'] ) ) { |
|
299 | + if ( ! isset( $args[ 'id' ], $args[ 'fields' ] ) || ! is_array( $args[ 'fields' ] ) ) { |
|
300 | 300 | return; |
301 | 301 | } |
302 | 302 | |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | * |
330 | 330 | * @param string $id The group_id of the current group. |
331 | 331 | */ |
332 | - $more_attributes = apply_filters( "cmb2_additional_group_attributes", '', $field_group->args, $args['id'] ); |
|
332 | + $more_attributes = apply_filters( "cmb2_additional_group_attributes", '', $field_group->args, $args[ 'id' ] ); |
|
333 | 333 | |
334 | 334 | $field_group->peform_param_callback( 'before_group' ); |
335 | 335 | |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | <div class="inside cmb-td cmb-nested cmb-field-list">'; |
394 | 394 | // Loop and render repeatable group fields |
395 | 395 | foreach ( array_values( $field_group->args( 'fields' ) ) as $field_args ) { |
396 | - if ( 'hidden' == $field_args['type'] ) { |
|
396 | + if ( 'hidden' == $field_args[ 'type' ] ) { |
|
397 | 397 | |
398 | 398 | // Save rendering for after the metabox |
399 | 399 | $this->add_hidden_field( array( |
@@ -403,8 +403,8 @@ discard block |
||
403 | 403 | |
404 | 404 | } else { |
405 | 405 | |
406 | - $field_args['show_names'] = $field_group->args( 'show_names' ); |
|
407 | - $field_args['context'] = $field_group->args( 'context' ); |
|
406 | + $field_args[ 'show_names' ] = $field_group->args( 'show_names' ); |
|
407 | + $field_args[ 'context' ] = $field_group->args( 'context' ); |
|
408 | 408 | |
409 | 409 | $field = $this->get_field( $field_args, $field_group )->render_field(); |
410 | 410 | } |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | */ |
434 | 434 | public function add_hidden_field( $args ) { |
435 | 435 | $field = new CMB2_Field( $args ); |
436 | - $this->hidden_fields[] = new CMB2_Types( $field ); |
|
436 | + $this->hidden_fields[ ] = new CMB2_Types( $field ); |
|
437 | 437 | |
438 | 438 | return $field; |
439 | 439 | } |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | */ |
573 | 573 | public function process_field( $field_args ) { |
574 | 574 | |
575 | - switch ( $field_args['type'] ) { |
|
575 | + switch ( $field_args[ 'type' ] ) { |
|
576 | 576 | |
577 | 577 | case 'group': |
578 | 578 | $this->save_group( $field_args ); |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | ) ); |
593 | 593 | |
594 | 594 | if ( $field->save_field_from_data( $this->data_to_save ) ) { |
595 | - $this->updated[] = $field->id(); |
|
595 | + $this->updated[ ] = $field->id(); |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | break; |
@@ -605,11 +605,11 @@ discard block |
||
605 | 605 | */ |
606 | 606 | public function save_group( $args ) { |
607 | 607 | |
608 | - if ( ! isset( $args['id'], $args['fields'], $this->data_to_save[ $args['id'] ] ) || ! is_array( $args['fields'] ) ) { |
|
608 | + if ( ! isset( $args[ 'id' ], $args[ 'fields' ], $this->data_to_save[ $args[ 'id' ] ] ) || ! is_array( $args[ 'fields' ] ) ) { |
|
609 | 609 | return; |
610 | 610 | } |
611 | 611 | |
612 | - $field_group = new CMB2_Field( array( |
|
612 | + $field_group = new CMB2_Field( array( |
|
613 | 613 | 'field_args' => $args, |
614 | 614 | 'object_type' => $this->object_type(), |
615 | 615 | 'object_id' => $this->object_id(), |
@@ -644,16 +644,16 @@ discard block |
||
644 | 644 | $_new_val = array(); |
645 | 645 | foreach ( $new_val as $group_index => $grouped_data ) { |
646 | 646 | // Add the supporting data to the $saved array stack |
647 | - $saved[ $field_group->index ][ $grouped_data['supporting_field_id'] ][] = $grouped_data['supporting_field_value']; |
|
647 | + $saved[ $field_group->index ][ $grouped_data[ 'supporting_field_id' ] ][ ] = $grouped_data[ 'supporting_field_value' ]; |
|
648 | 648 | // Reset var to the actual value |
649 | - $_new_val[ $group_index ] = $grouped_data['value']; |
|
649 | + $_new_val[ $group_index ] = $grouped_data[ 'value' ]; |
|
650 | 650 | } |
651 | 651 | $new_val = $_new_val; |
652 | 652 | } else { |
653 | 653 | // Add the supporting data to the $saved array stack |
654 | - $saved[ $field_group->index ][ $new_val['supporting_field_id'] ] = $new_val['supporting_field_value']; |
|
654 | + $saved[ $field_group->index ][ $new_val[ 'supporting_field_id' ] ] = $new_val[ 'supporting_field_value' ]; |
|
655 | 655 | // Reset var to the actual value |
656 | - $new_val = $new_val['value']; |
|
656 | + $new_val = $new_val[ 'value' ]; |
|
657 | 657 | } |
658 | 658 | } |
659 | 659 | |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | $is_removed = ( empty( $new_val ) && ! empty( $old_val ) ); |
667 | 667 | // Compare values and add to `$updated` array |
668 | 668 | if ( $is_updated || $is_removed ) { |
669 | - $this->updated[] = $base_id . '::' . $field_group->index . '::' . $sub_id; |
|
669 | + $this->updated[ ] = $base_id . '::' . $field_group->index . '::' . $sub_id; |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | // Add to `$saved` array |
@@ -701,22 +701,22 @@ discard block |
||
701 | 701 | // Try to get our object ID from the global space |
702 | 702 | switch ( $this->object_type() ) { |
703 | 703 | case 'user': |
704 | - $object_id = isset( $_REQUEST['user_id'] ) ? $_REQUEST['user_id'] : $object_id; |
|
705 | - $object_id = ! $object_id && 'user-new.php' != $pagenow && isset( $GLOBALS['user_ID'] ) ? $GLOBALS['user_ID'] : $object_id; |
|
704 | + $object_id = isset( $_REQUEST[ 'user_id' ] ) ? $_REQUEST[ 'user_id' ] : $object_id; |
|
705 | + $object_id = ! $object_id && 'user-new.php' != $pagenow && isset( $GLOBALS[ 'user_ID' ] ) ? $GLOBALS[ 'user_ID' ] : $object_id; |
|
706 | 706 | break; |
707 | 707 | |
708 | 708 | case 'comment': |
709 | - $object_id = isset( $_REQUEST['c'] ) ? $_REQUEST['c'] : $object_id; |
|
710 | - $object_id = ! $object_id && isset( $GLOBALS['comments']->comment_ID ) ? $GLOBALS['comments']->comment_ID : $object_id; |
|
709 | + $object_id = isset( $_REQUEST[ 'c' ] ) ? $_REQUEST[ 'c' ] : $object_id; |
|
710 | + $object_id = ! $object_id && isset( $GLOBALS[ 'comments' ]->comment_ID ) ? $GLOBALS[ 'comments' ]->comment_ID : $object_id; |
|
711 | 711 | break; |
712 | 712 | |
713 | 713 | case 'term': |
714 | - $object_id = isset( $_REQUEST['tag_ID'] ) ? $_REQUEST['tag_ID'] : $object_id; |
|
714 | + $object_id = isset( $_REQUEST[ 'tag_ID' ] ) ? $_REQUEST[ 'tag_ID' ] : $object_id; |
|
715 | 715 | break; |
716 | 716 | |
717 | 717 | default: |
718 | - $object_id = isset( $GLOBALS['post']->ID ) ? $GLOBALS['post']->ID : $object_id; |
|
719 | - $object_id = isset( $_REQUEST['post'] ) ? $_REQUEST['post'] : $object_id; |
|
718 | + $object_id = isset( $GLOBALS[ 'post' ]->ID ) ? $GLOBALS[ 'post' ]->ID : $object_id; |
|
719 | + $object_id = isset( $_REQUEST[ 'post' ] ) ? $_REQUEST[ 'post' ] : $object_id; |
|
720 | 720 | break; |
721 | 721 | } |
722 | 722 | |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | * @return boolean True/False |
789 | 789 | */ |
790 | 790 | public function is_options_page_mb() { |
791 | - 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'] ) ); |
|
791 | + 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' ] ) ); |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | /** |
@@ -854,7 +854,7 @@ discard block |
||
854 | 854 | return $field; |
855 | 855 | } |
856 | 856 | |
857 | - $field_id = is_string( $field ) ? $field : $field['id']; |
|
857 | + $field_id = is_string( $field ) ? $field : $field[ 'id' ]; |
|
858 | 858 | |
859 | 859 | $parent_field_id = ! empty( $field_group ) ? $field_group->id() : ''; |
860 | 860 | $ids = $this->get_field_ids( $field_id, $parent_field_id, true ); |
@@ -890,7 +890,7 @@ discard block |
||
890 | 890 | if ( $field_group && ( $sub_field_id || 0 === $sub_field_id ) ) { |
891 | 891 | |
892 | 892 | // Update the fields array w/ any modified properties inherited from the group field |
893 | - $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] = $field_args; |
|
893 | + $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] = $field_args; |
|
894 | 894 | |
895 | 895 | return array( |
896 | 896 | 'field_args' => $field_args, |
@@ -900,11 +900,11 @@ discard block |
||
900 | 900 | } |
901 | 901 | |
902 | 902 | if ( is_array( $field_args ) ) { |
903 | - $this->meta_box['fields'][ $field_id ] = array_merge( $field_args, $this->meta_box['fields'][ $field_id ] ); |
|
903 | + $this->meta_box[ 'fields' ][ $field_id ] = array_merge( $field_args, $this->meta_box[ 'fields' ][ $field_id ] ); |
|
904 | 904 | } |
905 | 905 | |
906 | 906 | return array( |
907 | - 'field_args' => $this->meta_box['fields'][ $field_id ], |
|
907 | + 'field_args' => $this->meta_box[ 'fields' ][ $field_id ], |
|
908 | 908 | 'object_type' => $this->object_type(), |
909 | 909 | 'object_id' => $this->object_id(), |
910 | 910 | ); |
@@ -921,8 +921,8 @@ discard block |
||
921 | 921 | |
922 | 922 | $sub_fields = false; |
923 | 923 | if ( array_key_exists( 'fields', $field ) ) { |
924 | - $sub_fields = $field['fields']; |
|
925 | - unset( $field['fields'] ); |
|
924 | + $sub_fields = $field[ 'fields' ]; |
|
925 | + unset( $field[ 'fields' ] ); |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | $field_id = $parent_field_id |
@@ -947,18 +947,18 @@ discard block |
||
947 | 947 | return false; |
948 | 948 | } |
949 | 949 | |
950 | - if ( 'oembed' === $field['type'] ) { |
|
950 | + if ( 'oembed' === $field[ 'type' ] ) { |
|
951 | 951 | // Initiate oembed Ajax hooks |
952 | 952 | cmb2_ajax(); |
953 | 953 | } |
954 | 954 | |
955 | 955 | $this->_add_field_to_array( |
956 | 956 | $field, |
957 | - $this->meta_box['fields'], |
|
957 | + $this->meta_box[ 'fields' ], |
|
958 | 958 | $position |
959 | 959 | ); |
960 | 960 | |
961 | - return $field['id']; |
|
961 | + return $field[ 'id' ]; |
|
962 | 962 | } |
963 | 963 | |
964 | 964 | /** |
@@ -970,27 +970,27 @@ discard block |
||
970 | 970 | * @return mixed Array of parent/field ids or false |
971 | 971 | */ |
972 | 972 | public function add_group_field( $parent_field_id, array $field, $position = 0 ) { |
973 | - if ( ! array_key_exists( $parent_field_id, $this->meta_box['fields'] ) ) { |
|
973 | + if ( ! array_key_exists( $parent_field_id, $this->meta_box[ 'fields' ] ) ) { |
|
974 | 974 | return false; |
975 | 975 | } |
976 | 976 | |
977 | - $parent_field = $this->meta_box['fields'][ $parent_field_id ]; |
|
977 | + $parent_field = $this->meta_box[ 'fields' ][ $parent_field_id ]; |
|
978 | 978 | |
979 | - if ( 'group' !== $parent_field['type'] ) { |
|
979 | + if ( 'group' !== $parent_field[ 'type' ] ) { |
|
980 | 980 | return false; |
981 | 981 | } |
982 | 982 | |
983 | - if ( ! isset( $parent_field['fields'] ) ) { |
|
984 | - $this->meta_box['fields'][ $parent_field_id ]['fields'] = array(); |
|
983 | + if ( ! isset( $parent_field[ 'fields' ] ) ) { |
|
984 | + $this->meta_box[ 'fields' ][ $parent_field_id ][ 'fields' ] = array(); |
|
985 | 985 | } |
986 | 986 | |
987 | 987 | $this->_add_field_to_array( |
988 | 988 | $field, |
989 | - $this->meta_box['fields'][ $parent_field_id ]['fields'], |
|
989 | + $this->meta_box[ 'fields' ][ $parent_field_id ][ 'fields' ], |
|
990 | 990 | $position |
991 | 991 | ); |
992 | 992 | |
993 | - return array( $parent_field_id, $field['id'] ); |
|
993 | + return array( $parent_field_id, $field[ 'id' ] ); |
|
994 | 994 | } |
995 | 995 | |
996 | 996 | /** |
@@ -1002,9 +1002,9 @@ discard block |
||
1002 | 1002 | */ |
1003 | 1003 | protected function _add_field_to_array( $field, &$fields, $position = 0 ) { |
1004 | 1004 | if ( $position ) { |
1005 | - cmb2_utils()->array_insert( $fields, array( $field['id'] => $field ), $position ); |
|
1005 | + cmb2_utils()->array_insert( $fields, array( $field[ 'id' ] => $field ), $position ); |
|
1006 | 1006 | } else { |
1007 | - $fields[ $field['id'] ] = $field; |
|
1007 | + $fields[ $field[ 'id' ] ] = $field; |
|
1008 | 1008 | } |
1009 | 1009 | } |
1010 | 1010 | |
@@ -1027,15 +1027,15 @@ discard block |
||
1027 | 1027 | unset( $this->fields[ implode( '', $ids ) ] ); |
1028 | 1028 | |
1029 | 1029 | if ( ! $sub_field_id ) { |
1030 | - unset( $this->meta_box['fields'][ $field_id ] ); |
|
1030 | + unset( $this->meta_box[ 'fields' ][ $field_id ] ); |
|
1031 | 1031 | return true; |
1032 | 1032 | } |
1033 | 1033 | |
1034 | - if ( isset( $this->fields[ $field_id ]->args['fields'][ $sub_field_id ] ) ) { |
|
1035 | - unset( $this->fields[ $field_id ]->args['fields'][ $sub_field_id ] ); |
|
1034 | + if ( isset( $this->fields[ $field_id ]->args[ 'fields' ][ $sub_field_id ] ) ) { |
|
1035 | + unset( $this->fields[ $field_id ]->args[ 'fields' ][ $sub_field_id ] ); |
|
1036 | 1036 | } |
1037 | - if ( isset( $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] ) ) { |
|
1038 | - unset( $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] ); |
|
1037 | + if ( isset( $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] ) ) { |
|
1038 | + unset( $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] ); |
|
1039 | 1039 | } |
1040 | 1040 | return true; |
1041 | 1041 | } |
@@ -1059,11 +1059,11 @@ discard block |
||
1059 | 1059 | list( $field_id, $sub_field_id ) = $ids; |
1060 | 1060 | |
1061 | 1061 | if ( ! $sub_field_id ) { |
1062 | - $this->meta_box['fields'][ $field_id ][ $property ] = $value; |
|
1062 | + $this->meta_box[ 'fields' ][ $field_id ][ $property ] = $value; |
|
1063 | 1063 | return $field_id; |
1064 | 1064 | } |
1065 | 1065 | |
1066 | - $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ][ $property ] = $value; |
|
1066 | + $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ][ $property ] = $value; |
|
1067 | 1067 | return $field_id; |
1068 | 1068 | } |
1069 | 1069 | |
@@ -1077,7 +1077,7 @@ discard block |
||
1077 | 1077 | public function get_field_ids( $field_id, $parent_field_id = '' ) { |
1078 | 1078 | $sub_field_id = $parent_field_id ? $field_id : ''; |
1079 | 1079 | $field_id = $parent_field_id ? $parent_field_id : $field_id; |
1080 | - $fields =& $this->meta_box['fields']; |
|
1080 | + $fields = & $this->meta_box[ 'fields' ]; |
|
1081 | 1081 | |
1082 | 1082 | if ( ! array_key_exists( $field_id, $fields ) ) { |
1083 | 1083 | $field_id = $this->search_old_school_array( $field_id, $fields ); |
@@ -1091,12 +1091,12 @@ discard block |
||
1091 | 1091 | return array( $field_id, $sub_field_id ); |
1092 | 1092 | } |
1093 | 1093 | |
1094 | - if ( 'group' !== $fields[ $field_id ]['type'] ) { |
|
1094 | + if ( 'group' !== $fields[ $field_id ][ 'type' ] ) { |
|
1095 | 1095 | return false; |
1096 | 1096 | } |
1097 | 1097 | |
1098 | - if ( ! array_key_exists( $sub_field_id, $fields[ $field_id ]['fields'] ) ) { |
|
1099 | - $sub_field_id = $this->search_old_school_array( $sub_field_id, $fields[ $field_id ]['fields'] ); |
|
1098 | + if ( ! array_key_exists( $sub_field_id, $fields[ $field_id ][ 'fields' ] ) ) { |
|
1099 | + $sub_field_id = $this->search_old_school_array( $sub_field_id, $fields[ $field_id ][ 'fields' ] ); |
|
1100 | 1100 | } |
1101 | 1101 | |
1102 | 1102 | return false === $sub_field_id ? false : array( $field_id, $sub_field_id ); |