@@ -409,6 +409,7 @@ discard block |
||
| 409 | 409 | * Add a hidden field to the list of hidden fields to be rendered later |
| 410 | 410 | * @since 2.0.0 |
| 411 | 411 | * @param array $field_args Array of field arguments to be passed to CMB2_Field |
| 412 | + * @param CMB2_Field $field_group |
|
| 412 | 413 | */ |
| 413 | 414 | public function add_hidden_field( $field_args, $field_group = null ) { |
| 414 | 415 | if ( isset( $field_args['field_args'] ) ) { |
@@ -610,7 +611,7 @@ discard block |
||
| 610 | 611 | /** |
| 611 | 612 | * Save a repeatable group |
| 612 | 613 | * @since 1.x.x |
| 613 | - * @param array $field_group CMB2_Field group field object |
|
| 614 | + * @param CMB2_Field $field_group CMB2_Field group field object |
|
| 614 | 615 | * @return mixed Return of CMB2_Field::update_data() |
| 615 | 616 | */ |
| 616 | 617 | public function save_group_field( $field_group ) { |
@@ -910,7 +911,7 @@ discard block |
||
| 910 | 911 | * @param mixed $field_id Field (or group field) ID |
| 911 | 912 | * @param mixed $field_args Array of field arguments |
| 912 | 913 | * @param mixed $sub_field_id Sub field ID (if field_group exists) |
| 913 | - * @param mixed $field_group If a sub-field, will be the parent group CMB2_Field object |
|
| 914 | + * @param CMB2_Field|null $field_group If a sub-field, will be the parent group CMB2_Field object |
|
| 914 | 915 | * @return array Array of CMB2_Field arguments |
| 915 | 916 | */ |
| 916 | 917 | public function get_field_args( $field_id, $field_args, $sub_field_id, $field_group ) { |
@@ -997,7 +998,7 @@ discard block |
||
| 997 | 998 | * @since 2.0.0 |
| 998 | 999 | * @param array $field Metabox field config array |
| 999 | 1000 | * @param int $position (optional) Position of metabox. 1 for first, etc |
| 1000 | - * @return mixed Field id or false |
|
| 1001 | + * @return string Field id or false |
|
| 1001 | 1002 | */ |
| 1002 | 1003 | public function add_field( array $field, $position = 0 ) { |
| 1003 | 1004 | if ( ! is_array( $field ) || ! array_key_exists( 'id', $field ) ) { |
@@ -119,19 +119,19 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | public function __construct( $meta_box, $object_id = 0 ) { |
| 121 | 121 | |
| 122 | - if ( empty( $meta_box['id'] ) ) { |
|
| 122 | + if ( empty( $meta_box[ 'id' ] ) ) { |
|
| 123 | 123 | wp_die( __( 'Metabox configuration is required to have an ID parameter', 'cmb2' ) ); |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | $this->meta_box = wp_parse_args( $meta_box, $this->mb_defaults ); |
| 127 | - $this->meta_box['fields'] = array(); |
|
| 127 | + $this->meta_box[ 'fields' ] = array(); |
|
| 128 | 128 | |
| 129 | 129 | $this->object_id( $object_id ); |
| 130 | 130 | $this->mb_object_type(); |
| 131 | - $this->cmb_id = $meta_box['id']; |
|
| 131 | + $this->cmb_id = $meta_box[ 'id' ]; |
|
| 132 | 132 | |
| 133 | - if ( ! empty( $meta_box['fields'] ) && is_array( $meta_box['fields'] ) ) { |
|
| 134 | - $this->add_fields( $meta_box['fields'] ); |
|
| 133 | + if ( ! empty( $meta_box[ 'fields' ] ) && is_array( $meta_box[ 'fields' ] ) ) { |
|
| 134 | + $this->add_fields( $meta_box[ 'fields' ] ); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | CMB2_Boxes::add( $this ); |
@@ -262,22 +262,22 @@ discard block |
||
| 262 | 262 | * @return mixed CMB2_Field object if successful. |
| 263 | 263 | */ |
| 264 | 264 | public function render_field( $field_args ) { |
| 265 | - $field_args['context'] = $this->prop( 'context' ); |
|
| 265 | + $field_args[ 'context' ] = $this->prop( 'context' ); |
|
| 266 | 266 | |
| 267 | - if ( 'group' == $field_args['type'] ) { |
|
| 267 | + if ( 'group' == $field_args[ 'type' ] ) { |
|
| 268 | 268 | |
| 269 | - if ( ! isset( $field_args['show_names'] ) ) { |
|
| 270 | - $field_args['show_names'] = $this->prop( 'show_names' ); |
|
| 269 | + if ( ! isset( $field_args[ 'show_names' ] ) ) { |
|
| 270 | + $field_args[ 'show_names' ] = $this->prop( 'show_names' ); |
|
| 271 | 271 | } |
| 272 | 272 | $field = $this->render_group( $field_args ); |
| 273 | 273 | |
| 274 | - } elseif ( 'hidden' == $field_args['type'] && $this->get_field( $field_args )->should_show() ) { |
|
| 274 | + } elseif ( 'hidden' == $field_args[ 'type' ] && $this->get_field( $field_args )->should_show() ) { |
|
| 275 | 275 | // Save rendering for after the metabox |
| 276 | 276 | $field = $this->add_hidden_field( $field_args ); |
| 277 | 277 | |
| 278 | 278 | } else { |
| 279 | 279 | |
| 280 | - $field_args['show_names'] = $this->prop( 'show_names' ); |
|
| 280 | + $field_args[ 'show_names' ] = $this->prop( 'show_names' ); |
|
| 281 | 281 | |
| 282 | 282 | // Render default fields |
| 283 | 283 | $field = $this->get_field( $field_args )->render_field(); |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | */ |
| 294 | 294 | public function render_group( $args ) { |
| 295 | 295 | |
| 296 | - if ( ! isset( $args['id'], $args['fields'] ) || ! is_array( $args['fields'] ) ) { |
|
| 296 | + if ( ! isset( $args[ 'id' ], $args[ 'fields' ] ) || ! is_array( $args[ 'fields' ] ) ) { |
|
| 297 | 297 | return; |
| 298 | 298 | } |
| 299 | 299 | |
@@ -375,15 +375,15 @@ discard block |
||
| 375 | 375 | <div class="inside cmb-td cmb-nested cmb-field-list">'; |
| 376 | 376 | // Loop and render repeatable group fields |
| 377 | 377 | foreach ( array_values( $field_group->args( 'fields' ) ) as $field_args ) { |
| 378 | - if ( 'hidden' == $field_args['type'] ) { |
|
| 378 | + if ( 'hidden' == $field_args[ 'type' ] ) { |
|
| 379 | 379 | |
| 380 | 380 | // Save rendering for after the metabox |
| 381 | 381 | $this->add_hidden_field( $field_args, $field_group ); |
| 382 | 382 | |
| 383 | 383 | } else { |
| 384 | 384 | |
| 385 | - $field_args['show_names'] = $field_group->args( 'show_names' ); |
|
| 386 | - $field_args['context'] = $field_group->args( 'context' ); |
|
| 385 | + $field_args[ 'show_names' ] = $field_group->args( 'show_names' ); |
|
| 386 | + $field_args[ 'context' ] = $field_group->args( 'context' ); |
|
| 387 | 387 | |
| 388 | 388 | $field = $this->get_field( $field_args, $field_group )->render_field(); |
| 389 | 389 | } |
@@ -411,14 +411,14 @@ discard block |
||
| 411 | 411 | * @param array $field_args Array of field arguments to be passed to CMB2_Field |
| 412 | 412 | */ |
| 413 | 413 | public function add_hidden_field( $field_args, $field_group = null ) { |
| 414 | - if ( isset( $field_args['field_args'] ) ) { |
|
| 414 | + if ( isset( $field_args[ 'field_args' ] ) ) { |
|
| 415 | 415 | // For back-compatibility. |
| 416 | 416 | $field = new CMB2_Field( $field_args ); |
| 417 | 417 | } else { |
| 418 | 418 | $field = $this->get_new_field( $field_args, $field_group ); |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | - $this->hidden_fields[] = new CMB2_Types( $field ); |
|
| 421 | + $this->hidden_fields[ ] = new CMB2_Types( $field ); |
|
| 422 | 422 | |
| 423 | 423 | return $field; |
| 424 | 424 | } |
@@ -515,11 +515,11 @@ discard block |
||
| 515 | 515 | */ |
| 516 | 516 | public function process_field( $field_args ) { |
| 517 | 517 | |
| 518 | - switch ( $field_args['type'] ) { |
|
| 518 | + switch ( $field_args[ 'type' ] ) { |
|
| 519 | 519 | |
| 520 | 520 | case 'group': |
| 521 | 521 | if ( $this->save_group( $field_args ) ) { |
| 522 | - $this->updated[] = $field_args['id']; |
|
| 522 | + $this->updated[ ] = $field_args[ 'id' ]; |
|
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | break; |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | $field = $this->get_new_field( $field_args ); |
| 534 | 534 | |
| 535 | 535 | if ( $field->save_field_from_data( $this->data_to_save ) ) { |
| 536 | - $this->updated[] = $field->id(); |
|
| 536 | + $this->updated[ ] = $field->id(); |
|
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | break; |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | * @return mixed Return of CMB2_Field::update_data() |
| 601 | 601 | */ |
| 602 | 602 | public function save_group( $args ) { |
| 603 | - if ( ! isset( $args['id'], $args['fields'] ) || ! is_array( $args['fields'] ) ) { |
|
| 603 | + if ( ! isset( $args[ 'id' ], $args[ 'fields' ] ) || ! is_array( $args[ 'fields' ] ) ) { |
|
| 604 | 604 | return; |
| 605 | 605 | } |
| 606 | 606 | |
@@ -648,16 +648,16 @@ discard block |
||
| 648 | 648 | $_new_val = array(); |
| 649 | 649 | foreach ( $new_val as $group_index => $grouped_data ) { |
| 650 | 650 | // Add the supporting data to the $saved array stack |
| 651 | - $saved[ $field_group->index ][ $grouped_data['supporting_field_id'] ][] = $grouped_data['supporting_field_value']; |
|
| 651 | + $saved[ $field_group->index ][ $grouped_data[ 'supporting_field_id' ] ][ ] = $grouped_data[ 'supporting_field_value' ]; |
|
| 652 | 652 | // Reset var to the actual value |
| 653 | - $_new_val[ $group_index ] = $grouped_data['value']; |
|
| 653 | + $_new_val[ $group_index ] = $grouped_data[ 'value' ]; |
|
| 654 | 654 | } |
| 655 | 655 | $new_val = $_new_val; |
| 656 | 656 | } else { |
| 657 | 657 | // Add the supporting data to the $saved array stack |
| 658 | - $saved[ $field_group->index ][ $new_val['supporting_field_id'] ] = $new_val['supporting_field_value']; |
|
| 658 | + $saved[ $field_group->index ][ $new_val[ 'supporting_field_id' ] ] = $new_val[ 'supporting_field_value' ]; |
|
| 659 | 659 | // Reset var to the actual value |
| 660 | - $new_val = $new_val['value']; |
|
| 660 | + $new_val = $new_val[ 'value' ]; |
|
| 661 | 661 | } |
| 662 | 662 | } |
| 663 | 663 | |
@@ -670,7 +670,7 @@ discard block |
||
| 670 | 670 | $is_removed = ( empty( $new_val ) && ! empty( $old_val ) ); |
| 671 | 671 | // Compare values and add to `$updated` array |
| 672 | 672 | if ( $is_updated || $is_removed ) { |
| 673 | - $this->updated[] = $base_id . '::' . $field_group->index . '::' . $sub_id; |
|
| 673 | + $this->updated[ ] = $base_id . '::' . $field_group->index . '::' . $sub_id; |
|
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | // Add to `$saved` array |
@@ -705,22 +705,22 @@ discard block |
||
| 705 | 705 | // Try to get our object ID from the global space |
| 706 | 706 | switch ( $this->object_type() ) { |
| 707 | 707 | case 'user': |
| 708 | - $object_id = isset( $_REQUEST['user_id'] ) ? $_REQUEST['user_id'] : $object_id; |
|
| 709 | - $object_id = ! $object_id && 'user-new.php' != $pagenow && isset( $GLOBALS['user_ID'] ) ? $GLOBALS['user_ID'] : $object_id; |
|
| 708 | + $object_id = isset( $_REQUEST[ 'user_id' ] ) ? $_REQUEST[ 'user_id' ] : $object_id; |
|
| 709 | + $object_id = ! $object_id && 'user-new.php' != $pagenow && isset( $GLOBALS[ 'user_ID' ] ) ? $GLOBALS[ 'user_ID' ] : $object_id; |
|
| 710 | 710 | break; |
| 711 | 711 | |
| 712 | 712 | case 'comment': |
| 713 | - $object_id = isset( $_REQUEST['c'] ) ? $_REQUEST['c'] : $object_id; |
|
| 714 | - $object_id = ! $object_id && isset( $GLOBALS['comments']->comment_ID ) ? $GLOBALS['comments']->comment_ID : $object_id; |
|
| 713 | + $object_id = isset( $_REQUEST[ 'c' ] ) ? $_REQUEST[ 'c' ] : $object_id; |
|
| 714 | + $object_id = ! $object_id && isset( $GLOBALS[ 'comments' ]->comment_ID ) ? $GLOBALS[ 'comments' ]->comment_ID : $object_id; |
|
| 715 | 715 | break; |
| 716 | 716 | |
| 717 | 717 | case 'term': |
| 718 | - $object_id = isset( $_REQUEST['tag_ID'] ) ? $_REQUEST['tag_ID'] : $object_id; |
|
| 718 | + $object_id = isset( $_REQUEST[ 'tag_ID' ] ) ? $_REQUEST[ 'tag_ID' ] : $object_id; |
|
| 719 | 719 | break; |
| 720 | 720 | |
| 721 | 721 | default: |
| 722 | - $object_id = isset( $GLOBALS['post']->ID ) ? $GLOBALS['post']->ID : $object_id; |
|
| 723 | - $object_id = isset( $_REQUEST['post'] ) ? $_REQUEST['post'] : $object_id; |
|
| 722 | + $object_id = isset( $GLOBALS[ 'post' ]->ID ) ? $GLOBALS[ 'post' ]->ID : $object_id; |
|
| 723 | + $object_id = isset( $_REQUEST[ 'post' ] ) ? $_REQUEST[ 'post' ] : $object_id; |
|
| 724 | 724 | break; |
| 725 | 725 | } |
| 726 | 726 | |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | * @return boolean True/False |
| 797 | 797 | */ |
| 798 | 798 | public function is_options_page_mb() { |
| 799 | - 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'] ) ); |
|
| 799 | + 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' ] ) ); |
|
| 800 | 800 | } |
| 801 | 801 | |
| 802 | 802 | /** |
@@ -883,7 +883,7 @@ discard block |
||
| 883 | 883 | return $field; |
| 884 | 884 | } |
| 885 | 885 | |
| 886 | - $field_id = is_string( $field ) ? $field : $field['id']; |
|
| 886 | + $field_id = is_string( $field ) ? $field : $field[ 'id' ]; |
|
| 887 | 887 | |
| 888 | 888 | $parent_field_id = ! empty( $field_group ) ? $field_group->id() : ''; |
| 889 | 889 | $ids = $this->get_field_ids( $field_id, $parent_field_id, true ); |
@@ -919,16 +919,16 @@ discard block |
||
| 919 | 919 | if ( $field_group && ( $sub_field_id || 0 === $sub_field_id ) ) { |
| 920 | 920 | |
| 921 | 921 | // Update the fields array w/ any modified properties inherited from the group field |
| 922 | - $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] = $field_args; |
|
| 922 | + $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] = $field_args; |
|
| 923 | 923 | |
| 924 | 924 | return $this->get_default_args( $field_args, $field_group ); |
| 925 | 925 | } |
| 926 | 926 | |
| 927 | 927 | if ( is_array( $field_args ) ) { |
| 928 | - $this->meta_box['fields'][ $field_id ] = array_merge( $field_args, $this->meta_box['fields'][ $field_id ] ); |
|
| 928 | + $this->meta_box[ 'fields' ][ $field_id ] = array_merge( $field_args, $this->meta_box[ 'fields' ][ $field_id ] ); |
|
| 929 | 929 | } |
| 930 | 930 | |
| 931 | - return $this->get_default_args( $this->meta_box['fields'][ $field_id ] ); |
|
| 931 | + return $this->get_default_args( $this->meta_box[ 'fields' ][ $field_id ] ); |
|
| 932 | 932 | } |
| 933 | 933 | |
| 934 | 934 | /** |
@@ -978,8 +978,8 @@ discard block |
||
| 978 | 978 | |
| 979 | 979 | $sub_fields = false; |
| 980 | 980 | if ( array_key_exists( 'fields', $field ) ) { |
| 981 | - $sub_fields = $field['fields']; |
|
| 982 | - unset( $field['fields'] ); |
|
| 981 | + $sub_fields = $field[ 'fields' ]; |
|
| 982 | + unset( $field[ 'fields' ] ); |
|
| 983 | 983 | } |
| 984 | 984 | |
| 985 | 985 | $field_id = $parent_field_id |
@@ -1004,18 +1004,18 @@ discard block |
||
| 1004 | 1004 | return false; |
| 1005 | 1005 | } |
| 1006 | 1006 | |
| 1007 | - if ( 'oembed' === $field['type'] ) { |
|
| 1007 | + if ( 'oembed' === $field[ 'type' ] ) { |
|
| 1008 | 1008 | // Initiate oembed Ajax hooks |
| 1009 | 1009 | cmb2_ajax(); |
| 1010 | 1010 | } |
| 1011 | 1011 | |
| 1012 | 1012 | $this->_add_field_to_array( |
| 1013 | 1013 | $field, |
| 1014 | - $this->meta_box['fields'], |
|
| 1014 | + $this->meta_box[ 'fields' ], |
|
| 1015 | 1015 | $position |
| 1016 | 1016 | ); |
| 1017 | 1017 | |
| 1018 | - return $field['id']; |
|
| 1018 | + return $field[ 'id' ]; |
|
| 1019 | 1019 | } |
| 1020 | 1020 | |
| 1021 | 1021 | /** |
@@ -1027,27 +1027,27 @@ discard block |
||
| 1027 | 1027 | * @return mixed Array of parent/field ids or false |
| 1028 | 1028 | */ |
| 1029 | 1029 | public function add_group_field( $parent_field_id, array $field, $position = 0 ) { |
| 1030 | - if ( ! array_key_exists( $parent_field_id, $this->meta_box['fields'] ) ) { |
|
| 1030 | + if ( ! array_key_exists( $parent_field_id, $this->meta_box[ 'fields' ] ) ) { |
|
| 1031 | 1031 | return false; |
| 1032 | 1032 | } |
| 1033 | 1033 | |
| 1034 | - $parent_field = $this->meta_box['fields'][ $parent_field_id ]; |
|
| 1034 | + $parent_field = $this->meta_box[ 'fields' ][ $parent_field_id ]; |
|
| 1035 | 1035 | |
| 1036 | - if ( 'group' !== $parent_field['type'] ) { |
|
| 1036 | + if ( 'group' !== $parent_field[ 'type' ] ) { |
|
| 1037 | 1037 | return false; |
| 1038 | 1038 | } |
| 1039 | 1039 | |
| 1040 | - if ( ! isset( $parent_field['fields'] ) ) { |
|
| 1041 | - $this->meta_box['fields'][ $parent_field_id ]['fields'] = array(); |
|
| 1040 | + if ( ! isset( $parent_field[ 'fields' ] ) ) { |
|
| 1041 | + $this->meta_box[ 'fields' ][ $parent_field_id ][ 'fields' ] = array(); |
|
| 1042 | 1042 | } |
| 1043 | 1043 | |
| 1044 | 1044 | $this->_add_field_to_array( |
| 1045 | 1045 | $field, |
| 1046 | - $this->meta_box['fields'][ $parent_field_id ]['fields'], |
|
| 1046 | + $this->meta_box[ 'fields' ][ $parent_field_id ][ 'fields' ], |
|
| 1047 | 1047 | $position |
| 1048 | 1048 | ); |
| 1049 | 1049 | |
| 1050 | - return array( $parent_field_id, $field['id'] ); |
|
| 1050 | + return array( $parent_field_id, $field[ 'id' ] ); |
|
| 1051 | 1051 | } |
| 1052 | 1052 | |
| 1053 | 1053 | /** |
@@ -1059,9 +1059,9 @@ discard block |
||
| 1059 | 1059 | */ |
| 1060 | 1060 | protected function _add_field_to_array( $field, &$fields, $position = 0 ) { |
| 1061 | 1061 | if ( $position ) { |
| 1062 | - cmb2_utils()->array_insert( $fields, array( $field['id'] => $field ), $position ); |
|
| 1062 | + cmb2_utils()->array_insert( $fields, array( $field[ 'id' ] => $field ), $position ); |
|
| 1063 | 1063 | } else { |
| 1064 | - $fields[ $field['id'] ] = $field; |
|
| 1064 | + $fields[ $field[ 'id' ] ] = $field; |
|
| 1065 | 1065 | } |
| 1066 | 1066 | } |
| 1067 | 1067 | |
@@ -1084,15 +1084,15 @@ discard block |
||
| 1084 | 1084 | unset( $this->fields[ implode( '', $ids ) ] ); |
| 1085 | 1085 | |
| 1086 | 1086 | if ( ! $sub_field_id ) { |
| 1087 | - unset( $this->meta_box['fields'][ $field_id ] ); |
|
| 1087 | + unset( $this->meta_box[ 'fields' ][ $field_id ] ); |
|
| 1088 | 1088 | return true; |
| 1089 | 1089 | } |
| 1090 | 1090 | |
| 1091 | - if ( isset( $this->fields[ $field_id ]->args['fields'][ $sub_field_id ] ) ) { |
|
| 1092 | - unset( $this->fields[ $field_id ]->args['fields'][ $sub_field_id ] ); |
|
| 1091 | + if ( isset( $this->fields[ $field_id ]->args[ 'fields' ][ $sub_field_id ] ) ) { |
|
| 1092 | + unset( $this->fields[ $field_id ]->args[ 'fields' ][ $sub_field_id ] ); |
|
| 1093 | 1093 | } |
| 1094 | - if ( isset( $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] ) ) { |
|
| 1095 | - unset( $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ] ); |
|
| 1094 | + if ( isset( $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] ) ) { |
|
| 1095 | + unset( $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ] ); |
|
| 1096 | 1096 | } |
| 1097 | 1097 | return true; |
| 1098 | 1098 | } |
@@ -1116,11 +1116,11 @@ discard block |
||
| 1116 | 1116 | list( $field_id, $sub_field_id ) = $ids; |
| 1117 | 1117 | |
| 1118 | 1118 | if ( ! $sub_field_id ) { |
| 1119 | - $this->meta_box['fields'][ $field_id ][ $property ] = $value; |
|
| 1119 | + $this->meta_box[ 'fields' ][ $field_id ][ $property ] = $value; |
|
| 1120 | 1120 | return $field_id; |
| 1121 | 1121 | } |
| 1122 | 1122 | |
| 1123 | - $this->meta_box['fields'][ $field_id ]['fields'][ $sub_field_id ][ $property ] = $value; |
|
| 1123 | + $this->meta_box[ 'fields' ][ $field_id ][ 'fields' ][ $sub_field_id ][ $property ] = $value; |
|
| 1124 | 1124 | return $field_id; |
| 1125 | 1125 | } |
| 1126 | 1126 | |
@@ -1134,7 +1134,7 @@ discard block |
||
| 1134 | 1134 | public function get_field_ids( $field_id, $parent_field_id = '' ) { |
| 1135 | 1135 | $sub_field_id = $parent_field_id ? $field_id : ''; |
| 1136 | 1136 | $field_id = $parent_field_id ? $parent_field_id : $field_id; |
| 1137 | - $fields =& $this->meta_box['fields']; |
|
| 1137 | + $fields = & $this->meta_box[ 'fields' ]; |
|
| 1138 | 1138 | |
| 1139 | 1139 | if ( ! array_key_exists( $field_id, $fields ) ) { |
| 1140 | 1140 | $field_id = $this->search_old_school_array( $field_id, $fields ); |
@@ -1148,12 +1148,12 @@ discard block |
||
| 1148 | 1148 | return array( $field_id, $sub_field_id ); |
| 1149 | 1149 | } |
| 1150 | 1150 | |
| 1151 | - if ( 'group' !== $fields[ $field_id ]['type'] ) { |
|
| 1151 | + if ( 'group' !== $fields[ $field_id ][ 'type' ] ) { |
|
| 1152 | 1152 | return false; |
| 1153 | 1153 | } |
| 1154 | 1154 | |
| 1155 | - if ( ! array_key_exists( $sub_field_id, $fields[ $field_id ]['fields'] ) ) { |
|
| 1156 | - $sub_field_id = $this->search_old_school_array( $sub_field_id, $fields[ $field_id ]['fields'] ); |
|
| 1155 | + if ( ! array_key_exists( $sub_field_id, $fields[ $field_id ][ 'fields' ] ) ) { |
|
| 1156 | + $sub_field_id = $this->search_old_school_array( $sub_field_id, $fields[ $field_id ][ 'fields' ] ); |
|
| 1157 | 1157 | } |
| 1158 | 1158 | |
| 1159 | 1159 | return false === $sub_field_id ? false : array( $field_id, $sub_field_id ); |
@@ -735,7 +735,7 @@ discard block |
||
| 735 | 735 | * Return a formatted timestamp for a field |
| 736 | 736 | * @since 2.0.0 |
| 737 | 737 | * @param string $format Either date_format or time_format |
| 738 | - * @param string $meta_value Optional meta value to check |
|
| 738 | + * @param integer $meta_value Optional meta value to check |
|
| 739 | 739 | * @return string Formatted date |
| 740 | 740 | */ |
| 741 | 741 | public function get_timestamp_format( $format = 'date_format', $meta_value = 0 ) { |
@@ -1007,7 +1007,7 @@ discard block |
||
| 1007 | 1007 | * Retrieve options args. Calls options_cb if it exists. |
| 1008 | 1008 | * @since 2.0.0 |
| 1009 | 1009 | * @param string $key Specific option to retrieve |
| 1010 | - * @return array Array of options |
|
| 1010 | + * @return string Array of options |
|
| 1011 | 1011 | */ |
| 1012 | 1012 | public function options( $key = '' ) { |
| 1013 | 1013 | if ( ! empty( $this->field_options ) ) { |
@@ -107,21 +107,21 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | public function __construct( $args ) { |
| 109 | 109 | |
| 110 | - if ( ! empty( $args['group_field'] ) ) { |
|
| 111 | - $this->group = $args['group_field']; |
|
| 110 | + if ( ! empty( $args[ 'group_field' ] ) ) { |
|
| 111 | + $this->group = $args[ 'group_field' ]; |
|
| 112 | 112 | $this->object_id = $this->group->object_id; |
| 113 | 113 | $this->object_type = $this->group->object_type; |
| 114 | 114 | $this->cmb_id = $this->group->cmb_id; |
| 115 | 115 | } else { |
| 116 | - $this->object_id = isset( $args['object_id'] ) && '_' !== $args['object_id'] ? $args['object_id'] : 0; |
|
| 117 | - $this->object_type = isset( $args['object_type'] ) ? $args['object_type'] : 'post'; |
|
| 116 | + $this->object_id = isset( $args[ 'object_id' ] ) && '_' !== $args[ 'object_id' ] ? $args[ 'object_id' ] : 0; |
|
| 117 | + $this->object_type = isset( $args[ 'object_type' ] ) ? $args[ 'object_type' ] : 'post'; |
|
| 118 | 118 | |
| 119 | - if ( isset( $args['cmb_id'] ) ) { |
|
| 120 | - $this->cmb_id = $args['cmb_id']; |
|
| 119 | + if ( isset( $args[ 'cmb_id' ] ) ) { |
|
| 120 | + $this->cmb_id = $args[ 'cmb_id' ]; |
|
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - $this->args = $this->_set_field_defaults( $args['field_args'] ); |
|
| 124 | + $this->args = $this->_set_field_defaults( $args[ 'field_args' ] ); |
|
| 125 | 125 | |
| 126 | 126 | if ( $this->object_id ) { |
| 127 | 127 | $this->value = $this->get_data(); |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | * @return mixed Value of field argument |
| 137 | 137 | */ |
| 138 | 138 | public function __call( $name, $arguments ) { |
| 139 | - $key = isset( $arguments[0] ) ? $arguments[0] : false; |
|
| 139 | + $key = isset( $arguments[ 0 ] ) ? $arguments[ 0 ] : false; |
|
| 140 | 140 | return $this->args( $name, $key ); |
| 141 | 141 | } |
| 142 | 142 | |
@@ -207,9 +207,9 @@ discard block |
||
| 207 | 207 | */ |
| 208 | 208 | public function get_data( $field_id = '', $args = array() ) { |
| 209 | 209 | if ( $field_id ) { |
| 210 | - $args['field_id'] = $field_id; |
|
| 210 | + $args[ 'field_id' ] = $field_id; |
|
| 211 | 211 | } else if ( $this->group ) { |
| 212 | - $args['field_id'] = $this->group->id(); |
|
| 212 | + $args[ 'field_id' ] = $this->group->id(); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | $a = $this->data_args( $args ); |
@@ -250,13 +250,13 @@ discard block |
||
| 250 | 250 | * |
| 251 | 251 | * @since 2.0.0 |
| 252 | 252 | */ |
| 253 | - $data = apply_filters( "cmb2_override_{$a['field_id']}_meta_value", $data, $this->object_id, $a, $this ); |
|
| 253 | + $data = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_value", $data, $this->object_id, $a, $this ); |
|
| 254 | 254 | |
| 255 | 255 | // If no override, get value normally |
| 256 | 256 | if ( 'cmb2_field_no_override_val' === $data ) { |
| 257 | - $data = 'options-page' === $a['type'] |
|
| 258 | - ? cmb2_options( $a['id'] )->get( $a['field_id'] ) |
|
| 259 | - : get_metadata( $a['type'], $a['id'], $a['field_id'], ( $a['single'] || $a['repeat'] ) ); |
|
| 257 | + $data = 'options-page' === $a[ 'type' ] |
|
| 258 | + ? cmb2_options( $a[ 'id' ] )->get( $a[ 'field_id' ] ) |
|
| 259 | + : get_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], ( $a[ 'single' ] || $a[ 'repeat' ] ) ); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | if ( $this->group ) { |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | public function update_data( $new_value, $single = true ) { |
| 279 | 279 | $a = $this->data_args( array( 'single' => $single ) ); |
| 280 | 280 | |
| 281 | - $a['value'] = $a['repeat'] ? array_values( $new_value ) : $new_value; |
|
| 281 | + $a[ 'value' ] = $a[ 'repeat' ] ? array_values( $new_value ) : $new_value; |
|
| 282 | 282 | |
| 283 | 283 | /** |
| 284 | 284 | * Filter whether to override saving of meta value. |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | * |
| 315 | 315 | * @since 2.0.0 |
| 316 | 316 | */ |
| 317 | - $override = apply_filters( "cmb2_override_{$a['field_id']}_meta_save", $override, $a, $this->args(), $this ); |
|
| 317 | + $override = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_save", $override, $a, $this->args(), $this ); |
|
| 318 | 318 | |
| 319 | 319 | // If override, return that |
| 320 | 320 | if ( null !== $override ) { |
@@ -322,22 +322,22 @@ discard block |
||
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | // Options page handling (or temp data store) |
| 325 | - if ( 'options-page' === $a['type'] || empty( $a['id'] ) ) { |
|
| 326 | - return cmb2_options( $a['id'] )->update( $a['field_id'], $a['value'], false, $a['single'] ); |
|
| 325 | + if ( 'options-page' === $a[ 'type' ] || empty( $a[ 'id' ] ) ) { |
|
| 326 | + return cmb2_options( $a[ 'id' ] )->update( $a[ 'field_id' ], $a[ 'value' ], false, $a[ 'single' ] ); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | // Add metadata if not single |
| 330 | - if ( ! $a['single'] ) { |
|
| 331 | - return add_metadata( $a['type'], $a['id'], $a['field_id'], $a['value'], false ); |
|
| 330 | + if ( ! $a[ 'single' ] ) { |
|
| 331 | + return add_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $a[ 'value' ], false ); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | // Delete meta if we have an empty array |
| 335 | - if ( is_array( $a['value'] ) && empty( $a['value'] ) ) { |
|
| 336 | - return delete_metadata( $a['type'], $a['id'], $a['field_id'], $this->value ); |
|
| 335 | + if ( is_array( $a[ 'value' ] ) && empty( $a[ 'value' ] ) ) { |
|
| 336 | + return delete_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $this->value ); |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | // Update metadata |
| 340 | - return update_metadata( $a['type'], $a['id'], $a['field_id'], $a['value'] ); |
|
| 340 | + return update_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $a[ 'value' ] ); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | /** |
@@ -387,19 +387,19 @@ discard block |
||
| 387 | 387 | * @param array $field_args All field arguments |
| 388 | 388 | * @param CMB2_Field object $field This field object |
| 389 | 389 | */ |
| 390 | - $override = apply_filters( "cmb2_override_{$a['field_id']}_meta_remove", $override, $a, $this->args(), $this ); |
|
| 390 | + $override = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_remove", $override, $a, $this->args(), $this ); |
|
| 391 | 391 | |
| 392 | 392 | // If no override, remove as usual |
| 393 | 393 | if ( null !== $override ) { |
| 394 | 394 | return $override; |
| 395 | 395 | } |
| 396 | 396 | // Option page handling |
| 397 | - elseif ( 'options-page' === $a['type'] || empty( $a['id'] ) ) { |
|
| 398 | - return cmb2_options( $a['id'] )->remove( $a['field_id'] ); |
|
| 397 | + elseif ( 'options-page' === $a[ 'type' ] || empty( $a[ 'id' ] ) ) { |
|
| 398 | + return cmb2_options( $a[ 'id' ] )->remove( $a[ 'field_id' ] ); |
|
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | // Remove metadata |
| 402 | - return delete_metadata( $a['type'], $a['id'], $a['field_id'], $old ); |
|
| 402 | + return delete_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $old ); |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | /** |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | |
| 871 | 871 | foreach ( $conditional_classes as $class => $condition ) { |
| 872 | 872 | if ( $condition ) { |
| 873 | - $classes[] = $class; |
|
| 873 | + $classes[ ] = $class; |
|
| 874 | 874 | } |
| 875 | 875 | } |
| 876 | 876 | |
@@ -879,7 +879,7 @@ discard block |
||
| 879 | 879 | } |
| 880 | 880 | |
| 881 | 881 | if ( $added_classes ) { |
| 882 | - $classes[] = esc_attr( $added_classes ); |
|
| 882 | + $classes[ ] = esc_attr( $added_classes ); |
|
| 883 | 883 | } |
| 884 | 884 | |
| 885 | 885 | /** |
@@ -981,10 +981,10 @@ discard block |
||
| 981 | 981 | public function string( $text_key, $fallback ) { |
| 982 | 982 | // If null, populate with our field strings values. |
| 983 | 983 | if ( null === $this->strings ) { |
| 984 | - $this->strings = (array) $this->args['text']; |
|
| 984 | + $this->strings = (array) $this->args[ 'text' ]; |
|
| 985 | 985 | |
| 986 | - if ( is_callable( $this->args['text_cb'] ) ) { |
|
| 987 | - $strings = call_user_func( $this->args['text_cb'], $this ); |
|
| 986 | + if ( is_callable( $this->args[ 'text_cb' ] ) ) { |
|
| 987 | + $strings = call_user_func( $this->args[ 'text_cb' ], $this ); |
|
| 988 | 988 | |
| 989 | 989 | if ( $strings && is_array( $strings ) ) { |
| 990 | 990 | $this->strings += $strings; |
@@ -1018,10 +1018,10 @@ discard block |
||
| 1018 | 1018 | return $this->field_options; |
| 1019 | 1019 | } |
| 1020 | 1020 | |
| 1021 | - $this->field_options = (array) $this->args['options']; |
|
| 1021 | + $this->field_options = (array) $this->args[ 'options' ]; |
|
| 1022 | 1022 | |
| 1023 | - if ( is_callable( $this->args['options_cb'] ) ) { |
|
| 1024 | - $options = call_user_func( $this->args['options_cb'], $this ); |
|
| 1023 | + if ( is_callable( $this->args[ 'options_cb' ] ) ) { |
|
| 1024 | + $options = call_user_func( $this->args[ 'options_cb' ], $this ); |
|
| 1025 | 1025 | |
| 1026 | 1026 | if ( $options && is_array( $options ) ) { |
| 1027 | 1027 | $this->field_options += $options; |
@@ -1043,17 +1043,17 @@ discard block |
||
| 1043 | 1043 | * @return mixed Default field value |
| 1044 | 1044 | */ |
| 1045 | 1045 | public function get_default() { |
| 1046 | - if ( null !== $this->args['default'] ) { |
|
| 1047 | - return $this->args['default']; |
|
| 1046 | + if ( null !== $this->args[ 'default' ] ) { |
|
| 1047 | + return $this->args[ 'default' ]; |
|
| 1048 | 1048 | } |
| 1049 | 1049 | |
| 1050 | - $param = is_callable( $this->args['default_cb'] ) ? 'default_cb' : 'default'; |
|
| 1050 | + $param = is_callable( $this->args[ 'default_cb' ] ) ? 'default_cb' : 'default'; |
|
| 1051 | 1051 | $default = $this->get_param_callback_result( $param, false ); |
| 1052 | 1052 | |
| 1053 | 1053 | // Allow a filter override of the default value |
| 1054 | - $this->args['default'] = apply_filters( 'cmb2_default_filter', $default, $this ); |
|
| 1054 | + $this->args[ 'default' ] = apply_filters( 'cmb2_default_filter', $default, $this ); |
|
| 1055 | 1055 | |
| 1056 | - return $this->args['default']; |
|
| 1056 | + return $this->args[ 'default' ]; |
|
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | 1059 | /** |
@@ -1080,68 +1080,68 @@ discard block |
||
| 1080 | 1080 | 'default_cb' => '', |
| 1081 | 1081 | 'select_all_button' => true, |
| 1082 | 1082 | 'multiple' => false, |
| 1083 | - 'repeatable' => isset( $args['type'] ) && 'group' == $args['type'], |
|
| 1083 | + 'repeatable' => isset( $args[ 'type' ] ) && 'group' == $args[ 'type' ], |
|
| 1084 | 1084 | 'inline' => false, |
| 1085 | 1085 | 'on_front' => true, |
| 1086 | 1086 | 'show_names' => true, |
| 1087 | 1087 | 'date_format' => 'm\/d\/Y', |
| 1088 | 1088 | 'time_format' => 'h:i A', |
| 1089 | - 'description' => isset( $args['desc'] ) ? $args['desc'] : '', |
|
| 1090 | - 'preview_size' => 'file' == $args['type'] ? array( 350, 350 ) : array( 50, 50 ), |
|
| 1089 | + 'description' => isset( $args[ 'desc' ] ) ? $args[ 'desc' ] : '', |
|
| 1090 | + 'preview_size' => 'file' == $args[ 'type' ] ? array( 350, 350 ) : array( 50, 50 ), |
|
| 1091 | 1091 | 'render_row_cb' => array( $this, 'render_field_callback' ), |
| 1092 | - 'label_cb' => 'title' != $args['type'] ? array( $this, 'label' ) : '', |
|
| 1092 | + 'label_cb' => 'title' != $args[ 'type' ] ? array( $this, 'label' ) : '', |
|
| 1093 | 1093 | ) ); |
| 1094 | 1094 | |
| 1095 | 1095 | // default param can be passed a callback as well |
| 1096 | - if ( is_callable( $args['default'] ) ) { |
|
| 1097 | - $args['default_cb'] = $args['default']; |
|
| 1098 | - $args['default'] = null; |
|
| 1096 | + if ( is_callable( $args[ 'default' ] ) ) { |
|
| 1097 | + $args[ 'default_cb' ] = $args[ 'default' ]; |
|
| 1098 | + $args[ 'default' ] = null; |
|
| 1099 | 1099 | } |
| 1100 | 1100 | |
| 1101 | - $args['repeatable'] = $args['repeatable'] && ! $this->repeatable_exception( $args['type'] ); |
|
| 1102 | - $args['inline'] = $args['inline'] || false !== stripos( $args['type'], '_inline' ); |
|
| 1101 | + $args[ 'repeatable' ] = $args[ 'repeatable' ] && ! $this->repeatable_exception( $args[ 'type' ] ); |
|
| 1102 | + $args[ 'inline' ] = $args[ 'inline' ] || false !== stripos( $args[ 'type' ], '_inline' ); |
|
| 1103 | 1103 | |
| 1104 | 1104 | // options param can be passed a callback as well |
| 1105 | - if ( is_callable( $args['options'] ) ) { |
|
| 1106 | - $args['options_cb'] = $args['options']; |
|
| 1107 | - $args['options'] = array(); |
|
| 1105 | + if ( is_callable( $args[ 'options' ] ) ) { |
|
| 1106 | + $args[ 'options_cb' ] = $args[ 'options' ]; |
|
| 1107 | + $args[ 'options' ] = array(); |
|
| 1108 | 1108 | } |
| 1109 | 1109 | |
| 1110 | - $args['options'] = 'group' == $args['type'] ? wp_parse_args( $args['options'], array( |
|
| 1110 | + $args[ 'options' ] = 'group' == $args[ 'type' ] ? wp_parse_args( $args[ 'options' ], array( |
|
| 1111 | 1111 | 'add_button' => __( 'Add Group', 'cmb2' ), |
| 1112 | 1112 | 'remove_button' => __( 'Remove Group', 'cmb2' ), |
| 1113 | - ) ) : $args['options']; |
|
| 1113 | + ) ) : $args[ 'options' ]; |
|
| 1114 | 1114 | |
| 1115 | - $args['_id'] = $args['id']; |
|
| 1116 | - $args['_name'] = $args['id']; |
|
| 1115 | + $args[ '_id' ] = $args[ 'id' ]; |
|
| 1116 | + $args[ '_name' ] = $args[ 'id' ]; |
|
| 1117 | 1117 | |
| 1118 | 1118 | if ( $this->group ) { |
| 1119 | 1119 | |
| 1120 | - $args['id'] = $this->group->args( 'id' ) . '_' . $this->group->index . '_' . $args['id']; |
|
| 1121 | - $args['_name'] = $this->group->args( 'id' ) . '[' . $this->group->index . '][' . $args['_name'] . ']'; |
|
| 1120 | + $args[ 'id' ] = $this->group->args( 'id' ) . '_' . $this->group->index . '_' . $args[ 'id' ]; |
|
| 1121 | + $args[ '_name' ] = $this->group->args( 'id' ) . '[' . $this->group->index . '][' . $args[ '_name' ] . ']'; |
|
| 1122 | 1122 | } |
| 1123 | 1123 | |
| 1124 | - if ( 'wysiwyg' == $args['type'] ) { |
|
| 1125 | - $args['id'] = strtolower( str_ireplace( '-', '_', $args['id'] ) ); |
|
| 1126 | - $args['options']['textarea_name'] = $args['_name']; |
|
| 1124 | + if ( 'wysiwyg' == $args[ 'type' ] ) { |
|
| 1125 | + $args[ 'id' ] = strtolower( str_ireplace( '-', '_', $args[ 'id' ] ) ); |
|
| 1126 | + $args[ 'options' ][ 'textarea_name' ] = $args[ '_name' ]; |
|
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 1129 | 1129 | $option_types = apply_filters( 'cmb2_all_or_nothing_types', array( 'select', 'radio', 'radio_inline', 'taxonomy_select', 'taxonomy_radio', 'taxonomy_radio_inline' ), $this ); |
| 1130 | 1130 | |
| 1131 | - if ( in_array( $args['type'], $option_types, true ) ) { |
|
| 1131 | + if ( in_array( $args[ 'type' ], $option_types, true ) ) { |
|
| 1132 | 1132 | |
| 1133 | - $args['show_option_none'] = isset( $args['show_option_none'] ) ? $args['show_option_none'] : null; |
|
| 1134 | - $args['show_option_none'] = true === $args['show_option_none'] ? __( 'None', 'cmb2' ) : $args['show_option_none']; |
|
| 1133 | + $args[ 'show_option_none' ] = isset( $args[ 'show_option_none' ] ) ? $args[ 'show_option_none' ] : null; |
|
| 1134 | + $args[ 'show_option_none' ] = true === $args[ 'show_option_none' ] ? __( 'None', 'cmb2' ) : $args[ 'show_option_none' ]; |
|
| 1135 | 1135 | |
| 1136 | - if ( null === $args['show_option_none'] ) { |
|
| 1137 | - $off_by_default = in_array( $args['type'], array( 'select', 'radio', 'radio_inline' ), true ); |
|
| 1138 | - $args['show_option_none'] = $off_by_default ? false : __( 'None', 'cmb2' ); |
|
| 1136 | + if ( null === $args[ 'show_option_none' ] ) { |
|
| 1137 | + $off_by_default = in_array( $args[ 'type' ], array( 'select', 'radio', 'radio_inline' ), true ); |
|
| 1138 | + $args[ 'show_option_none' ] = $off_by_default ? false : __( 'None', 'cmb2' ); |
|
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | 1141 | } |
| 1142 | 1142 | |
| 1143 | - $args['has_supporting_data'] = in_array( |
|
| 1144 | - $args['type'], |
|
| 1143 | + $args[ 'has_supporting_data' ] = in_array( |
|
| 1144 | + $args[ 'type' ], |
|
| 1145 | 1145 | array( |
| 1146 | 1146 | // CMB2_Sanitize::_save_file_id_value()/CMB2_Sanitize::_get_group_file_value_array() |
| 1147 | 1147 | 'file', |
@@ -1173,10 +1173,10 @@ discard block |
||
| 1173 | 1173 | 'cmb_id' => $this->cmb_id, |
| 1174 | 1174 | ); |
| 1175 | 1175 | |
| 1176 | - if ( isset( $field_args['field_args'] ) ) { |
|
| 1176 | + if ( isset( $field_args[ 'field_args' ] ) ) { |
|
| 1177 | 1177 | $args = wp_parse_args( $field_args, $args ); |
| 1178 | 1178 | } else { |
| 1179 | - $args['field_args'] = wp_parse_args( $field_args, $this->args ); |
|
| 1179 | + $args[ 'field_args' ] = wp_parse_args( $field_args, $this->args ); |
|
| 1180 | 1180 | } |
| 1181 | 1181 | |
| 1182 | 1182 | return new CMB2_Field( $args ); |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | $dir = wp_upload_dir(); |
| 31 | 31 | |
| 32 | 32 | // Is URL in uploads directory? |
| 33 | - if ( false === strpos( $img_url, $dir['baseurl'] . '/' ) ) { |
|
| 33 | + if ( false === strpos( $img_url, $dir[ 'baseurl' ] . '/' ) ) { |
|
| 34 | 34 | return false; |
| 35 | 35 | } |
| 36 | 36 | |
@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | foreach ( $query->posts as $post_id ) { |
| 57 | 57 | $meta = wp_get_attachment_metadata( $post_id ); |
| 58 | - $original_file = basename( $meta['file'] ); |
|
| 59 | - $cropped_image_files = isset( $meta['sizes'] ) ? wp_list_pluck( $meta['sizes'], 'file' ) : array(); |
|
| 58 | + $original_file = basename( $meta[ 'file' ] ); |
|
| 59 | + $cropped_image_files = isset( $meta[ 'sizes' ] ) ? wp_list_pluck( $meta[ 'sizes' ], 'file' ) : array(); |
|
| 60 | 60 | if ( $original_file === $file || in_array( $file, $cropped_image_files ) ) { |
| 61 | 61 | $attachment_id = $post_id; |
| 62 | 62 | break; |
@@ -140,8 +140,7 @@ discard block |
||
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | return $this->is_valid_time_stamp( $string ) |
| 143 | - ? (int) $string : |
|
| 144 | - strtotime( (string) $string ); |
|
| 143 | + ? (int) $string : strtotime( (string) $string ); |
|
| 145 | 144 | } |
| 146 | 145 | |
| 147 | 146 | /** |
@@ -172,7 +171,7 @@ discard block |
||
| 172 | 171 | * @param mixed $value Value to check |
| 173 | 172 | * @return bool True or false |
| 174 | 173 | */ |
| 175 | - public function notempty( $value ){ |
|
| 174 | + public function notempty( $value ) { |
|
| 176 | 175 | return null !== $value && '' !== $value && false !== $value; |
| 177 | 176 | } |
| 178 | 177 | |
@@ -322,24 +321,24 @@ discard block |
||
| 322 | 321 | |
| 323 | 322 | // order is relevant here, since the replacement will be done sequentially. |
| 324 | 323 | $supported_options = array( |
| 325 | - 'd' => 'dd', // Day, leading 0 |
|
| 326 | - 'j' => 'd', // Day, no 0 |
|
| 327 | - 'z' => 'o', // Day of the year, no leading zeroes, |
|
| 324 | + 'd' => 'dd', // Day, leading 0 |
|
| 325 | + 'j' => 'd', // Day, no 0 |
|
| 326 | + 'z' => 'o', // Day of the year, no leading zeroes, |
|
| 328 | 327 | // 'D' => 'D', // Day name short, not sure how it'll work with translations |
| 329 | 328 | // 'l' => 'DD', // Day name full, idem before |
| 330 | - 'm' => 'mm', // Month of the year, leading 0 |
|
| 331 | - 'n' => 'm', // Month of the year, no leading 0 |
|
| 329 | + 'm' => 'mm', // Month of the year, leading 0 |
|
| 330 | + 'n' => 'm', // Month of the year, no leading 0 |
|
| 332 | 331 | // 'M' => 'M', // Month, Short name |
| 333 | 332 | // 'F' => 'MM', // Month, full name, |
| 334 | - 'y' => 'y', // Year, two digit |
|
| 335 | - 'Y' => 'yy', // Year, full |
|
| 336 | - 'H' => 'HH', // Hour with leading 0 (24 hour) |
|
| 337 | - 'G' => 'H', // Hour with no leading 0 (24 hour) |
|
| 338 | - 'h' => 'hh', // Hour with leading 0 (12 hour) |
|
| 339 | - 'g' => 'h', // Hour with no leading 0 (12 hour), |
|
| 340 | - 'i' => 'mm', // Minute with leading 0, |
|
| 341 | - 's' => 'ss', // Second with leading 0, |
|
| 342 | - 'a' => 'tt', // am/pm |
|
| 333 | + 'y' => 'y', // Year, two digit |
|
| 334 | + 'Y' => 'yy', // Year, full |
|
| 335 | + 'H' => 'HH', // Hour with leading 0 (24 hour) |
|
| 336 | + 'G' => 'H', // Hour with no leading 0 (24 hour) |
|
| 337 | + 'h' => 'hh', // Hour with leading 0 (12 hour) |
|
| 338 | + 'g' => 'h', // Hour with no leading 0 (12 hour), |
|
| 339 | + 'i' => 'mm', // Minute with leading 0, |
|
| 340 | + 's' => 'ss', // Second with leading 0, |
|
| 341 | + 'a' => 'tt', // am/pm |
|
| 343 | 342 | 'A' => 'TT' // AM/PM |
| 344 | 343 | ); |
| 345 | 344 | |
@@ -360,7 +359,7 @@ discard block |
||
| 360 | 359 | * @return string Modified value |
| 361 | 360 | */ |
| 362 | 361 | public function wrap_escaped_chars( $value ) { |
| 363 | - return "'" . str_replace( '\\', '', $value[0] ) . "'"; |
|
| 362 | + return "'" . str_replace( '\\', '', $value[ 0 ] ) . "'"; |
|
| 364 | 363 | } |
| 365 | 364 | |
| 366 | 365 | /** |
@@ -115,7 +115,8 @@ discard block |
||
| 115 | 115 | $tzstring = ''; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists |
|
| 118 | + if ( empty( $tzstring ) ) { |
|
| 119 | +// Create a UTC+- zone if no timezone string exists |
|
| 119 | 120 | if ( 0 == $current_offset ) { |
| 120 | 121 | $tzstring = 'UTC+0'; |
| 121 | 122 | } elseif ( $current_offset < 0 ) { |
@@ -172,7 +173,7 @@ discard block |
||
| 172 | 173 | * @param mixed $value Value to check |
| 173 | 174 | * @return bool True or false |
| 174 | 175 | */ |
| 175 | - public function notempty( $value ){ |
|
| 176 | + public function notempty( $value ) { |
|
| 176 | 177 | return null !== $value && '' !== $value && false !== $value; |
| 177 | 178 | } |
| 178 | 179 | |