@@ -171,7 +171,7 @@ |
||
| 171 | 171 | * |
| 172 | 172 | * @since 2.0.0 |
| 173 | 173 | * @param string $property Metabox config property to retrieve |
| 174 | - * @param mixed $fallback Fallback value to set if no value found |
|
| 174 | + * @param boolean|null $fallback Fallback value to set if no value found |
|
| 175 | 175 | * @return mixed Metabox config property value or false |
| 176 | 176 | */ |
| 177 | 177 | public function prop( $property, $fallback = null ) { |
@@ -403,11 +403,11 @@ |
||
| 403 | 403 | switch ( $message ) { |
| 404 | 404 | |
| 405 | 405 | case self::DEPRECATED_PARAM: |
| 406 | - $message = sprintf( __( 'The "%1$s" field parameter has been deprecated in favor of the "%1$s" parameter.', 'cmb2' ), $args[3], $args[4] ); |
|
| 406 | + $message = sprintf( __( 'The "%1$s" field parameter has been deprecated in favor of the "%1$s" parameter.', 'cmb2' ), $args[ 3 ], $args[ 4 ] ); |
|
| 407 | 407 | break; |
| 408 | 408 | |
| 409 | 409 | case self::DEPRECATED_CB_PARAM: |
| 410 | - $message = sprintf( __( 'Using the "%1$s" field parameter as a callback has been deprecated in favor of the "%1$s" parameter.', 'cmb2' ), $args[3], $args[4] ); |
|
| 410 | + $message = sprintf( __( 'Using the "%1$s" field parameter as a callback has been deprecated in favor of the "%1$s" parameter.', 'cmb2' ), $args[ 3 ], $args[ 4 ] ); |
|
| 411 | 411 | break; |
| 412 | 412 | |
| 413 | 413 | default: |
@@ -751,7 +751,7 @@ discard block |
||
| 751 | 751 | * |
| 752 | 752 | * @since 2.0.0 |
| 753 | 753 | * @param string $format Either date_format or time_format |
| 754 | - * @param string $meta_value Optional meta value to check |
|
| 754 | + * @param integer $meta_value Optional meta value to check |
|
| 755 | 755 | * @return string Formatted date |
| 756 | 756 | */ |
| 757 | 757 | public function get_timestamp_format( $format = 'date_format', $meta_value = 0 ) { |
@@ -1032,7 +1032,7 @@ discard block |
||
| 1032 | 1032 | * |
| 1033 | 1033 | * @since 2.0.0 |
| 1034 | 1034 | * @param string $key Specific option to retrieve |
| 1035 | - * @return array Array of options |
|
| 1035 | + * @return string Array of options |
|
| 1036 | 1036 | */ |
| 1037 | 1037 | public function options( $key = '' ) { |
| 1038 | 1038 | if ( ! empty( $this->field_options ) ) { |
@@ -122,21 +122,21 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | public function __construct( $args ) { |
| 124 | 124 | |
| 125 | - if ( ! empty( $args['group_field'] ) ) { |
|
| 126 | - $this->group = $args['group_field']; |
|
| 125 | + if ( ! empty( $args[ 'group_field' ] ) ) { |
|
| 126 | + $this->group = $args[ 'group_field' ]; |
|
| 127 | 127 | $this->object_id = $this->group->object_id; |
| 128 | 128 | $this->object_type = $this->group->object_type; |
| 129 | 129 | $this->cmb_id = $this->group->cmb_id; |
| 130 | 130 | } else { |
| 131 | - $this->object_id = isset( $args['object_id'] ) && '_' !== $args['object_id'] ? $args['object_id'] : 0; |
|
| 132 | - $this->object_type = isset( $args['object_type'] ) ? $args['object_type'] : 'post'; |
|
| 131 | + $this->object_id = isset( $args[ 'object_id' ] ) && '_' !== $args[ 'object_id' ] ? $args[ 'object_id' ] : 0; |
|
| 132 | + $this->object_type = isset( $args[ 'object_type' ] ) ? $args[ 'object_type' ] : 'post'; |
|
| 133 | 133 | |
| 134 | - if ( isset( $args['cmb_id'] ) ) { |
|
| 135 | - $this->cmb_id = $args['cmb_id']; |
|
| 134 | + if ( isset( $args[ 'cmb_id' ] ) ) { |
|
| 135 | + $this->cmb_id = $args[ 'cmb_id' ]; |
|
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - $this->args = $this->_set_field_defaults( $args['field_args'], $args ); |
|
| 139 | + $this->args = $this->_set_field_defaults( $args[ 'field_args' ], $args ); |
|
| 140 | 140 | |
| 141 | 141 | if ( $this->object_id ) { |
| 142 | 142 | $this->value = $this->get_data(); |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | return call_user_func_array( array( $this, 'get_string' ), $arguments ); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - $key = isset( $arguments[0] ) ? $arguments[0] : false; |
|
| 159 | + $key = isset( $arguments[ 0 ] ) ? $arguments[ 0 ] : false; |
|
| 160 | 160 | return $this->args( $name, $key ); |
| 161 | 161 | } |
| 162 | 162 | |
@@ -232,9 +232,9 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | public function get_data( $field_id = '', $args = array() ) { |
| 234 | 234 | if ( $field_id ) { |
| 235 | - $args['field_id'] = $field_id; |
|
| 235 | + $args[ 'field_id' ] = $field_id; |
|
| 236 | 236 | } elseif ( $this->group ) { |
| 237 | - $args['field_id'] = $this->group->id(); |
|
| 237 | + $args[ 'field_id' ] = $this->group->id(); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | $a = $this->data_args( $args ); |
@@ -275,13 +275,13 @@ discard block |
||
| 275 | 275 | * |
| 276 | 276 | * @since 2.0.0 |
| 277 | 277 | */ |
| 278 | - $data = apply_filters( "cmb2_override_{$a['field_id']}_meta_value", $data, $this->object_id, $a, $this ); |
|
| 278 | + $data = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_value", $data, $this->object_id, $a, $this ); |
|
| 279 | 279 | |
| 280 | 280 | // If no override, get value normally |
| 281 | 281 | if ( 'cmb2_field_no_override_val' === $data ) { |
| 282 | - $data = 'options-page' === $a['type'] |
|
| 283 | - ? cmb2_options( $a['id'] )->get( $a['field_id'] ) |
|
| 284 | - : get_metadata( $a['type'], $a['id'], $a['field_id'], ( $a['single'] || $a['repeat'] ) ); |
|
| 282 | + $data = 'options-page' === $a[ 'type' ] |
|
| 283 | + ? cmb2_options( $a[ 'id' ] )->get( $a[ 'field_id' ] ) |
|
| 284 | + : get_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], ( $a[ 'single' ] || $a[ 'repeat' ] ) ); |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | if ( $this->group ) { |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | public function update_data( $new_value, $single = true ) { |
| 305 | 305 | $a = $this->data_args( array( 'single' => $single ) ); |
| 306 | 306 | |
| 307 | - $a['value'] = $a['repeat'] ? array_values( $new_value ) : $new_value; |
|
| 307 | + $a[ 'value' ] = $a[ 'repeat' ] ? array_values( $new_value ) : $new_value; |
|
| 308 | 308 | |
| 309 | 309 | /** |
| 310 | 310 | * Filter whether to override saving of meta value. |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | * |
| 341 | 341 | * @since 2.0.0 |
| 342 | 342 | */ |
| 343 | - $override = apply_filters( "cmb2_override_{$a['field_id']}_meta_save", $override, $a, $this->args(), $this ); |
|
| 343 | + $override = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_save", $override, $a, $this->args(), $this ); |
|
| 344 | 344 | |
| 345 | 345 | // If override, return that |
| 346 | 346 | if ( null !== $override ) { |
@@ -348,22 +348,22 @@ discard block |
||
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | // Options page handling (or temp data store) |
| 351 | - if ( 'options-page' === $a['type'] || empty( $a['id'] ) ) { |
|
| 352 | - return cmb2_options( $a['id'] )->update( $a['field_id'], $a['value'], false, $a['single'] ); |
|
| 351 | + if ( 'options-page' === $a[ 'type' ] || empty( $a[ 'id' ] ) ) { |
|
| 352 | + return cmb2_options( $a[ 'id' ] )->update( $a[ 'field_id' ], $a[ 'value' ], false, $a[ 'single' ] ); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | // Add metadata if not single |
| 356 | - if ( ! $a['single'] ) { |
|
| 357 | - return add_metadata( $a['type'], $a['id'], $a['field_id'], $a['value'], false ); |
|
| 356 | + if ( ! $a[ 'single' ] ) { |
|
| 357 | + return add_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $a[ 'value' ], false ); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | // Delete meta if we have an empty array |
| 361 | - if ( is_array( $a['value'] ) && empty( $a['value'] ) ) { |
|
| 362 | - return delete_metadata( $a['type'], $a['id'], $a['field_id'], $this->value ); |
|
| 361 | + if ( is_array( $a[ 'value' ] ) && empty( $a[ 'value' ] ) ) { |
|
| 362 | + return delete_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $this->value ); |
|
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | // Update metadata |
| 366 | - return update_metadata( $a['type'], $a['id'], $a['field_id'], $a['value'] ); |
|
| 366 | + return update_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $a[ 'value' ] ); |
|
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | /** |
@@ -414,18 +414,18 @@ discard block |
||
| 414 | 414 | * @param array $field_args All field arguments |
| 415 | 415 | * @param CMB2_Field object $field This field object |
| 416 | 416 | */ |
| 417 | - $override = apply_filters( "cmb2_override_{$a['field_id']}_meta_remove", $override, $a, $this->args(), $this ); |
|
| 417 | + $override = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_remove", $override, $a, $this->args(), $this ); |
|
| 418 | 418 | |
| 419 | 419 | // If no override, remove as usual |
| 420 | 420 | if ( null !== $override ) { |
| 421 | 421 | return $override; |
| 422 | 422 | } // Option page handling |
| 423 | - elseif ( 'options-page' === $a['type'] || empty( $a['id'] ) ) { |
|
| 424 | - return cmb2_options( $a['id'] )->remove( $a['field_id'] ); |
|
| 423 | + elseif ( 'options-page' === $a[ 'type' ] || empty( $a[ 'id' ] ) ) { |
|
| 424 | + return cmb2_options( $a[ 'id' ] )->remove( $a[ 'field_id' ] ); |
|
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | // Remove metadata |
| 428 | - return delete_metadata( $a['type'], $a['id'], $a['field_id'], $old ); |
|
| 428 | + return delete_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $old ); |
|
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | /** |
@@ -891,7 +891,7 @@ discard block |
||
| 891 | 891 | |
| 892 | 892 | foreach ( $conditional_classes as $class => $condition ) { |
| 893 | 893 | if ( $condition ) { |
| 894 | - $classes[] = $class; |
|
| 894 | + $classes[ ] = $class; |
|
| 895 | 895 | } |
| 896 | 896 | } |
| 897 | 897 | |
@@ -902,7 +902,7 @@ discard block |
||
| 902 | 902 | } |
| 903 | 903 | |
| 904 | 904 | if ( $added_classes ) { |
| 905 | - $classes[] = esc_attr( $added_classes ); |
|
| 905 | + $classes[ ] = esc_attr( $added_classes ); |
|
| 906 | 906 | } |
| 907 | 907 | |
| 908 | 908 | /** |
@@ -1005,10 +1005,10 @@ discard block |
||
| 1005 | 1005 | public function get_string( $text_key, $fallback ) { |
| 1006 | 1006 | // If null, populate with our field strings values. |
| 1007 | 1007 | if ( null === $this->strings ) { |
| 1008 | - $this->strings = (array) $this->args['text']; |
|
| 1008 | + $this->strings = (array) $this->args[ 'text' ]; |
|
| 1009 | 1009 | |
| 1010 | - if ( is_callable( $this->args['text_cb'] ) ) { |
|
| 1011 | - $strings = call_user_func( $this->args['text_cb'], $this ); |
|
| 1010 | + if ( is_callable( $this->args[ 'text_cb' ] ) ) { |
|
| 1011 | + $strings = call_user_func( $this->args[ 'text_cb' ], $this ); |
|
| 1012 | 1012 | |
| 1013 | 1013 | if ( $strings && is_array( $strings ) ) { |
| 1014 | 1014 | $this->strings += $strings; |
@@ -1043,10 +1043,10 @@ discard block |
||
| 1043 | 1043 | return $this->field_options; |
| 1044 | 1044 | } |
| 1045 | 1045 | |
| 1046 | - $this->field_options = (array) $this->args['options']; |
|
| 1046 | + $this->field_options = (array) $this->args[ 'options' ]; |
|
| 1047 | 1047 | |
| 1048 | - if ( is_callable( $this->args['options_cb'] ) ) { |
|
| 1049 | - $options = call_user_func( $this->args['options_cb'], $this ); |
|
| 1048 | + if ( is_callable( $this->args[ 'options_cb' ] ) ) { |
|
| 1049 | + $options = call_user_func( $this->args[ 'options_cb' ], $this ); |
|
| 1050 | 1050 | |
| 1051 | 1051 | if ( $options && is_array( $options ) ) { |
| 1052 | 1052 | $this->field_options = $options + $this->field_options; |
@@ -1068,7 +1068,7 @@ discard block |
||
| 1068 | 1068 | */ |
| 1069 | 1069 | public function add_js_dependencies( $dependencies = array() ) { |
| 1070 | 1070 | foreach ( (array) $dependencies as $dependency ) { |
| 1071 | - $this->args['js_dependencies'][ $dependency ] = $dependency; |
|
| 1071 | + $this->args[ 'js_dependencies' ][ $dependency ] = $dependency; |
|
| 1072 | 1072 | } |
| 1073 | 1073 | |
| 1074 | 1074 | CMB2_JS::add_dependencies( $dependencies ); |
@@ -1082,17 +1082,17 @@ discard block |
||
| 1082 | 1082 | * @return mixed Default field value |
| 1083 | 1083 | */ |
| 1084 | 1084 | public function get_default() { |
| 1085 | - if ( null !== $this->args['default'] ) { |
|
| 1086 | - return $this->args['default']; |
|
| 1085 | + if ( null !== $this->args[ 'default' ] ) { |
|
| 1086 | + return $this->args[ 'default' ]; |
|
| 1087 | 1087 | } |
| 1088 | 1088 | |
| 1089 | - $param = is_callable( $this->args['default_cb'] ) ? 'default_cb' : 'default'; |
|
| 1089 | + $param = is_callable( $this->args[ 'default_cb' ] ) ? 'default_cb' : 'default'; |
|
| 1090 | 1090 | $default = $this->get_param_callback_result( $param ); |
| 1091 | 1091 | |
| 1092 | 1092 | // Allow a filter override of the default value |
| 1093 | - $this->args['default'] = apply_filters( 'cmb2_default_filter', $default, $this ); |
|
| 1093 | + $this->args[ 'default' ] = apply_filters( 'cmb2_default_filter', $default, $this ); |
|
| 1094 | 1094 | |
| 1095 | - return $this->args['default']; |
|
| 1095 | + return $this->args[ 'default' ]; |
|
| 1096 | 1096 | } |
| 1097 | 1097 | |
| 1098 | 1098 | /** |
@@ -1123,18 +1123,18 @@ discard block |
||
| 1123 | 1123 | 'classes_cb' => '', |
| 1124 | 1124 | 'select_all_button' => true, |
| 1125 | 1125 | 'multiple' => false, |
| 1126 | - 'repeatable' => isset( $args['type'] ) && 'group' == $args['type'], |
|
| 1126 | + 'repeatable' => isset( $args[ 'type' ] ) && 'group' == $args[ 'type' ], |
|
| 1127 | 1127 | 'inline' => false, |
| 1128 | 1128 | 'on_front' => true, |
| 1129 | 1129 | 'show_names' => true, |
| 1130 | 1130 | 'save_field' => true, // Will not save if false |
| 1131 | 1131 | 'date_format' => 'm\/d\/Y', |
| 1132 | 1132 | 'time_format' => 'h:i A', |
| 1133 | - 'description' => isset( $args['desc'] ) ? $args['desc'] : '', |
|
| 1134 | - 'preview_size' => 'file' == $args['type'] ? array( 350, 350 ) : array( 50, 50 ), |
|
| 1133 | + 'description' => isset( $args[ 'desc' ] ) ? $args[ 'desc' ] : '', |
|
| 1134 | + 'preview_size' => 'file' == $args[ 'type' ] ? array( 350, 350 ) : array( 50, 50 ), |
|
| 1135 | 1135 | 'render_row_cb' => array( $this, 'render_field_callback' ), |
| 1136 | 1136 | 'display_cb' => array( $this, 'display_value_callback' ), |
| 1137 | - 'label_cb' => 'title' != $args['type'] ? array( $this, 'label' ) : '', |
|
| 1137 | + 'label_cb' => 'title' != $args[ 'type' ] ? array( $this, 'label' ) : '', |
|
| 1138 | 1138 | 'column' => false, |
| 1139 | 1139 | 'js_dependencies' => array(), |
| 1140 | 1140 | 'show_in_rest' => null, |
@@ -1149,43 +1149,43 @@ discard block |
||
| 1149 | 1149 | */ |
| 1150 | 1150 | $args = $this->convert_deprecated_params( $args ); |
| 1151 | 1151 | |
| 1152 | - $args['repeatable'] = $args['repeatable'] && ! $this->repeatable_exception( $args['type'] ); |
|
| 1153 | - $args['inline'] = $args['inline'] || false !== stripos( $args['type'], '_inline' ); |
|
| 1152 | + $args[ 'repeatable' ] = $args[ 'repeatable' ] && ! $this->repeatable_exception( $args[ 'type' ] ); |
|
| 1153 | + $args[ 'inline' ] = $args[ 'inline' ] || false !== stripos( $args[ 'type' ], '_inline' ); |
|
| 1154 | 1154 | |
| 1155 | - $args['options'] = 'group' == $args['type'] ? wp_parse_args( $args['options'], array( |
|
| 1155 | + $args[ 'options' ] = 'group' == $args[ 'type' ] ? wp_parse_args( $args[ 'options' ], array( |
|
| 1156 | 1156 | 'add_button' => esc_html__( 'Add Group', 'cmb2' ), |
| 1157 | 1157 | 'remove_button' => esc_html__( 'Remove Group', 'cmb2' ), |
| 1158 | - ) ) : $args['options']; |
|
| 1158 | + ) ) : $args[ 'options' ]; |
|
| 1159 | 1159 | |
| 1160 | - $args['_id'] = $args['id']; |
|
| 1161 | - $args['_name'] = $args['id']; |
|
| 1160 | + $args[ '_id' ] = $args[ 'id' ]; |
|
| 1161 | + $args[ '_name' ] = $args[ 'id' ]; |
|
| 1162 | 1162 | |
| 1163 | 1163 | if ( $this->group ) { |
| 1164 | 1164 | |
| 1165 | - $args['id'] = $this->group->args( 'id' ) . '_' . $this->group->index . '_' . $args['id']; |
|
| 1166 | - $args['_name'] = $this->group->args( 'id' ) . '[' . $this->group->index . '][' . $args['_name'] . ']'; |
|
| 1165 | + $args[ 'id' ] = $this->group->args( 'id' ) . '_' . $this->group->index . '_' . $args[ 'id' ]; |
|
| 1166 | + $args[ '_name' ] = $this->group->args( 'id' ) . '[' . $this->group->index . '][' . $args[ '_name' ] . ']'; |
|
| 1167 | 1167 | } |
| 1168 | 1168 | |
| 1169 | - if ( 'wysiwyg' == $args['type'] ) { |
|
| 1170 | - $args['id'] = strtolower( str_ireplace( '-', '_', $args['id'] ) ); |
|
| 1171 | - $args['options']['textarea_name'] = $args['_name']; |
|
| 1169 | + if ( 'wysiwyg' == $args[ 'type' ] ) { |
|
| 1170 | + $args[ 'id' ] = strtolower( str_ireplace( '-', '_', $args[ 'id' ] ) ); |
|
| 1171 | + $args[ 'options' ][ 'textarea_name' ] = $args[ '_name' ]; |
|
| 1172 | 1172 | } |
| 1173 | 1173 | |
| 1174 | 1174 | $option_types = apply_filters( 'cmb2_all_or_nothing_types', array( 'select', 'radio', 'radio_inline', 'taxonomy_select', 'taxonomy_radio', 'taxonomy_radio_inline' ), $this ); |
| 1175 | 1175 | |
| 1176 | - if ( in_array( $args['type'], $option_types, true ) ) { |
|
| 1176 | + if ( in_array( $args[ 'type' ], $option_types, true ) ) { |
|
| 1177 | 1177 | |
| 1178 | - $args['show_option_none'] = isset( $args['show_option_none'] ) ? $args['show_option_none'] : null; |
|
| 1179 | - $args['show_option_none'] = true === $args['show_option_none'] ? esc_html__( 'None', 'cmb2' ) : $args['show_option_none']; |
|
| 1178 | + $args[ 'show_option_none' ] = isset( $args[ 'show_option_none' ] ) ? $args[ 'show_option_none' ] : null; |
|
| 1179 | + $args[ 'show_option_none' ] = true === $args[ 'show_option_none' ] ? esc_html__( 'None', 'cmb2' ) : $args[ 'show_option_none' ]; |
|
| 1180 | 1180 | |
| 1181 | - if ( null === $args['show_option_none'] ) { |
|
| 1182 | - $off_by_default = in_array( $args['type'], array( 'select', 'radio', 'radio_inline' ), true ); |
|
| 1183 | - $args['show_option_none'] = $off_by_default ? false : esc_html__( 'None', 'cmb2' ); |
|
| 1181 | + if ( null === $args[ 'show_option_none' ] ) { |
|
| 1182 | + $off_by_default = in_array( $args[ 'type' ], array( 'select', 'radio', 'radio_inline' ), true ); |
|
| 1183 | + $args[ 'show_option_none' ] = $off_by_default ? false : esc_html__( 'None', 'cmb2' ); |
|
| 1184 | 1184 | } |
| 1185 | 1185 | } |
| 1186 | 1186 | |
| 1187 | - $args['has_supporting_data'] = in_array( |
|
| 1188 | - $args['type'], |
|
| 1187 | + $args[ 'has_supporting_data' ] = in_array( |
|
| 1188 | + $args[ 'type' ], |
|
| 1189 | 1189 | array( |
| 1190 | 1190 | // CMB2_Sanitize::_save_file_id_value()/CMB2_Sanitize::_get_group_file_value_array() |
| 1191 | 1191 | 'file', |
@@ -1209,10 +1209,10 @@ discard block |
||
| 1209 | 1209 | protected function get_default_args( $field_args, $field_group = null ) { |
| 1210 | 1210 | $args = parent::get_default_args( array(), $this->group ); |
| 1211 | 1211 | |
| 1212 | - if ( isset( $field_args['field_args'] ) ) { |
|
| 1212 | + if ( isset( $field_args[ 'field_args' ] ) ) { |
|
| 1213 | 1213 | $args = wp_parse_args( $field_args, $args ); |
| 1214 | 1214 | } else { |
| 1215 | - $args['field_args'] = wp_parse_args( $field_args, $this->args ); |
|
| 1215 | + $args[ 'field_args' ] = wp_parse_args( $field_args, $this->args ); |
|
| 1216 | 1216 | } |
| 1217 | 1217 | |
| 1218 | 1218 | return $args; |
@@ -1256,41 +1256,41 @@ discard block |
||
| 1256 | 1256 | */ |
| 1257 | 1257 | protected function convert_deprecated_params( $args ) { |
| 1258 | 1258 | |
| 1259 | - if ( isset( $args['row_classes'] ) ) { |
|
| 1259 | + if ( isset( $args[ 'row_classes' ] ) ) { |
|
| 1260 | 1260 | |
| 1261 | 1261 | // We'll let this one be. |
| 1262 | 1262 | // $this->deprecated_param( __CLASS__ . '::__construct()', '2.2.3', self::DEPRECATED_PARAM, 'row_classes', 'classes' ); |
| 1263 | 1263 | // row_classes param could be a callback. This is definitely deprecated. |
| 1264 | - if ( is_callable( $args['row_classes'] ) ) { |
|
| 1264 | + if ( is_callable( $args[ 'row_classes' ] ) ) { |
|
| 1265 | 1265 | |
| 1266 | 1266 | $this->deprecated_param( __CLASS__ . '::__construct()', '2.2.3', self::DEPRECATED_CB_PARAM, 'row_classes', 'classes_cb' ); |
| 1267 | 1267 | |
| 1268 | - $args['classes_cb'] = $args['row_classes']; |
|
| 1269 | - $args['classes'] = null; |
|
| 1268 | + $args[ 'classes_cb' ] = $args[ 'row_classes' ]; |
|
| 1269 | + $args[ 'classes' ] = null; |
|
| 1270 | 1270 | } else { |
| 1271 | 1271 | |
| 1272 | - $args['classes'] = $args['row_classes']; |
|
| 1272 | + $args[ 'classes' ] = $args[ 'row_classes' ]; |
|
| 1273 | 1273 | } |
| 1274 | 1274 | |
| 1275 | - unset( $args['row_classes'] ); |
|
| 1275 | + unset( $args[ 'row_classes' ] ); |
|
| 1276 | 1276 | } |
| 1277 | 1277 | |
| 1278 | 1278 | // default param can be passed a callback as well |
| 1279 | - if ( is_callable( $args['default'] ) ) { |
|
| 1279 | + if ( is_callable( $args[ 'default' ] ) ) { |
|
| 1280 | 1280 | |
| 1281 | 1281 | $this->deprecated_param( __CLASS__ . '::__construct()', '2.2.3', self::DEPRECATED_CB_PARAM, 'default', 'default_cb' ); |
| 1282 | 1282 | |
| 1283 | - $args['default_cb'] = $args['default']; |
|
| 1284 | - $args['default'] = null; |
|
| 1283 | + $args[ 'default_cb' ] = $args[ 'default' ]; |
|
| 1284 | + $args[ 'default' ] = null; |
|
| 1285 | 1285 | } |
| 1286 | 1286 | |
| 1287 | 1287 | // options param can be passed a callback as well |
| 1288 | - if ( is_callable( $args['options'] ) ) { |
|
| 1288 | + if ( is_callable( $args[ 'options' ] ) ) { |
|
| 1289 | 1289 | |
| 1290 | 1290 | $this->deprecated_param( __CLASS__ . '::__construct()', '2.2.3', self::DEPRECATED_CB_PARAM, 'options', 'options_cb' ); |
| 1291 | 1291 | |
| 1292 | - $args['options_cb'] = $args['options']; |
|
| 1293 | - $args['options'] = array(); |
|
| 1292 | + $args[ 'options_cb' ] = $args[ 'options' ]; |
|
| 1293 | + $args[ 'options' ] = array(); |
|
| 1294 | 1294 | } |
| 1295 | 1295 | |
| 1296 | 1296 | return $args; |
@@ -484,7 +484,7 @@ discard block |
||
| 484 | 484 | * |
| 485 | 485 | * @since 2.2.4 |
| 486 | 486 | * @param array $classes Array of classes |
| 487 | - * @return array Modified array of classes |
|
| 487 | + * @return string[] Modified array of classes |
|
| 488 | 488 | */ |
| 489 | 489 | public function postbox_classes( $classes ) { |
| 490 | 490 | if ( $this->cmb->prop( 'closed' ) && ! in_array( 'closed', $classes ) ) { |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | * |
| 506 | 506 | * @since 2.2.4 |
| 507 | 507 | * @param array $classes Array of classes |
| 508 | - * @return array Modified array of classes |
|
| 508 | + * @return string[] Modified array of classes |
|
| 509 | 509 | */ |
| 510 | 510 | protected function alternate_context_postbox_classes( $classes ) { |
| 511 | 511 | $classes[] = 'context-box'; |
@@ -276,25 +276,25 @@ discard block |
||
| 276 | 276 | $fields = $this->cmb->prop( 'fields' ); |
| 277 | 277 | |
| 278 | 278 | foreach ( $fields as $key => $field ) { |
| 279 | - if ( ! isset( $field['column'] ) ) { |
|
| 279 | + if ( ! isset( $field[ 'column' ] ) ) { |
|
| 280 | 280 | continue; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - $column = $field['column']; |
|
| 283 | + $column = $field[ 'column' ]; |
|
| 284 | 284 | |
| 285 | - if ( false === $column['position'] ) { |
|
| 285 | + if ( false === $column[ 'position' ] ) { |
|
| 286 | 286 | |
| 287 | - $columns[ $field['id'] ] = $column['name']; |
|
| 287 | + $columns[ $field[ 'id' ] ] = $column[ 'name' ]; |
|
| 288 | 288 | |
| 289 | 289 | } else { |
| 290 | 290 | |
| 291 | - $before = array_slice( $columns, 0, absint( $column['position'] ) ); |
|
| 292 | - $before[ $field['id'] ] = $column['name']; |
|
| 291 | + $before = array_slice( $columns, 0, absint( $column[ 'position' ] ) ); |
|
| 292 | + $before[ $field[ 'id' ] ] = $column[ 'name' ]; |
|
| 293 | 293 | $columns = $before + $columns; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - $column['field'] = $field; |
|
| 297 | - $this->columns[ $field['id'] ] = $column; |
|
| 296 | + $column[ 'field' ] = $field; |
|
| 297 | + $this->columns[ $field[ 'id' ] ] = $column; |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | return $columns; |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | public function column_display( $column_name, $object_id ) { |
| 309 | 309 | if ( isset( $this->columns[ $column_name ] ) ) { |
| 310 | 310 | $field = new CMB2_Field( array( |
| 311 | - 'field_args' => $this->columns[ $column_name ]['field'], |
|
| 311 | + 'field_args' => $this->columns[ $column_name ][ 'field' ], |
|
| 312 | 312 | 'object_type' => $this->object_type, |
| 313 | 313 | 'object_id' => $this->cmb->object_id( $object_id ), |
| 314 | 314 | 'cmb_id' => $this->cmb->cmb_id, |
@@ -488,13 +488,13 @@ discard block |
||
| 488 | 488 | */ |
| 489 | 489 | public function postbox_classes( $classes ) { |
| 490 | 490 | if ( $this->cmb->prop( 'closed' ) && ! in_array( 'closed', $classes ) ) { |
| 491 | - $classes[] = 'closed'; |
|
| 491 | + $classes[ ] = 'closed'; |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | if ( $this->cmb->is_alternate_context_box() ) { |
| 495 | 495 | $classes = $this->alternate_context_postbox_classes( $classes ); |
| 496 | 496 | } else { |
| 497 | - $classes[] = 'cmb2-postbox'; |
|
| 497 | + $classes[ ] = 'cmb2-postbox'; |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | return $classes; |
@@ -508,19 +508,19 @@ discard block |
||
| 508 | 508 | * @return array Modified array of classes |
| 509 | 509 | */ |
| 510 | 510 | protected function alternate_context_postbox_classes( $classes ) { |
| 511 | - $classes[] = 'context-box'; |
|
| 512 | - $classes[] = 'context-' . $this->cmb->prop( 'context' ) . '-box'; |
|
| 511 | + $classes[ ] = 'context-box'; |
|
| 512 | + $classes[ ] = 'context-' . $this->cmb->prop( 'context' ) . '-box'; |
|
| 513 | 513 | |
| 514 | 514 | if ( in_array( $this->cmb->cmb_id, get_hidden_meta_boxes( get_current_screen() ) ) ) { |
| 515 | - $classes[] = 'hide-if-js'; |
|
| 515 | + $classes[ ] = 'hide-if-js'; |
|
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | $add_wrap = $this->cmb->prop( 'title' ) || ! $this->cmb->prop( 'remove_box_wrap' ); |
| 519 | 519 | |
| 520 | 520 | if ( $add_wrap ) { |
| 521 | - $classes[] = 'cmb2-postbox postbox'; |
|
| 521 | + $classes[ ] = 'cmb2-postbox postbox'; |
|
| 522 | 522 | } else { |
| 523 | - $classes[] = 'cmb2-no-box-wrap'; |
|
| 523 | + $classes[ ] = 'cmb2-no-box-wrap'; |
|
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | return $classes; |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | public function user_new_metabox( $section ) { |
| 545 | 545 | if ( $section == $this->cmb->prop( 'new_user_section' ) ) { |
| 546 | 546 | $object_id = $this->cmb->object_id(); |
| 547 | - $this->cmb->object_id( isset( $_REQUEST['user_id'] ) ? $_REQUEST['user_id'] : $object_id ); |
|
| 547 | + $this->cmb->object_id( isset( $_REQUEST[ 'user_id' ] ) ? $_REQUEST[ 'user_id' ] : $object_id ); |
|
| 548 | 548 | $this->user_metabox(); |
| 549 | 549 | } |
| 550 | 550 | } |
@@ -735,7 +735,7 @@ discard block |
||
| 735 | 735 | |
| 736 | 736 | $data_to_delete = array(); |
| 737 | 737 | foreach ( $this->cmb->prop( 'fields' ) as $field ) { |
| 738 | - $data_to_delete[ $field['id'] ] = ''; |
|
| 738 | + $data_to_delete[ $field[ 'id' ] ] = ''; |
|
| 739 | 739 | } |
| 740 | 740 | |
| 741 | 741 | $this->cmb->save_fields( $term_id, 'term', $data_to_delete ); |
@@ -433,6 +433,7 @@ discard block |
||
| 433 | 433 | * Gets the values for the `file` field type from the data being saved. |
| 434 | 434 | * |
| 435 | 435 | * @since 2.2.0 |
| 436 | + * @param string $id_key |
|
| 436 | 437 | */ |
| 437 | 438 | public function _get_group_file_value_array( $id_key ) { |
| 438 | 439 | $alldata = $this->field->group->data_to_save; |
@@ -460,6 +461,7 @@ discard block |
||
| 460 | 461 | * Peforms saving of `file` attachement's ID |
| 461 | 462 | * |
| 462 | 463 | * @since 1.1.0 |
| 464 | + * @param string $file_id_key |
|
| 463 | 465 | */ |
| 464 | 466 | public function _save_file_id_value( $file_id_key ) { |
| 465 | 467 | $id_field = $this->_new_supporting_field( $file_id_key ); |
@@ -481,6 +483,7 @@ discard block |
||
| 481 | 483 | * Peforms saving of `text_datetime_timestamp_timezone` utc timestamp |
| 482 | 484 | * |
| 483 | 485 | * @since 2.2.0 |
| 486 | + * @param string $utc_key |
|
| 484 | 487 | */ |
| 485 | 488 | public function _save_utc_value( $utc_key, $utc_stamp ) { |
| 486 | 489 | return $this->_new_supporting_field( $utc_key )->save_field( $utc_stamp ); |
@@ -239,7 +239,7 @@ |
||
| 239 | 239 | * @param string $fieldtype The type of field being rendered. |
| 240 | 240 | * @param string $render_class_name The default field type class to use. Defaults to null. |
| 241 | 241 | * @param array $args Optional arguments to pass to type class. |
| 242 | - * @param mixed $additional Optional additional argument to pass to type class. |
|
| 242 | + * @param string $additional Optional additional argument to pass to type class. |
|
| 243 | 243 | * @return CMB2_Type_Base Type object. |
| 244 | 244 | */ |
| 245 | 245 | public function get_new_render_type( $fieldtype, $render_class_name = null, $args = array(), $additional = '' ) { |
@@ -208,6 +208,7 @@ discard block |
||
| 208 | 208 | * @param string|array $object_types Object(s) the field is being registered |
| 209 | 209 | * to, "post"|"term"|"comment" etc. |
| 210 | 210 | * @param string $object_types Canonical object type for callbacks. |
| 211 | + * @param string $object_type |
|
| 211 | 212 | * |
| 212 | 213 | * @return void |
| 213 | 214 | */ |
@@ -706,7 +707,7 @@ discard block |
||
| 706 | 707 | * Retrieve all CMB2_REST instances from the registry. |
| 707 | 708 | * |
| 708 | 709 | * @since 2.2.3 |
| 709 | - * @return CMB2[] Array of all registered CMB2_REST instances. |
|
| 710 | + * @return CMB2_REST[] Array of all registered CMB2_REST instances. |
|
| 710 | 711 | */ |
| 711 | 712 | public static function get_all() { |
| 712 | 713 | return self::$boxes; |
@@ -154,30 +154,30 @@ discard block |
||
| 154 | 154 | foreach ( self::$boxes as $cmb_id => $rest_box ) { |
| 155 | 155 | $types = array_flip( $rest_box->cmb->box_types() ); |
| 156 | 156 | |
| 157 | - if ( isset( $types['user'] ) ) { |
|
| 158 | - unset( $types['user'] ); |
|
| 159 | - self::$type_boxes['user'][ $cmb_id ] = $cmb_id; |
|
| 157 | + if ( isset( $types[ 'user' ] ) ) { |
|
| 158 | + unset( $types[ 'user' ] ); |
|
| 159 | + self::$type_boxes[ 'user' ][ $cmb_id ] = $cmb_id; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - if ( isset( $types['comment'] ) ) { |
|
| 163 | - unset( $types['comment'] ); |
|
| 164 | - self::$type_boxes['comment'][ $cmb_id ] = $cmb_id; |
|
| 162 | + if ( isset( $types[ 'comment' ] ) ) { |
|
| 163 | + unset( $types[ 'comment' ] ); |
|
| 164 | + self::$type_boxes[ 'comment' ][ $cmb_id ] = $cmb_id; |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - if ( isset( $types['term'] ) ) { |
|
| 168 | - unset( $types['term'] ); |
|
| 167 | + if ( isset( $types[ 'term' ] ) ) { |
|
| 168 | + unset( $types[ 'term' ] ); |
|
| 169 | 169 | |
| 170 | 170 | $taxonomies = array_merge( |
| 171 | 171 | $taxonomies, |
| 172 | 172 | CMB2_Utils::ensure_array( $rest_box->cmb->prop( 'taxonomies' ) ) |
| 173 | 173 | ); |
| 174 | 174 | |
| 175 | - self::$type_boxes['term'][ $cmb_id ] = $cmb_id; |
|
| 175 | + self::$type_boxes[ 'term' ][ $cmb_id ] = $cmb_id; |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | if ( ! empty( $types ) ) { |
| 179 | 179 | $alltypes = array_merge( $alltypes, array_flip( $types ) ); |
| 180 | - self::$type_boxes['post'][ $cmb_id ] = $cmb_id; |
|
| 180 | + self::$type_boxes[ 'post' ][ $cmb_id ] = $cmb_id; |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
@@ -187,15 +187,15 @@ discard block |
||
| 187 | 187 | self::register_rest_field( $alltypes, 'post' ); |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - if ( ! empty( self::$type_boxes['user'] ) ) { |
|
| 190 | + if ( ! empty( self::$type_boxes[ 'user' ] ) ) { |
|
| 191 | 191 | self::register_rest_field( 'user', 'user' ); |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - if ( ! empty( self::$type_boxes['comment'] ) ) { |
|
| 194 | + if ( ! empty( self::$type_boxes[ 'comment' ] ) ) { |
|
| 195 | 195 | self::register_rest_field( 'comment', 'comment' ); |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - if ( ! empty( self::$type_boxes['term'] ) ) { |
|
| 198 | + if ( ! empty( self::$type_boxes[ 'term' ] ) ) { |
|
| 199 | 199 | self::register_rest_field( $taxonomies, 'term' ); |
| 200 | 200 | } |
| 201 | 201 | } |
@@ -228,18 +228,18 @@ discard block |
||
| 228 | 228 | */ |
| 229 | 229 | protected function declare_read_edit_fields() { |
| 230 | 230 | foreach ( $this->cmb->prop( 'fields' ) as $field ) { |
| 231 | - $show_in_rest = isset( $field['show_in_rest'] ) ? $field['show_in_rest'] : null; |
|
| 231 | + $show_in_rest = isset( $field[ 'show_in_rest' ] ) ? $field[ 'show_in_rest' ] : null; |
|
| 232 | 232 | |
| 233 | 233 | if ( false === $show_in_rest ) { |
| 234 | 234 | continue; |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | if ( $this->can_read( $show_in_rest ) ) { |
| 238 | - $this->read_fields[] = $field['id']; |
|
| 238 | + $this->read_fields[ ] = $field[ 'id' ]; |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | if ( $this->can_edit( $show_in_rest ) ) { |
| 242 | - $this->edit_fields[] = $field['id']; |
|
| 242 | + $this->edit_fields[ ] = $field[ 'id' ]; |
|
| 243 | 243 | } |
| 244 | 244 | } |
| 245 | 245 | } |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | * @return mixed |
| 370 | 370 | */ |
| 371 | 371 | protected static function get_rest_values( $object, $request, $object_type, $main_object_type = 'post' ) { |
| 372 | - if ( ! isset( $object['id'] ) ) { |
|
| 372 | + if ( ! isset( $object[ 'id' ] ) ) { |
|
| 373 | 373 | return; |
| 374 | 374 | } |
| 375 | 375 | |
@@ -380,12 +380,12 @@ discard block |
||
| 380 | 380 | $rest_box = self::$boxes[ $cmb_id ]; |
| 381 | 381 | |
| 382 | 382 | foreach ( $rest_box->read_fields as $field_id ) { |
| 383 | - $rest_box->cmb->object_id( $object['id'] ); |
|
| 383 | + $rest_box->cmb->object_id( $object[ 'id' ] ); |
|
| 384 | 384 | $rest_box->cmb->object_type( $main_object_type ); |
| 385 | 385 | |
| 386 | 386 | $field = $rest_box->cmb->get_field( $field_id ); |
| 387 | 387 | |
| 388 | - $field->object_id( $object['id'] ); |
|
| 388 | + $field->object_id( $object[ 'id' ] ); |
|
| 389 | 389 | $field->object_type( $main_object_type ); |
| 390 | 390 | |
| 391 | 391 | $values[ $cmb_id ][ $field->id( true ) ] = $field->get_data(); |
@@ -619,8 +619,8 @@ discard block |
||
| 619 | 619 | return intval( $object->comment_ID ); |
| 620 | 620 | } |
| 621 | 621 | case 'term': |
| 622 | - if ( is_array( $object ) && isset( $object['term_id'] ) ) { |
|
| 623 | - return intval( $object['term_id'] ); |
|
| 622 | + if ( is_array( $object ) && isset( $object[ 'term_id' ] ) ) { |
|
| 623 | + return intval( $object[ 'term_id' ] ); |
|
| 624 | 624 | } elseif ( isset( $object->term_id ) ) { |
| 625 | 625 | return intval( $object->term_id ); |
| 626 | 626 | } |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | * @since 2.2.3 |
| 206 | 206 | * |
| 207 | 207 | * @param mixed $cb Callable function/method. |
| 208 | - * @return mixed Results of output buffer after calling function/method. |
|
| 208 | + * @return string Results of output buffer after calling function/method. |
|
| 209 | 209 | */ |
| 210 | 210 | public function get_cb_results( $cb ) { |
| 211 | 211 | $args = func_get_args(); |
@@ -221,7 +221,6 @@ discard block |
||
| 221 | 221 | * |
| 222 | 222 | * @since 2.2.3 |
| 223 | 223 | * |
| 224 | - * @param mixed $item WordPress representation of the item. |
|
| 225 | 224 | * @param WP_REST_Request $request Request object. |
| 226 | 225 | * @return WP_REST_Response $response |
| 227 | 226 | */ |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * Stores the rendered field output. |
| 59 | 59 | * |
| 60 | 60 | * @since 2.2.2 |
| 61 | - * @param string|CMB2_Type_Base $rendered Rendered output. |
|
| 61 | + * @param string $rendered Rendered output. |
|
| 62 | 62 | * @return string|CMB2_Type_Base Rendered output or this object. |
| 63 | 63 | */ |
| 64 | 64 | public function rendered( $rendered ) { |
@@ -117,7 +117,6 @@ discard block |
||
| 117 | 117 | /** |
| 118 | 118 | * Fall back to CMB2_Types methods |
| 119 | 119 | * |
| 120 | - * @param string $field |
|
| 121 | 120 | * @throws Exception Throws an exception if the field is invalid. |
| 122 | 121 | * @return mixed |
| 123 | 122 | */ |
@@ -139,7 +138,7 @@ discard block |
||
| 139 | 138 | * |
| 140 | 139 | * @param string $field |
| 141 | 140 | * @throws Exception Throws an exception if the field is invalid. |
| 142 | - * @return mixed |
|
| 141 | + * @return CMB2_Field |
|
| 143 | 142 | */ |
| 144 | 143 | public function __get( $field ) { |
| 145 | 144 | switch ( $field ) { |
@@ -16,7 +16,6 @@ |
||
| 16 | 16 | * Handles outputting an 'textarea' element |
| 17 | 17 | * |
| 18 | 18 | * @since 1.1.0 |
| 19 | - * @param array $args Override arguments |
|
| 20 | 19 | * @return string Form textarea element |
| 21 | 20 | */ |
| 22 | 21 | public function render() { |