@@ -123,19 +123,19 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public function __construct( $config, $object_id = 0 ) { |
125 | 125 | |
126 | - if ( empty( $config['id'] ) ) { |
|
126 | + if ( empty( $config[ 'id' ] ) ) { |
|
127 | 127 | wp_die( esc_html__( 'Metabox configuration is required to have an ID parameter.', 'cmb2' ) ); |
128 | 128 | } |
129 | 129 | |
130 | 130 | $this->meta_box = wp_parse_args( $config, $this->mb_defaults ); |
131 | - $this->meta_box['fields'] = array(); |
|
131 | + $this->meta_box[ 'fields' ] = array(); |
|
132 | 132 | |
133 | 133 | $this->object_id( $object_id ); |
134 | 134 | $this->mb_object_type(); |
135 | - $this->cmb_id = $config['id']; |
|
135 | + $this->cmb_id = $config[ 'id' ]; |
|
136 | 136 | |
137 | - if ( ! empty( $config['fields'] ) && is_array( $config['fields'] ) ) { |
|
138 | - $this->add_fields( $config['fields'] ); |
|
137 | + if ( ! empty( $config[ 'fields' ] ) && is_array( $config[ 'fields' ] ) ) { |
|
138 | + $this->add_fields( $config[ 'fields' ] ); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | CMB2_Boxes::add( $this ); |
@@ -243,17 +243,17 @@ discard block |
||
243 | 243 | |
244 | 244 | // Include custom class if requesting no title. |
245 | 245 | if ( ! $this->prop( 'title' ) && ! $this->prop( 'remove_box_wrap' ) ) { |
246 | - $context[] = 'cmb2-context-wrap-no-title'; |
|
246 | + $context[ ] = 'cmb2-context-wrap-no-title'; |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | // Include a generic context wrapper. |
250 | - $context[] = 'cmb2-context-wrap'; |
|
250 | + $context[ ] = 'cmb2-context-wrap'; |
|
251 | 251 | |
252 | 252 | // Include a context-type based context wrapper. |
253 | - $context[] = 'cmb2-context-wrap-' . $this->prop( 'context' ); |
|
253 | + $context[ ] = 'cmb2-context-wrap-' . $this->prop( 'context' ); |
|
254 | 254 | |
255 | 255 | // Include an ID based context wrapper as well. |
256 | - $context[] = 'cmb2-context-wrap-' . $this->prop( 'id' ); |
|
256 | + $context[ ] = 'cmb2-context-wrap-' . $this->prop( 'id' ); |
|
257 | 257 | |
258 | 258 | // And merge all the classes back into the array. |
259 | 259 | $classes = array_merge( $classes, $context ); |
@@ -332,22 +332,22 @@ discard block |
||
332 | 332 | * @return mixed CMB2_Field object if successful. |
333 | 333 | */ |
334 | 334 | public function render_field( $field_args ) { |
335 | - $field_args['context'] = $this->prop( 'context' ); |
|
335 | + $field_args[ 'context' ] = $this->prop( 'context' ); |
|
336 | 336 | |
337 | - if ( 'group' == $field_args['type'] ) { |
|
337 | + if ( 'group' == $field_args[ 'type' ] ) { |
|
338 | 338 | |
339 | - if ( ! isset( $field_args['show_names'] ) ) { |
|
340 | - $field_args['show_names'] = $this->prop( 'show_names' ); |
|
339 | + if ( ! isset( $field_args[ 'show_names' ] ) ) { |
|
340 | + $field_args[ 'show_names' ] = $this->prop( 'show_names' ); |
|
341 | 341 | } |
342 | 342 | $field = $this->render_group( $field_args ); |
343 | 343 | |
344 | - } elseif ( 'hidden' == $field_args['type'] && $this->get_field( $field_args )->should_show() ) { |
|
344 | + } elseif ( 'hidden' == $field_args[ 'type' ] && $this->get_field( $field_args )->should_show() ) { |
|
345 | 345 | // Save rendering for after the metabox |
346 | 346 | $field = $this->add_hidden_field( $field_args ); |
347 | 347 | |
348 | 348 | } else { |
349 | 349 | |
350 | - $field_args['show_names'] = $this->prop( 'show_names' ); |
|
350 | + $field_args[ 'show_names' ] = $this->prop( 'show_names' ); |
|
351 | 351 | |
352 | 352 | // Render default fields |
353 | 353 | $field = $this->get_field( $field_args )->render_field(); |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | */ |
364 | 364 | public function render_group( $args ) { |
365 | 365 | |
366 | - if ( ! isset( $args['id'], $args['fields'] ) || ! is_array( $args['fields'] ) ) { |
|
366 | + if ( ! isset( $args[ 'id' ], $args[ 'fields' ] ) || ! is_array( $args[ 'fields' ] ) ) { |
|
367 | 367 | return; |
368 | 368 | } |
369 | 369 | |
@@ -473,15 +473,15 @@ discard block |
||
473 | 473 | <div class="inside cmb-td cmb-nested cmb-field-list">'; |
474 | 474 | // Loop and render repeatable group fields |
475 | 475 | foreach ( array_values( $field_group->args( 'fields' ) ) as $field_args ) { |
476 | - if ( 'hidden' == $field_args['type'] ) { |
|
476 | + if ( 'hidden' == $field_args[ 'type' ] ) { |
|
477 | 477 | |
478 | 478 | // Save rendering for after the metabox |
479 | 479 | $this->add_hidden_field( $field_args, $field_group ); |
480 | 480 | |
481 | 481 | } else { |
482 | 482 | |
483 | - $field_args['show_names'] = $field_group->args( 'show_names' ); |
|
484 | - $field_args['context'] = $field_group->args( 'context' ); |
|
483 | + $field_args[ 'show_names' ] = $field_group->args( 'show_names' ); |
|
484 | + $field_args[ 'context' ] = $field_group->args( 'context' ); |
|
485 | 485 | |
486 | 486 | $field = $this->get_field( $field_args, $field_group )->render_field(); |
487 | 487 | } |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | * @param CMB2_Field|null $field_group CMB2_Field group field object |
511 | 511 | */ |
512 | 512 | public function add_hidden_field( $field_args, $field_group = null ) { |
513 | - if ( isset( $field_args['field_args'] ) ) { |
|
513 | + if ( isset( $field_args[ 'field_args' ] ) ) { |
|
514 | 514 | // For back-compatibility. |
515 | 515 | $field = new CMB2_Field( $field_args ); |
516 | 516 | } else { |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | $types->iterator = $field_group->index; |
524 | 524 | } |
525 | 525 | |
526 | - $this->hidden_fields[] = $types; |
|
526 | + $this->hidden_fields[ ] = $types; |
|
527 | 527 | |
528 | 528 | return $field; |
529 | 529 | } |
@@ -626,11 +626,11 @@ discard block |
||
626 | 626 | */ |
627 | 627 | public function process_field( $field_args ) { |
628 | 628 | |
629 | - switch ( $field_args['type'] ) { |
|
629 | + switch ( $field_args[ 'type' ] ) { |
|
630 | 630 | |
631 | 631 | case 'group': |
632 | 632 | if ( $this->save_group( $field_args ) ) { |
633 | - $this->updated[] = $field_args['id']; |
|
633 | + $this->updated[ ] = $field_args[ 'id' ]; |
|
634 | 634 | } |
635 | 635 | |
636 | 636 | break; |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | $field = $this->get_new_field( $field_args ); |
645 | 645 | |
646 | 646 | if ( $field->save_field_from_data( $this->data_to_save ) ) { |
647 | - $this->updated[] = $field->id(); |
|
647 | + $this->updated[ ] = $field->id(); |
|
648 | 648 | } |
649 | 649 | |
650 | 650 | break; |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | * @return mixed Return of CMB2_Field::update_data() |
712 | 712 | */ |
713 | 713 | public function save_group( $args ) { |
714 | - if ( ! isset( $args['id'], $args['fields'] ) || ! is_array( $args['fields'] ) ) { |
|
714 | + if ( ! isset( $args[ 'id' ], $args[ 'fields' ] ) || ! is_array( $args[ 'fields' ] ) ) { |
|
715 | 715 | return; |
716 | 716 | } |
717 | 717 | |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | $field_group->data_to_save = $this->data_to_save; |
741 | 741 | |
742 | 742 | foreach ( array_values( $field_group->fields() ) as $field_args ) { |
743 | - if ( 'title' === $field_args['type'] ) { |
|
743 | + if ( 'title' === $field_args[ 'type' ] ) { |
|
744 | 744 | // Don't process title fields |
745 | 745 | continue; |
746 | 746 | } |
@@ -763,16 +763,16 @@ discard block |
||
763 | 763 | $_new_val = array(); |
764 | 764 | foreach ( $new_val as $group_index => $grouped_data ) { |
765 | 765 | // Add the supporting data to the $saved array stack |
766 | - $saved[ $field_group->index ][ $grouped_data['supporting_field_id'] ][] = $grouped_data['supporting_field_value']; |
|
766 | + $saved[ $field_group->index ][ $grouped_data[ 'supporting_field_id' ] ][ ] = $grouped_data[ 'supporting_field_value' ]; |
|
767 | 767 | // Reset var to the actual value |
768 | - $_new_val[ $group_index ] = $grouped_data['value']; |
|
768 | + $_new_val[ $group_index ] = $grouped_data[ 'value' ]; |
|
769 | 769 | } |
770 | 770 | $new_val = $_new_val; |
771 | 771 | } else { |
772 | 772 | // Add the supporting data to the $saved array stack |
773 | - $saved[ $field_group->index ][ $new_val['supporting_field_id'] ] = $new_val['supporting_field_value']; |
|
773 | + $saved[ $field_group->index ][ $new_val[ 'supporting_field_id' ] ] = $new_val[ 'supporting_field_value' ]; |
|
774 | 774 | // Reset var to the actual value |
775 | - $new_val = $new_val['value']; |
|
775 | + $new_val = $new_val[ 'value' ]; |
|
776 | 776 | } |
777 | 777 | } |
778 | 778 | |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | |
787 | 787 | // Compare values and add to `$updated` array |
788 | 788 | if ( $is_updated || $is_removed ) { |
789 | - $this->updated[] = $base_id . '::' . $field_group->index . '::' . $sub_id; |
|
789 | + $this->updated[ ] = $base_id . '::' . $field_group->index . '::' . $sub_id; |
|
790 | 790 | } |
791 | 791 | |
792 | 792 | // Add to `$saved` array |
@@ -823,22 +823,22 @@ discard block |
||
823 | 823 | // Try to get our object ID from the global space |
824 | 824 | switch ( $this->object_type() ) { |
825 | 825 | case 'user': |
826 | - $object_id = isset( $_REQUEST['user_id'] ) ? $_REQUEST['user_id'] : $object_id; |
|
827 | - $object_id = ! $object_id && 'user-new.php' != $pagenow && isset( $GLOBALS['user_ID'] ) ? $GLOBALS['user_ID'] : $object_id; |
|
826 | + $object_id = isset( $_REQUEST[ 'user_id' ] ) ? $_REQUEST[ 'user_id' ] : $object_id; |
|
827 | + $object_id = ! $object_id && 'user-new.php' != $pagenow && isset( $GLOBALS[ 'user_ID' ] ) ? $GLOBALS[ 'user_ID' ] : $object_id; |
|
828 | 828 | break; |
829 | 829 | |
830 | 830 | case 'comment': |
831 | - $object_id = isset( $_REQUEST['c'] ) ? $_REQUEST['c'] : $object_id; |
|
832 | - $object_id = ! $object_id && isset( $GLOBALS['comments']->comment_ID ) ? $GLOBALS['comments']->comment_ID : $object_id; |
|
831 | + $object_id = isset( $_REQUEST[ 'c' ] ) ? $_REQUEST[ 'c' ] : $object_id; |
|
832 | + $object_id = ! $object_id && isset( $GLOBALS[ 'comments' ]->comment_ID ) ? $GLOBALS[ 'comments' ]->comment_ID : $object_id; |
|
833 | 833 | break; |
834 | 834 | |
835 | 835 | case 'term': |
836 | - $object_id = isset( $_REQUEST['tag_ID'] ) ? $_REQUEST['tag_ID'] : $object_id; |
|
836 | + $object_id = isset( $_REQUEST[ 'tag_ID' ] ) ? $_REQUEST[ 'tag_ID' ] : $object_id; |
|
837 | 837 | break; |
838 | 838 | |
839 | 839 | default: |
840 | - $object_id = isset( $GLOBALS['post']->ID ) ? $GLOBALS['post']->ID : $object_id; |
|
841 | - $object_id = isset( $_REQUEST['post'] ) ? $_REQUEST['post'] : $object_id; |
|
840 | + $object_id = isset( $GLOBALS[ 'post' ]->ID ) ? $GLOBALS[ 'post' ]->ID : $object_id; |
|
841 | + $object_id = isset( $_REQUEST[ 'post' ] ) ? $_REQUEST[ 'post' ] : $object_id; |
|
842 | 842 | break; |
843 | 843 | } |
844 | 844 | |
@@ -909,7 +909,7 @@ discard block |
||
909 | 909 | * @return boolean True/False |
910 | 910 | */ |
911 | 911 | public function is_options_page_mb() { |
912 | - 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'] ) ); |
|
912 | + 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' ] ) ); |
|
913 | 913 | } |
914 | 914 | |
915 | 915 | /** |
@@ -953,7 +953,7 @@ discard block |
||
953 | 953 | $type = 'term'; |
954 | 954 | } |
955 | 955 | |
956 | - if ( defined( 'DOING_AJAX' ) && isset( $_POST['action'] ) && 'add-tag' === $_POST['action'] ) { |
|
956 | + if ( defined( 'DOING_AJAX' ) && isset( $_POST[ 'action' ] ) && 'add-tag' === $_POST[ 'action' ] ) { |
|
957 | 957 | $type = 'term'; |
958 | 958 | } |
959 | 959 | |
@@ -1000,7 +1000,7 @@ discard block |
||
1000 | 1000 | return $field; |
1001 | 1001 | } |
1002 | 1002 | |
1003 | - $field_id = is_string( $field ) ? $field : $field['id']; |
|
1003 | + $field_id = is_string( $field ) ? $field : $field[ 'id' ]; |
|
1004 | 1004 | |
1005 | 1005 | $parent_field_id = ! empty( $field_group ) ? $field_group->id() : ''; |
1006 | 1006 | $ids = $this->get_field_ids( $field_id, $parent_field_id ); |
@@ -1036,16 +1036,16 @@ discard block |
||
1036 | 1036 | if ( $field_group && ( $sub_field_id || 0 === $sub_field_id ) ) { |
1037 | 1037 | |
1038 | 1038 | // Update the fields array w/ any modified properties inherited from the group field |
1039 | - $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] = $field_args; |
|
1039 | + $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] = $field_args; |
|
1040 | 1040 | |
1041 | 1041 | return $this->get_default_args( $field_args, $field_group ); |
1042 | 1042 | } |
1043 | 1043 | |
1044 | 1044 | if ( is_array( $field_args ) ) { |
1045 | - $this->meta_box['fields'][ $field_id ] = array_merge( $field_args, $this->meta_box['fields'][ $field_id ] ); |
|
1045 | + $this->meta_box[ 'fields' ][ $field_id ] = array_merge( $field_args, $this->meta_box[ 'fields' ][ $field_id ] ); |
|
1046 | 1046 | } |
1047 | 1047 | |
1048 | - return $this->get_default_args( $this->meta_box['fields'][ $field_id ] ); |
|
1048 | + return $this->get_default_args( $this->meta_box[ 'fields' ][ $field_id ] ); |
|
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | /** |
@@ -1095,8 +1095,8 @@ discard block |
||
1095 | 1095 | |
1096 | 1096 | $sub_fields = false; |
1097 | 1097 | if ( array_key_exists( 'fields', $field ) ) { |
1098 | - $sub_fields = $field['fields']; |
|
1099 | - unset( $field['fields'] ); |
|
1098 | + $sub_fields = $field[ 'fields' ]; |
|
1099 | + unset( $field[ 'fields' ] ); |
|
1100 | 1100 | } |
1101 | 1101 | |
1102 | 1102 | $field_id = $parent_field_id |
@@ -1121,26 +1121,26 @@ discard block |
||
1121 | 1121 | return false; |
1122 | 1122 | } |
1123 | 1123 | |
1124 | - if ( 'oembed' === $field['type'] ) { |
|
1124 | + if ( 'oembed' === $field[ 'type' ] ) { |
|
1125 | 1125 | // Initiate oembed Ajax hooks |
1126 | 1126 | cmb2_ajax(); |
1127 | 1127 | } |
1128 | 1128 | |
1129 | - if ( isset( $field['column'] ) && false !== $field['column'] ) { |
|
1129 | + if ( isset( $field[ 'column' ] ) && false !== $field[ 'column' ] ) { |
|
1130 | 1130 | $field = $this->define_field_column( $field ); |
1131 | 1131 | } |
1132 | 1132 | |
1133 | - if ( isset( $field['taxonomy'] ) && ! empty( $field['remove_default'] ) ) { |
|
1134 | - $this->tax_metaboxes_to_remove[ $field['taxonomy'] ] = $field['taxonomy']; |
|
1133 | + if ( isset( $field[ 'taxonomy' ] ) && ! empty( $field[ 'remove_default' ] ) ) { |
|
1134 | + $this->tax_metaboxes_to_remove[ $field[ 'taxonomy' ] ] = $field[ 'taxonomy' ]; |
|
1135 | 1135 | } |
1136 | 1136 | |
1137 | 1137 | $this->_add_field_to_array( |
1138 | 1138 | $field, |
1139 | - $this->meta_box['fields'], |
|
1139 | + $this->meta_box[ 'fields' ], |
|
1140 | 1140 | $position |
1141 | 1141 | ); |
1142 | 1142 | |
1143 | - return $field['id']; |
|
1143 | + return $field[ 'id' ]; |
|
1144 | 1144 | } |
1145 | 1145 | |
1146 | 1146 | /** |
@@ -1152,10 +1152,10 @@ discard block |
||
1152 | 1152 | protected function define_field_column( array $field ) { |
1153 | 1153 | $this->has_columns = true; |
1154 | 1154 | |
1155 | - $column = is_array( $field['column'] ) ? $field['column'] : array(); |
|
1155 | + $column = is_array( $field[ 'column' ] ) ? $field[ 'column' ] : array(); |
|
1156 | 1156 | |
1157 | - $field['column'] = wp_parse_args( $column, array( |
|
1158 | - 'name' => isset( $field['name'] ) ? $field['name'] : '', |
|
1157 | + $field[ 'column' ] = wp_parse_args( $column, array( |
|
1158 | + 'name' => isset( $field[ 'name' ] ) ? $field[ 'name' ] : '', |
|
1159 | 1159 | 'position' => false, |
1160 | 1160 | ) ); |
1161 | 1161 | |
@@ -1171,27 +1171,27 @@ discard block |
||
1171 | 1171 | * @return mixed Array of parent/field ids or false |
1172 | 1172 | */ |
1173 | 1173 | public function add_group_field( $parent_field_id, array $field, $position = 0 ) { |
1174 | - if ( ! array_key_exists( $parent_field_id, $this->meta_box['fields'] ) ) { |
|
1174 | + if ( ! array_key_exists( $parent_field_id, $this->meta_box[ 'fields' ] ) ) { |
|
1175 | 1175 | return false; |
1176 | 1176 | } |
1177 | 1177 | |
1178 | - $parent_field = $this->meta_box['fields'][ $parent_field_id ]; |
|
1178 | + $parent_field = $this->meta_box[ 'fields' ][ $parent_field_id ]; |
|
1179 | 1179 | |
1180 | - if ( 'group' !== $parent_field['type'] ) { |
|
1180 | + if ( 'group' !== $parent_field[ 'type' ] ) { |
|
1181 | 1181 | return false; |
1182 | 1182 | } |
1183 | 1183 | |
1184 | - if ( ! isset( $parent_field['fields'] ) ) { |
|
1185 | - $this->meta_box['fields'][ $parent_field_id ]['fields'] = array(); |
|
1184 | + if ( ! isset( $parent_field[ 'fields' ] ) ) { |
|
1185 | + $this->meta_box[ 'fields' ][ $parent_field_id ][ 'fields' ] = array(); |
|
1186 | 1186 | } |
1187 | 1187 | |
1188 | 1188 | $this->_add_field_to_array( |
1189 | 1189 | $field, |
1190 | - $this->meta_box['fields'][ $parent_field_id ]['fields'], |
|
1190 | + $this->meta_box[ 'fields' ][ $parent_field_id ][ 'fields' ], |
|
1191 | 1191 | $position |
1192 | 1192 | ); |
1193 | 1193 | |
1194 | - return array( $parent_field_id, $field['id'] ); |
|
1194 | + return array( $parent_field_id, $field[ 'id' ] ); |
|
1195 | 1195 | } |
1196 | 1196 | |
1197 | 1197 | /** |
@@ -1203,9 +1203,9 @@ discard block |
||
1203 | 1203 | */ |
1204 | 1204 | protected function _add_field_to_array( $field, &$fields, $position = 0 ) { |
1205 | 1205 | if ( $position ) { |
1206 | - CMB2_Utils::array_insert( $fields, array( $field['id'] => $field ), $position ); |
|
1206 | + CMB2_Utils::array_insert( $fields, array( $field[ 'id' ] => $field ), $position ); |
|
1207 | 1207 | } else { |
1208 | - $fields[ $field['id'] ] = $field; |
|
1208 | + $fields[ $field[ 'id' ] ] = $field; |
|
1209 | 1209 | } |
1210 | 1210 | } |
1211 | 1211 | |
@@ -1228,15 +1228,15 @@ discard block |
||
1228 | 1228 | unset( $this->fields[ implode( '', $ids ) ] ); |
1229 | 1229 | |
1230 | 1230 | if ( ! $sub_field_id ) { |
1231 | - unset( $this->meta_box['fields'][ $field_id ] ); |
|
1231 | + unset( $this->meta_box[ 'fields' ][ $field_id ] ); |
|
1232 | 1232 | return true; |
1233 | 1233 | } |
1234 | 1234 | |
1235 | - if ( isset( $this->fields[ $field_id ]->args['fields'][ $sub_field_id ] ) ) { |
|
1236 | - unset( $this->fields[ $field_id ]->args['fields'][ $sub_field_id ] ); |
|
1235 | + if ( isset( $this->fields[ $field_id ]->args[ 'fields' ][ $sub_field_id ] ) ) { |
|
1236 | + unset( $this->fields[ $field_id ]->args[ 'fields' ][ $sub_field_id ] ); |
|
1237 | 1237 | } |
1238 | - if ( isset( $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] ) ) { |
|
1239 | - unset( $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] ); |
|
1238 | + if ( isset( $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] ) ) { |
|
1239 | + unset( $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] ); |
|
1240 | 1240 | } |
1241 | 1241 | return true; |
1242 | 1242 | } |
@@ -1260,11 +1260,11 @@ discard block |
||
1260 | 1260 | list( $field_id, $sub_field_id ) = $ids; |
1261 | 1261 | |
1262 | 1262 | if ( ! $sub_field_id ) { |
1263 | - $this->meta_box['fields'][ $field_id ][ $property ] = $value; |
|
1263 | + $this->meta_box[ 'fields' ][ $field_id ][ $property ] = $value; |
|
1264 | 1264 | return $field_id; |
1265 | 1265 | } |
1266 | 1266 | |
1267 | - $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ][ $property ] = $value; |
|
1267 | + $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ][ $property ] = $value; |
|
1268 | 1268 | return $field_id; |
1269 | 1269 | } |
1270 | 1270 | |
@@ -1278,7 +1278,7 @@ discard block |
||
1278 | 1278 | public function get_field_ids( $field_id, $parent_field_id = '' ) { |
1279 | 1279 | $sub_field_id = $parent_field_id ? $field_id : ''; |
1280 | 1280 | $field_id = $parent_field_id ? $parent_field_id : $field_id; |
1281 | - $fields =& $this->meta_box['fields']; |
|
1281 | + $fields = & $this->meta_box[ 'fields' ]; |
|
1282 | 1282 | |
1283 | 1283 | if ( ! array_key_exists( $field_id, $fields ) ) { |
1284 | 1284 | $field_id = $this->search_old_school_array( $field_id, $fields ); |
@@ -1292,12 +1292,12 @@ discard block |
||
1292 | 1292 | return array( $field_id, $sub_field_id ); |
1293 | 1293 | } |
1294 | 1294 | |
1295 | - if ( 'group' !== $fields[ $field_id ]['type'] ) { |
|
1295 | + if ( 'group' !== $fields[ $field_id ][ 'type' ] ) { |
|
1296 | 1296 | return false; |
1297 | 1297 | } |
1298 | 1298 | |
1299 | - if ( ! array_key_exists( $sub_field_id, $fields[ $field_id ]['fields'] ) ) { |
|
1300 | - $sub_field_id = $this->search_old_school_array( $sub_field_id, $fields[ $field_id ]['fields'] ); |
|
1299 | + if ( ! array_key_exists( $sub_field_id, $fields[ $field_id ][ 'fields' ] ) ) { |
|
1300 | + $sub_field_id = $this->search_old_school_array( $sub_field_id, $fields[ $field_id ][ 'fields' ] ); |
|
1301 | 1301 | } |
1302 | 1302 | |
1303 | 1303 | return false === $sub_field_id ? false : array( $field_id, $sub_field_id ); |
@@ -230,7 +230,7 @@ |
||
230 | 230 | * @param string $fieldtype The type of field being rendered. |
231 | 231 | * @param string $render_class_name The default field type class to use. Defaults to null. |
232 | 232 | * @param array $args Optional arguments to pass to type class. |
233 | - * @param mixed $additional Optional additional argument to pass to type class. |
|
233 | + * @param string $additional Optional additional argument to pass to type class. |
|
234 | 234 | * @return CMB2_Type_Base Type object. |
235 | 235 | */ |
236 | 236 | public function get_new_render_type( $fieldtype, $render_class_name = null, $args = array(), $additional = '' ) { |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | // Check for methods to be proxied to the CMB2_Type_Base object. |
55 | 55 | if ( $exists = $this->maybe_proxy_method( $fieldtype, $arguments ) ) { |
56 | - return $exists['value']; |
|
56 | + return $exists[ 'value' ]; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | // Check for custom field type class. |
@@ -481,8 +481,8 @@ discard block |
||
481 | 481 | 'class' => 'cmb2-hidden', |
482 | 482 | ); |
483 | 483 | if ( $this->field->group ) { |
484 | - $args['data-groupid'] = $this->field->group->id(); |
|
485 | - $args['data-iterator'] = $this->iterator; |
|
484 | + $args[ 'data-groupid' ] = $this->field->group->id(); |
|
485 | + $args[ 'data-iterator' ] = $this->iterator; |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | return $this->get_new_render_type( __FUNCTION__, 'CMB2_Type_Text', $args, 'input' )->render(); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $dir = wp_upload_dir(); |
38 | 38 | |
39 | 39 | // Is URL in uploads directory? |
40 | - if ( false === strpos( $img_url, $dir['baseurl'] . '/' ) ) { |
|
40 | + if ( false === strpos( $img_url, $dir[ 'baseurl' ] . '/' ) ) { |
|
41 | 41 | return false; |
42 | 42 | } |
43 | 43 | |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | |
63 | 63 | foreach ( $query->posts as $post_id ) { |
64 | 64 | $meta = wp_get_attachment_metadata( $post_id ); |
65 | - $original_file = basename( $meta['file'] ); |
|
66 | - $cropped_image_files = isset( $meta['sizes'] ) ? wp_list_pluck( $meta['sizes'], 'file' ) : array(); |
|
65 | + $original_file = basename( $meta[ 'file' ] ); |
|
66 | + $cropped_image_files = isset( $meta[ 'sizes' ] ) ? wp_list_pluck( $meta[ 'sizes' ], 'file' ) : array(); |
|
67 | 67 | if ( $original_file === $file || in_array( $file, $cropped_image_files ) ) { |
68 | 68 | $attachment_id = $post_id; |
69 | 69 | break; |
@@ -147,8 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | |
149 | 149 | return self::is_valid_time_stamp( $string ) |
150 | - ? (int) $string : |
|
151 | - strtotime( (string) $string ); |
|
150 | + ? (int) $string : strtotime( (string) $string ); |
|
152 | 151 | } |
153 | 152 | |
154 | 153 | /** |
@@ -179,7 +178,7 @@ discard block |
||
179 | 178 | * @param mixed $value Value to check |
180 | 179 | * @return bool True or false |
181 | 180 | */ |
182 | - public static function notempty( $value ){ |
|
181 | + public static function notempty( $value ) { |
|
183 | 182 | return null !== $value && '' !== $value && false !== $value && array() !== $value; |
184 | 183 | } |
185 | 184 | |
@@ -337,24 +336,24 @@ discard block |
||
337 | 336 | |
338 | 337 | // order is relevant here, since the replacement will be done sequentially. |
339 | 338 | $supported_options = array( |
340 | - 'd' => 'dd', // Day, leading 0 |
|
341 | - 'j' => 'd', // Day, no 0 |
|
342 | - 'z' => 'o', // Day of the year, no leading zeroes, |
|
339 | + 'd' => 'dd', // Day, leading 0 |
|
340 | + 'j' => 'd', // Day, no 0 |
|
341 | + 'z' => 'o', // Day of the year, no leading zeroes, |
|
343 | 342 | // 'D' => 'D', // Day name short, not sure how it'll work with translations |
344 | 343 | // 'l' => 'DD', // Day name full, idem before |
345 | - 'm' => 'mm', // Month of the year, leading 0 |
|
346 | - 'n' => 'm', // Month of the year, no leading 0 |
|
344 | + 'm' => 'mm', // Month of the year, leading 0 |
|
345 | + 'n' => 'm', // Month of the year, no leading 0 |
|
347 | 346 | // 'M' => 'M', // Month, Short name |
348 | 347 | // 'F' => 'MM', // Month, full name, |
349 | - 'y' => 'y', // Year, two digit |
|
350 | - 'Y' => 'yy', // Year, full |
|
351 | - 'H' => 'HH', // Hour with leading 0 (24 hour) |
|
352 | - 'G' => 'H', // Hour with no leading 0 (24 hour) |
|
353 | - 'h' => 'hh', // Hour with leading 0 (12 hour) |
|
354 | - 'g' => 'h', // Hour with no leading 0 (12 hour), |
|
355 | - 'i' => 'mm', // Minute with leading 0, |
|
356 | - 's' => 'ss', // Second with leading 0, |
|
357 | - 'a' => 'tt', // am/pm |
|
348 | + 'y' => 'y', // Year, two digit |
|
349 | + 'Y' => 'yy', // Year, full |
|
350 | + 'H' => 'HH', // Hour with leading 0 (24 hour) |
|
351 | + 'G' => 'H', // Hour with no leading 0 (24 hour) |
|
352 | + 'h' => 'hh', // Hour with leading 0 (12 hour) |
|
353 | + 'g' => 'h', // Hour with no leading 0 (12 hour), |
|
354 | + 'i' => 'mm', // Minute with leading 0, |
|
355 | + 's' => 'ss', // Second with leading 0, |
|
356 | + 'a' => 'tt', // am/pm |
|
358 | 357 | 'A' => 'TT' // AM/PM |
359 | 358 | ); |
360 | 359 | |
@@ -375,7 +374,7 @@ discard block |
||
375 | 374 | * @return string Modified value |
376 | 375 | */ |
377 | 376 | public static function wrap_escaped_chars( $value ) { |
378 | - return "'" . str_replace( '\\', '', $value[0] ) . "'"; |
|
377 | + return "'" . str_replace( '\\', '', $value[ 0 ] ) . "'"; |
|
379 | 378 | } |
380 | 379 | |
381 | 380 | /** |
@@ -434,7 +433,7 @@ discard block |
||
434 | 433 | * @return string String of attributes for form element. |
435 | 434 | */ |
436 | 435 | public static function concat_attrs( $attrs, $attr_exclude = array() ) { |
437 | - $attr_exclude[] = 'rendered'; |
|
436 | + $attr_exclude[ ] = 'rendered'; |
|
438 | 437 | $attributes = ''; |
439 | 438 | foreach ( $attrs as $attr => $val ) { |
440 | 439 | $excluded = in_array( $attr, (array) $attr_exclude, true ); |
@@ -122,7 +122,8 @@ discard block |
||
122 | 122 | $tzstring = ''; |
123 | 123 | } |
124 | 124 | |
125 | - if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists |
|
125 | + if ( empty( $tzstring ) ) { |
|
126 | +// Create a UTC+- zone if no timezone string exists |
|
126 | 127 | if ( 0 == $current_offset ) { |
127 | 128 | $tzstring = 'UTC+0'; |
128 | 129 | } elseif ( $current_offset < 0 ) { |
@@ -179,7 +180,7 @@ discard block |
||
179 | 180 | * @param mixed $value Value to check |
180 | 181 | * @return bool True or false |
181 | 182 | */ |
182 | - public static function notempty( $value ){ |
|
183 | + public static function notempty( $value ) { |
|
183 | 184 | return null !== $value && '' !== $value && false !== $value && array() !== $value; |
184 | 185 | } |
185 | 186 |
@@ -90,18 +90,18 @@ discard block |
||
90 | 90 | $oembed = cmb2_ajax()->get_oembed_no_edit( $args ); |
91 | 91 | |
92 | 92 | // Send back our embed |
93 | - if ( $oembed['embed'] && $oembed['embed'] != $oembed['fallback'] ) { |
|
94 | - return '<div class="cmb2-oembed">' . $oembed['embed'] . '</div>'; |
|
93 | + if ( $oembed[ 'embed' ] && $oembed[ 'embed' ] != $oembed[ 'fallback' ] ) { |
|
94 | + return '<div class="cmb2-oembed">' . $oembed[ 'embed' ] . '</div>'; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | $error = sprintf( |
98 | 98 | /* translators: 1: results for. 2: link to codex.wordpress.org/Embeds */ |
99 | 99 | esc_html__( 'No oEmbed Results Found for %1$s. View more info at %2$s.', 'cmb2' ), |
100 | - $oembed['fallback'], |
|
100 | + $oembed[ 'fallback' ], |
|
101 | 101 | '<a href="https://codex.wordpress.org/Embeds" target="_blank">codex.wordpress.org/Embeds</a>' |
102 | 102 | ); |
103 | 103 | |
104 | - if ( isset( $args['wp_error'] ) && $args['wp_error'] ) { |
|
104 | + if ( isset( $args[ 'wp_error' ] ) && $args[ 'wp_error' ] ) { |
|
105 | 105 | return new WP_Error( 'cmb2_get_oembed_result', $error, compact( 'oembed', 'args' ) ); |
106 | 106 | } |
107 | 107 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | $cmb = CMB2_Boxes::get( $meta_box ); |
217 | 217 | } else { |
218 | 218 | // See if we already have an instance of this metabox |
219 | - $cmb = CMB2_Boxes::get( $meta_box['id'] ); |
|
219 | + $cmb = CMB2_Boxes::get( $meta_box[ 'id' ] ); |
|
220 | 220 | // If not, we'll initate a new metabox |
221 | 221 | $cmb = $cmb ? $cmb : new CMB2( $meta_box, $object_id ); |
222 | 222 | } |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | ) ); |
292 | 292 | |
293 | 293 | // Set object type explicitly (rather than trying to guess from context) |
294 | - $cmb->object_type( $args['object_type'] ); |
|
294 | + $cmb->object_type( $args[ 'object_type' ] ); |
|
295 | 295 | |
296 | 296 | // Save the metabox if it's been submitted |
297 | 297 | // check permissions |
@@ -299,32 +299,32 @@ discard block |
||
299 | 299 | if ( |
300 | 300 | $cmb->prop( 'save_fields' ) |
301 | 301 | // check nonce |
302 | - && isset( $_POST['submit-cmb'], $_POST['object_id'], $_POST[ $cmb->nonce() ] ) |
|
302 | + && isset( $_POST[ 'submit-cmb' ], $_POST[ 'object_id' ], $_POST[ $cmb->nonce() ] ) |
|
303 | 303 | && wp_verify_nonce( $_POST[ $cmb->nonce() ], $cmb->nonce() ) |
304 | - && $object_id && $_POST['object_id'] == $object_id |
|
304 | + && $object_id && $_POST[ 'object_id' ] == $object_id |
|
305 | 305 | ) { |
306 | 306 | $cmb->save_fields( $object_id, $cmb->object_type(), $_POST ); |
307 | 307 | } |
308 | 308 | |
309 | 309 | // Enqueue JS/CSS |
310 | - if ( $args['cmb_styles'] ) { |
|
310 | + if ( $args[ 'cmb_styles' ] ) { |
|
311 | 311 | CMB2_hookup::enqueue_cmb_css(); |
312 | 312 | } |
313 | 313 | |
314 | - if ( $args['enqueue_js'] ) { |
|
314 | + if ( $args[ 'enqueue_js' ] ) { |
|
315 | 315 | CMB2_hookup::enqueue_cmb_js(); |
316 | 316 | } |
317 | 317 | |
318 | - $form_format = apply_filters( 'cmb2_get_metabox_form_format', $args['form_format'], $object_id, $cmb ); |
|
318 | + $form_format = apply_filters( 'cmb2_get_metabox_form_format', $args[ 'form_format' ], $object_id, $cmb ); |
|
319 | 319 | |
320 | 320 | $format_parts = explode( '%3$s', $form_format ); |
321 | 321 | |
322 | 322 | // Show cmb form |
323 | - printf( $format_parts[0], $cmb->cmb_id, $object_id ); |
|
323 | + printf( $format_parts[ 0 ], $cmb->cmb_id, $object_id ); |
|
324 | 324 | $cmb->show_form(); |
325 | 325 | |
326 | - if ( isset( $format_parts[1] ) && $format_parts[1] ) { |
|
327 | - printf( str_ireplace( '%4$s', '%1$s', $format_parts[1] ), $args['save_button'] ); |
|
326 | + if ( isset( $format_parts[ 1 ] ) && $format_parts[ 1 ] ) { |
|
327 | + printf( str_ireplace( '%4$s', '%1$s', $format_parts[ 1 ] ), $args[ 'save_button' ] ); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | } |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | * @param array $args Optional arguments array |
338 | 338 | */ |
339 | 339 | function cmb2_metabox_form( $meta_box, $object_id = 0, $args = array() ) { |
340 | - if ( ! isset( $args['echo'] ) || $args['echo'] ) { |
|
340 | + if ( ! isset( $args[ 'echo' ] ) || $args[ 'echo' ] ) { |
|
341 | 341 | cmb2_print_metabox_form( $meta_box, $object_id, $args ); |
342 | 342 | } else { |
343 | 343 | return cmb2_get_metabox_form( $meta_box, $object_id, $args ); |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | |
360 | 360 | $schedule_format = str_replace( |
361 | 361 | array( 'M', 'Y', 'm', 'd', 'H', 'i', 'a' ), |
362 | - array('%b', '%Y', '%m', '%d', '%H', '%M', '%p' ), |
|
362 | + array( '%b', '%Y', '%m', '%d', '%H', '%M', '%p' ), |
|
363 | 363 | $date_format |
364 | 364 | ); |
365 | 365 | |
@@ -376,14 +376,14 @@ discard block |
||
376 | 376 | * 4 or 2 characters, as needed |
377 | 377 | */ |
378 | 378 | '%04d-%02d-%02d %02d:%02d:%02d', |
379 | - $parsed_time['tm_year'] + 1900, // This will be "111", so we need to add 1900. |
|
380 | - $parsed_time['tm_mon'] + 1, // This will be the month minus one, so we add one. |
|
381 | - $parsed_time['tm_mday'], |
|
382 | - $parsed_time['tm_hour'], |
|
383 | - $parsed_time['tm_min'], |
|
384 | - $parsed_time['tm_sec'] |
|
379 | + $parsed_time[ 'tm_year' ] + 1900, // This will be "111", so we need to add 1900. |
|
380 | + $parsed_time[ 'tm_mon' ] + 1, // This will be the month minus one, so we add one. |
|
381 | + $parsed_time[ 'tm_mday' ], |
|
382 | + $parsed_time[ 'tm_hour' ], |
|
383 | + $parsed_time[ 'tm_min' ], |
|
384 | + $parsed_time[ 'tm_sec' ] |
|
385 | 385 | ); |
386 | 386 | |
387 | - return new DateTime($ymd); |
|
387 | + return new DateTime( $ymd ); |
|
388 | 388 | } |
389 | 389 | } |
@@ -56,23 +56,23 @@ |
||
56 | 56 | $min = $debug ? '' : '.min'; |
57 | 57 | |
58 | 58 | // if colorpicker |
59 | - if ( ! is_admin() && isset( $dependencies['wp-color-picker'] ) ) { |
|
59 | + if ( ! is_admin() && isset( $dependencies[ 'wp-color-picker' ] ) ) { |
|
60 | 60 | self::colorpicker_frontend(); |
61 | 61 | } |
62 | 62 | |
63 | 63 | // if file/file_list |
64 | - if ( isset( $dependencies['media-editor'] ) ) { |
|
64 | + if ( isset( $dependencies[ 'media-editor' ] ) ) { |
|
65 | 65 | wp_enqueue_media(); |
66 | 66 | } |
67 | 67 | |
68 | 68 | // if timepicker |
69 | - if ( isset( $dependencies['jquery-ui-datetimepicker'] ) ) { |
|
69 | + if ( isset( $dependencies[ 'jquery-ui-datetimepicker' ] ) ) { |
|
70 | 70 | wp_register_script( 'jquery-ui-datetimepicker', CMB2_Utils::url( 'js/jquery-ui-timepicker-addon.min.js' ), array( 'jquery-ui-slider' ), CMB2_VERSION ); |
71 | 71 | } |
72 | 72 | |
73 | 73 | // if cmb2-wysiwyg |
74 | - $enqueue_wysiwyg = isset( $dependencies['cmb2-wysiwyg'] ) && $debug; |
|
75 | - unset( $dependencies['cmb2-wysiwyg'] ); |
|
74 | + $enqueue_wysiwyg = isset( $dependencies[ 'cmb2-wysiwyg' ] ) && $debug; |
|
75 | + unset( $dependencies[ 'cmb2-wysiwyg' ] ); |
|
76 | 76 | |
77 | 77 | // Enqueue cmb JS |
78 | 78 | wp_enqueue_script( self::$handle, CMB2_Utils::url( "js/cmb2{$min}.js" ), $dependencies, CMB2_VERSION, true ); |
@@ -33,7 +33,7 @@ |
||
33 | 33 | 'data-objecttype' => $field->object_type, |
34 | 34 | ) ) |
35 | 35 | . '<p class="cmb-spinner spinner"></p>' |
36 | - . '<div id="'. $this->_id( '-status' ). '" class="cmb2-media-status ui-helper-clearfix embed_wrap">' . $oembed . '</div>'; |
|
36 | + . '<div id="' . $this->_id( '-status' ) . '" class="cmb2-media-status ui-helper-clearfix embed_wrap">' . $oembed . '</div>'; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | } |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function img_status_output( $args ) { |
57 | 57 | return sprintf( '<%1$s class="img-status cmb2-media-item">%2$s<p class="cmb2-remove-wrapper"><a href="#" class="cmb2-remove-file-button"%3$s>%4$s</a></p>%5$s</%1$s>', |
58 | - $args['tag'], |
|
59 | - $args['image'], |
|
60 | - isset( $args['cached_id'] ) ? ' rel="' . $args['cached_id'] . '"' : '', |
|
58 | + $args[ 'tag' ], |
|
59 | + $args[ 'image' ], |
|
60 | + isset( $args[ 'cached_id' ] ) ? ' rel="' . $args[ 'cached_id' ] . '"' : '', |
|
61 | 61 | esc_html( $this->_text( 'remove_image_text', esc_html__( 'Remove Image', 'cmb2' ) ) ), |
62 | - isset( $args['id_input'] ) ? $args['id_input'] : '' |
|
62 | + isset( $args[ 'id_input' ] ) ? $args[ 'id_input' ] : '' |
|
63 | 63 | ); |
64 | 64 | } |
65 | 65 | |
@@ -71,14 +71,14 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function file_status_output( $args ) { |
73 | 73 | return sprintf( '<%1$s class="file-status cmb2-media-item"><span>%2$s <strong>%3$s</strong></span> (<a href="%4$s" target="_blank" rel="external">%5$s</a> / <a href="#" class="cmb2-remove-file-button"%6$s>%7$s</a>)%8$s</%1$s>', |
74 | - $args['tag'], |
|
74 | + $args[ 'tag' ], |
|
75 | 75 | esc_html( $this->_text( 'file_text', esc_html__( 'File:', 'cmb2' ) ) ), |
76 | - CMB2_Utils::get_file_name_from_path( $args['value'] ), |
|
77 | - $args['value'], |
|
76 | + CMB2_Utils::get_file_name_from_path( $args[ 'value' ] ), |
|
77 | + $args[ 'value' ], |
|
78 | 78 | esc_html( $this->_text( 'file_download_text', esc_html__( 'Download', 'cmb2' ) ) ), |
79 | - isset( $args['cached_id'] ) ? ' rel="' . $args['cached_id'] . '"' : '', |
|
79 | + isset( $args[ 'cached_id' ] ) ? ' rel="' . $args[ 'cached_id' ] . '"' : '', |
|
80 | 80 | esc_html( $this->_text( 'remove_text', esc_html__( 'Remove', 'cmb2' ) ) ), |
81 | - isset( $args['id_input'] ) ? $args['id_input'] : '' |
|
81 | + isset( $args[ 'id_input' ] ) ? $args[ 'id_input' ] : '' |
|
82 | 82 | ); |
83 | 83 | } |
84 | 84 |
@@ -14,7 +14,7 @@ |
||
14 | 14 | |
15 | 15 | public function render() { |
16 | 16 | |
17 | - $this->field->args['default'] = $this->field->get_default() |
|
17 | + $this->field->args[ 'default' ] = $this->field->get_default() |
|
18 | 18 | ? $this->field->get_default() |
19 | 19 | : CMB2_Utils::timezone_string(); |
20 | 20 |
@@ -36,7 +36,7 @@ |
||
36 | 36 | ); |
37 | 37 | |
38 | 38 | if ( is_array( $saved_terms ) && in_array( $term->slug, $saved_terms ) ) { |
39 | - $args['checked'] = 'checked'; |
|
39 | + $args[ 'checked' ] = 'checked'; |
|
40 | 40 | } |
41 | 41 | $options .= $this->list_input( $args, $i ); |
42 | 42 | $i++; |