@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | } |
359 | 359 | |
360 | 360 | // Cast to bool. |
361 | - return !! $val; |
|
361 | + return ! ! $val; |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | /** |
@@ -386,11 +386,11 @@ discard block |
||
386 | 386 | switch ( $message ) { |
387 | 387 | |
388 | 388 | case self::DEPRECATED_PARAM: |
389 | - $message = sprintf( __( 'The "%s" field parameter has been deprecated in favor of the "%s" parameter.', 'cmb2' ), $args[3], $args[4] ); |
|
389 | + $message = sprintf( __( 'The "%s" field parameter has been deprecated in favor of the "%s" parameter.', 'cmb2' ), $args[ 3 ], $args[ 4 ] ); |
|
390 | 390 | break; |
391 | 391 | |
392 | 392 | case self::DEPRECATED_CB_PARAM: |
393 | - $message = sprintf( __( 'Using the "%s" field parameter as a callback has been deprecated in favor of the "%s" parameter.', 'cmb2' ), $args[3], $args[4] ); |
|
393 | + $message = sprintf( __( 'Using the "%s" field parameter as a callback has been deprecated in favor of the "%s" parameter.', 'cmb2' ), $args[ 3 ], $args[ 4 ] ); |
|
394 | 394 | break; |
395 | 395 | |
396 | 396 | default: |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | public function __call( $method, $args ) { |
470 | 470 | $object_class = strtolower( get_class( $this ) ); |
471 | 471 | |
472 | - if ( ! has_filter( "{$object_class}_inherit_{$method}" ) ) { |
|
472 | + if ( ! has_filter( "{$object_class}_inherit_{$method}" ) ) { |
|
473 | 473 | throw new Exception( sprintf( esc_html__( 'Invalid %1$s method: %2$s', 'cmb2' ), get_class( $this ), $method ) ); |
474 | 474 | } |
475 | 475 |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | if ( $this->cmb->has_columns ) { |
124 | 124 | add_filter( 'manage_edit-comments_columns', array( $this, 'register_column_headers' ) ); |
125 | - add_action( 'manage_comments_custom_column', array( $this, 'column_display' ), 10, 3 ); |
|
125 | + add_action( 'manage_comments_custom_column', array( $this, 'column_display' ), 10, 3 ); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | |
140 | 140 | if ( $this->cmb->has_columns ) { |
141 | 141 | add_filter( 'manage_users_columns', array( $this, 'register_column_headers' ) ); |
142 | - add_filter( 'manage_users_custom_column', array( $this, 'return_column_display' ), 10, 3 ); |
|
142 | + add_filter( 'manage_users_custom_column', array( $this, 'return_column_display' ), 10, 3 ); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | |
174 | 174 | if ( $this->cmb->has_columns ) { |
175 | 175 | add_filter( "manage_edit-{$taxonomy}_columns", array( $this, 'register_column_headers' ) ); |
176 | - add_filter( "manage_{$taxonomy}_custom_column", array( $this, 'return_column_display' ), 10, 3 ); |
|
176 | + add_filter( "manage_{$taxonomy}_custom_column", array( $this, 'return_column_display' ), 10, 3 ); |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
@@ -266,25 +266,25 @@ discard block |
||
266 | 266 | $fields = $this->cmb->prop( 'fields' ); |
267 | 267 | |
268 | 268 | foreach ( $fields as $key => $field ) { |
269 | - if ( ! isset( $field['column'] ) ) { |
|
269 | + if ( ! isset( $field[ 'column' ] ) ) { |
|
270 | 270 | continue; |
271 | 271 | } |
272 | 272 | |
273 | - $column = $field['column']; |
|
273 | + $column = $field[ 'column' ]; |
|
274 | 274 | |
275 | - if ( false === $column['position'] ) { |
|
275 | + if ( false === $column[ 'position' ] ) { |
|
276 | 276 | |
277 | - $columns[ $field['id'] ] = $column['name']; |
|
277 | + $columns[ $field[ 'id' ] ] = $column[ 'name' ]; |
|
278 | 278 | |
279 | 279 | } else { |
280 | 280 | |
281 | - $before = array_slice( $columns, 0, absint( $column['position'] ) ); |
|
282 | - $before[ $field['id'] ] = $column['name']; |
|
281 | + $before = array_slice( $columns, 0, absint( $column[ 'position' ] ) ); |
|
282 | + $before[ $field[ 'id' ] ] = $column[ 'name' ]; |
|
283 | 283 | $columns = $before + $columns; |
284 | 284 | } |
285 | 285 | |
286 | - $column['field'] = $field; |
|
287 | - $this->columns[ $field['id'] ] = $column; |
|
286 | + $column[ 'field' ] = $field; |
|
287 | + $this->columns[ $field[ 'id' ] ] = $column; |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | return $columns; |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | public function column_display( $column_name, $object_id ) { |
298 | 298 | if ( isset( $this->columns[ $column_name ] ) ) { |
299 | 299 | $field = new CMB2_Field( array( |
300 | - 'field_args' => $this->columns[ $column_name ]['field'], |
|
300 | + 'field_args' => $this->columns[ $column_name ][ 'field' ], |
|
301 | 301 | 'object_type' => $this->object_type, |
302 | 302 | 'object_id' => $this->cmb->object_id( $object_id ), |
303 | 303 | 'cmb_id' => $this->cmb->cmb_id, |
@@ -469,13 +469,13 @@ discard block |
||
469 | 469 | */ |
470 | 470 | public function postbox_classes( $classes ) { |
471 | 471 | if ( $this->cmb->prop( 'closed' ) && ! in_array( 'closed', $classes ) ) { |
472 | - $classes[] = 'closed'; |
|
472 | + $classes[ ] = 'closed'; |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | if ( $this->cmb->is_alternate_context_box() ) { |
476 | 476 | $classes = $this->alternate_context_postbox_classes( $classes ); |
477 | 477 | } else { |
478 | - $classes[] = 'cmb2-postbox'; |
|
478 | + $classes[ ] = 'cmb2-postbox'; |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | return $classes; |
@@ -488,19 +488,19 @@ discard block |
||
488 | 488 | * @return array Modified array of classes |
489 | 489 | */ |
490 | 490 | protected function alternate_context_postbox_classes( $classes ) { |
491 | - $classes[] = 'context-box'; |
|
492 | - $classes[] = 'context-' . $this->cmb->prop( 'context' ) . '-box'; |
|
491 | + $classes[ ] = 'context-box'; |
|
492 | + $classes[ ] = 'context-' . $this->cmb->prop( 'context' ) . '-box'; |
|
493 | 493 | |
494 | 494 | if ( in_array( $this->cmb->cmb_id, get_hidden_meta_boxes( get_current_screen() ) ) ) { |
495 | - $classes[] = 'hide-if-js'; |
|
495 | + $classes[ ] = 'hide-if-js'; |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | $add_wrap = $this->cmb->prop( 'title' ) || ! $this->cmb->prop( 'remove_box_wrap' ); |
499 | 499 | |
500 | 500 | if ( $add_wrap ) { |
501 | - $classes[] = 'cmb2-postbox postbox'; |
|
501 | + $classes[ ] = 'cmb2-postbox postbox'; |
|
502 | 502 | } else { |
503 | - $classes[] = 'cmb2-no-box-wrap'; |
|
503 | + $classes[ ] = 'cmb2-no-box-wrap'; |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | return $classes; |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | public function user_new_metabox( $section ) { |
523 | 523 | if ( $section == $this->cmb->prop( 'new_user_section' ) ) { |
524 | 524 | $object_id = $this->cmb->object_id(); |
525 | - $this->cmb->object_id( isset( $_REQUEST['user_id'] ) ? $_REQUEST['user_id'] : $object_id ); |
|
525 | + $this->cmb->object_id( isset( $_REQUEST[ 'user_id' ] ) ? $_REQUEST[ 'user_id' ] : $object_id ); |
|
526 | 526 | $this->user_metabox(); |
527 | 527 | } |
528 | 528 | } |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | |
704 | 704 | $data_to_delete = array(); |
705 | 705 | foreach ( $this->cmb->prop( 'fields' ) as $field ) { |
706 | - $data_to_delete[ $field['id'] ] = ''; |
|
706 | + $data_to_delete[ $field[ 'id' ] ] = ''; |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | $this->cmb->save_fields( $term_id, 'term', $data_to_delete ); |
@@ -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(); |
@@ -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 | } |
@@ -112,21 +112,21 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function __construct( $args ) { |
114 | 114 | |
115 | - if ( ! empty( $args['group_field'] ) ) { |
|
116 | - $this->group = $args['group_field']; |
|
115 | + if ( ! empty( $args[ 'group_field' ] ) ) { |
|
116 | + $this->group = $args[ 'group_field' ]; |
|
117 | 117 | $this->object_id = $this->group->object_id; |
118 | 118 | $this->object_type = $this->group->object_type; |
119 | 119 | $this->cmb_id = $this->group->cmb_id; |
120 | 120 | } else { |
121 | - $this->object_id = isset( $args['object_id'] ) && '_' !== $args['object_id'] ? $args['object_id'] : 0; |
|
122 | - $this->object_type = isset( $args['object_type'] ) ? $args['object_type'] : 'post'; |
|
121 | + $this->object_id = isset( $args[ 'object_id' ] ) && '_' !== $args[ 'object_id' ] ? $args[ 'object_id' ] : 0; |
|
122 | + $this->object_type = isset( $args[ 'object_type' ] ) ? $args[ 'object_type' ] : 'post'; |
|
123 | 123 | |
124 | - if ( isset( $args['cmb_id'] ) ) { |
|
125 | - $this->cmb_id = $args['cmb_id']; |
|
124 | + if ( isset( $args[ 'cmb_id' ] ) ) { |
|
125 | + $this->cmb_id = $args[ 'cmb_id' ]; |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
129 | - $this->args = $this->_set_field_defaults( $args['field_args'], $args ); |
|
129 | + $this->args = $this->_set_field_defaults( $args[ 'field_args' ], $args ); |
|
130 | 130 | |
131 | 131 | if ( $this->object_id ) { |
132 | 132 | $this->value = $this->get_data(); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | return call_user_func_array( array( $this, 'get_string' ), $arguments ); |
146 | 146 | } |
147 | 147 | |
148 | - $key = isset( $arguments[0] ) ? $arguments[0] : false; |
|
148 | + $key = isset( $arguments[ 0 ] ) ? $arguments[ 0 ] : false; |
|
149 | 149 | return $this->args( $name, $key ); |
150 | 150 | } |
151 | 151 | |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | */ |
217 | 217 | public function get_data( $field_id = '', $args = array() ) { |
218 | 218 | if ( $field_id ) { |
219 | - $args['field_id'] = $field_id; |
|
219 | + $args[ 'field_id' ] = $field_id; |
|
220 | 220 | } else if ( $this->group ) { |
221 | - $args['field_id'] = $this->group->id(); |
|
221 | + $args[ 'field_id' ] = $this->group->id(); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | $a = $this->data_args( $args ); |
@@ -259,13 +259,13 @@ discard block |
||
259 | 259 | * |
260 | 260 | * @since 2.0.0 |
261 | 261 | */ |
262 | - $data = apply_filters( "cmb2_override_{$a['field_id']}_meta_value", $data, $this->object_id, $a, $this ); |
|
262 | + $data = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_value", $data, $this->object_id, $a, $this ); |
|
263 | 263 | |
264 | 264 | // If no override, get value normally |
265 | 265 | if ( 'cmb2_field_no_override_val' === $data ) { |
266 | - $data = 'options-page' === $a['type'] |
|
267 | - ? cmb2_options( $a['id'] )->get( $a['field_id'] ) |
|
268 | - : get_metadata( $a['type'], $a['id'], $a['field_id'], ( $a['single'] || $a['repeat'] ) ); |
|
266 | + $data = 'options-page' === $a[ 'type' ] |
|
267 | + ? cmb2_options( $a[ 'id' ] )->get( $a[ 'field_id' ] ) |
|
268 | + : get_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], ( $a[ 'single' ] || $a[ 'repeat' ] ) ); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | if ( $this->group ) { |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | public function update_data( $new_value, $single = true ) { |
288 | 288 | $a = $this->data_args( array( 'single' => $single ) ); |
289 | 289 | |
290 | - $a['value'] = $a['repeat'] ? array_values( $new_value ) : $new_value; |
|
290 | + $a[ 'value' ] = $a[ 'repeat' ] ? array_values( $new_value ) : $new_value; |
|
291 | 291 | |
292 | 292 | /** |
293 | 293 | * Filter whether to override saving of meta value. |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | * |
324 | 324 | * @since 2.0.0 |
325 | 325 | */ |
326 | - $override = apply_filters( "cmb2_override_{$a['field_id']}_meta_save", $override, $a, $this->args(), $this ); |
|
326 | + $override = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_save", $override, $a, $this->args(), $this ); |
|
327 | 327 | |
328 | 328 | // If override, return that |
329 | 329 | if ( null !== $override ) { |
@@ -331,22 +331,22 @@ discard block |
||
331 | 331 | } |
332 | 332 | |
333 | 333 | // Options page handling (or temp data store) |
334 | - if ( 'options-page' === $a['type'] || empty( $a['id'] ) ) { |
|
335 | - return cmb2_options( $a['id'] )->update( $a['field_id'], $a['value'], false, $a['single'] ); |
|
334 | + if ( 'options-page' === $a[ 'type' ] || empty( $a[ 'id' ] ) ) { |
|
335 | + return cmb2_options( $a[ 'id' ] )->update( $a[ 'field_id' ], $a[ 'value' ], false, $a[ 'single' ] ); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | // Add metadata if not single |
339 | - if ( ! $a['single'] ) { |
|
340 | - return add_metadata( $a['type'], $a['id'], $a['field_id'], $a['value'], false ); |
|
339 | + if ( ! $a[ 'single' ] ) { |
|
340 | + return add_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $a[ 'value' ], false ); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | // Delete meta if we have an empty array |
344 | - if ( is_array( $a['value'] ) && empty( $a['value'] ) ) { |
|
345 | - return delete_metadata( $a['type'], $a['id'], $a['field_id'], $this->value ); |
|
344 | + if ( is_array( $a[ 'value' ] ) && empty( $a[ 'value' ] ) ) { |
|
345 | + return delete_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $this->value ); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | // Update metadata |
349 | - return update_metadata( $a['type'], $a['id'], $a['field_id'], $a['value'] ); |
|
349 | + return update_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $a[ 'value' ] ); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | /** |
@@ -396,19 +396,19 @@ discard block |
||
396 | 396 | * @param array $field_args All field arguments |
397 | 397 | * @param CMB2_Field object $field This field object |
398 | 398 | */ |
399 | - $override = apply_filters( "cmb2_override_{$a['field_id']}_meta_remove", $override, $a, $this->args(), $this ); |
|
399 | + $override = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_remove", $override, $a, $this->args(), $this ); |
|
400 | 400 | |
401 | 401 | // If no override, remove as usual |
402 | 402 | if ( null !== $override ) { |
403 | 403 | return $override; |
404 | 404 | } |
405 | 405 | // Option page handling |
406 | - elseif ( 'options-page' === $a['type'] || empty( $a['id'] ) ) { |
|
407 | - return cmb2_options( $a['id'] )->remove( $a['field_id'] ); |
|
406 | + elseif ( 'options-page' === $a[ 'type' ] || empty( $a[ 'id' ] ) ) { |
|
407 | + return cmb2_options( $a[ 'id' ] )->remove( $a[ 'field_id' ] ); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | // Remove metadata |
411 | - return delete_metadata( $a['type'], $a['id'], $a['field_id'], $old ); |
|
411 | + return delete_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $old ); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | /** |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | |
860 | 860 | foreach ( $conditional_classes as $class => $condition ) { |
861 | 861 | if ( $condition ) { |
862 | - $classes[] = $class; |
|
862 | + $classes[ ] = $class; |
|
863 | 863 | } |
864 | 864 | } |
865 | 865 | |
@@ -870,7 +870,7 @@ discard block |
||
870 | 870 | } |
871 | 871 | |
872 | 872 | if ( $added_classes ) { |
873 | - $classes[] = esc_attr( $added_classes ); |
|
873 | + $classes[ ] = esc_attr( $added_classes ); |
|
874 | 874 | } |
875 | 875 | |
876 | 876 | /** |
@@ -970,10 +970,10 @@ discard block |
||
970 | 970 | public function get_string( $text_key, $fallback ) { |
971 | 971 | // If null, populate with our field strings values. |
972 | 972 | if ( null === $this->strings ) { |
973 | - $this->strings = (array) $this->args['text']; |
|
973 | + $this->strings = (array) $this->args[ 'text' ]; |
|
974 | 974 | |
975 | - if ( is_callable( $this->args['text_cb'] ) ) { |
|
976 | - $strings = call_user_func( $this->args['text_cb'], $this ); |
|
975 | + if ( is_callable( $this->args[ 'text_cb' ] ) ) { |
|
976 | + $strings = call_user_func( $this->args[ 'text_cb' ], $this ); |
|
977 | 977 | |
978 | 978 | if ( $strings && is_array( $strings ) ) { |
979 | 979 | $this->strings += $strings; |
@@ -1007,10 +1007,10 @@ discard block |
||
1007 | 1007 | return $this->field_options; |
1008 | 1008 | } |
1009 | 1009 | |
1010 | - $this->field_options = (array) $this->args['options']; |
|
1010 | + $this->field_options = (array) $this->args[ 'options' ]; |
|
1011 | 1011 | |
1012 | - if ( is_callable( $this->args['options_cb'] ) ) { |
|
1013 | - $options = call_user_func( $this->args['options_cb'], $this ); |
|
1012 | + if ( is_callable( $this->args[ 'options_cb' ] ) ) { |
|
1013 | + $options = call_user_func( $this->args[ 'options_cb' ], $this ); |
|
1014 | 1014 | |
1015 | 1015 | if ( $options && is_array( $options ) ) { |
1016 | 1016 | $this->field_options = $options + $this->field_options; |
@@ -1031,7 +1031,7 @@ discard block |
||
1031 | 1031 | */ |
1032 | 1032 | public function add_js_dependencies( $dependencies = array() ) { |
1033 | 1033 | foreach ( (array) $dependencies as $dependency ) { |
1034 | - $this->args['js_dependencies'][ $dependency ] = $dependency; |
|
1034 | + $this->args[ 'js_dependencies' ][ $dependency ] = $dependency; |
|
1035 | 1035 | } |
1036 | 1036 | |
1037 | 1037 | CMB2_JS::add_dependencies( $dependencies ); |
@@ -1045,17 +1045,17 @@ discard block |
||
1045 | 1045 | * @return mixed Default field value |
1046 | 1046 | */ |
1047 | 1047 | public function get_default() { |
1048 | - if ( null !== $this->args['default'] ) { |
|
1049 | - return $this->args['default']; |
|
1048 | + if ( null !== $this->args[ 'default' ] ) { |
|
1049 | + return $this->args[ 'default' ]; |
|
1050 | 1050 | } |
1051 | 1051 | |
1052 | - $param = is_callable( $this->args['default_cb'] ) ? 'default_cb' : 'default'; |
|
1052 | + $param = is_callable( $this->args[ 'default_cb' ] ) ? 'default_cb' : 'default'; |
|
1053 | 1053 | $default = $this->get_param_callback_result( $param ); |
1054 | 1054 | |
1055 | 1055 | // Allow a filter override of the default value |
1056 | - $this->args['default'] = apply_filters( 'cmb2_default_filter', $default, $this ); |
|
1056 | + $this->args[ 'default' ] = apply_filters( 'cmb2_default_filter', $default, $this ); |
|
1057 | 1057 | |
1058 | - return $this->args['default']; |
|
1058 | + return $this->args[ 'default' ]; |
|
1059 | 1059 | } |
1060 | 1060 | |
1061 | 1061 | /** |
@@ -1085,18 +1085,18 @@ discard block |
||
1085 | 1085 | 'classes_cb' => '', |
1086 | 1086 | 'select_all_button' => true, |
1087 | 1087 | 'multiple' => false, |
1088 | - 'repeatable' => isset( $args['type'] ) && 'group' == $args['type'], |
|
1088 | + 'repeatable' => isset( $args[ 'type' ] ) && 'group' == $args[ 'type' ], |
|
1089 | 1089 | 'inline' => false, |
1090 | 1090 | 'on_front' => true, |
1091 | 1091 | 'show_names' => true, |
1092 | 1092 | 'save_field' => true, // Will not save if false |
1093 | 1093 | 'date_format' => 'm\/d\/Y', |
1094 | 1094 | 'time_format' => 'h:i A', |
1095 | - 'description' => isset( $args['desc'] ) ? $args['desc'] : '', |
|
1096 | - 'preview_size' => 'file' == $args['type'] ? array( 350, 350 ) : array( 50, 50 ), |
|
1095 | + 'description' => isset( $args[ 'desc' ] ) ? $args[ 'desc' ] : '', |
|
1096 | + 'preview_size' => 'file' == $args[ 'type' ] ? array( 350, 350 ) : array( 50, 50 ), |
|
1097 | 1097 | 'render_row_cb' => array( $this, 'render_field_callback' ), |
1098 | 1098 | 'display_cb' => array( $this, 'display_value_callback' ), |
1099 | - 'label_cb' => 'title' != $args['type'] ? array( $this, 'label' ) : '', |
|
1099 | + 'label_cb' => 'title' != $args[ 'type' ] ? array( $this, 'label' ) : '', |
|
1100 | 1100 | 'column' => false, |
1101 | 1101 | 'js_dependencies' => array(), |
1102 | 1102 | 'show_in_rest' => null, |
@@ -1111,44 +1111,44 @@ discard block |
||
1111 | 1111 | */ |
1112 | 1112 | $args = $this->convert_deprecated_params( $args ); |
1113 | 1113 | |
1114 | - $args['repeatable'] = $args['repeatable'] && ! $this->repeatable_exception( $args['type'] ); |
|
1115 | - $args['inline'] = $args['inline'] || false !== stripos( $args['type'], '_inline' ); |
|
1114 | + $args[ 'repeatable' ] = $args[ 'repeatable' ] && ! $this->repeatable_exception( $args[ 'type' ] ); |
|
1115 | + $args[ 'inline' ] = $args[ 'inline' ] || false !== stripos( $args[ 'type' ], '_inline' ); |
|
1116 | 1116 | |
1117 | - $args['options'] = 'group' == $args['type'] ? wp_parse_args( $args['options'], array( |
|
1117 | + $args[ 'options' ] = 'group' == $args[ 'type' ] ? wp_parse_args( $args[ 'options' ], array( |
|
1118 | 1118 | 'add_button' => esc_html__( 'Add Group', 'cmb2' ), |
1119 | 1119 | 'remove_button' => esc_html__( 'Remove Group', 'cmb2' ), |
1120 | - ) ) : $args['options']; |
|
1120 | + ) ) : $args[ 'options' ]; |
|
1121 | 1121 | |
1122 | - $args['_id'] = $args['id']; |
|
1123 | - $args['_name'] = $args['id']; |
|
1122 | + $args[ '_id' ] = $args[ 'id' ]; |
|
1123 | + $args[ '_name' ] = $args[ 'id' ]; |
|
1124 | 1124 | |
1125 | 1125 | if ( $this->group ) { |
1126 | 1126 | |
1127 | - $args['id'] = $this->group->args( 'id' ) . '_' . $this->group->index . '_' . $args['id']; |
|
1128 | - $args['_name'] = $this->group->args( 'id' ) . '[' . $this->group->index . '][' . $args['_name'] . ']'; |
|
1127 | + $args[ 'id' ] = $this->group->args( 'id' ) . '_' . $this->group->index . '_' . $args[ 'id' ]; |
|
1128 | + $args[ '_name' ] = $this->group->args( 'id' ) . '[' . $this->group->index . '][' . $args[ '_name' ] . ']'; |
|
1129 | 1129 | } |
1130 | 1130 | |
1131 | - if ( 'wysiwyg' == $args['type'] ) { |
|
1132 | - $args['id'] = strtolower( str_ireplace( '-', '_', $args['id'] ) ); |
|
1133 | - $args['options']['textarea_name'] = $args['_name']; |
|
1131 | + if ( 'wysiwyg' == $args[ 'type' ] ) { |
|
1132 | + $args[ 'id' ] = strtolower( str_ireplace( '-', '_', $args[ 'id' ] ) ); |
|
1133 | + $args[ 'options' ][ 'textarea_name' ] = $args[ '_name' ]; |
|
1134 | 1134 | } |
1135 | 1135 | |
1136 | 1136 | $option_types = apply_filters( 'cmb2_all_or_nothing_types', array( 'select', 'radio', 'radio_inline', 'taxonomy_select', 'taxonomy_radio', 'taxonomy_radio_inline' ), $this ); |
1137 | 1137 | |
1138 | - if ( in_array( $args['type'], $option_types, true ) ) { |
|
1138 | + if ( in_array( $args[ 'type' ], $option_types, true ) ) { |
|
1139 | 1139 | |
1140 | - $args['show_option_none'] = isset( $args['show_option_none'] ) ? $args['show_option_none'] : null; |
|
1141 | - $args['show_option_none'] = true === $args['show_option_none'] ? esc_html__( 'None', 'cmb2' ) : $args['show_option_none']; |
|
1140 | + $args[ 'show_option_none' ] = isset( $args[ 'show_option_none' ] ) ? $args[ 'show_option_none' ] : null; |
|
1141 | + $args[ 'show_option_none' ] = true === $args[ 'show_option_none' ] ? esc_html__( 'None', 'cmb2' ) : $args[ 'show_option_none' ]; |
|
1142 | 1142 | |
1143 | - if ( null === $args['show_option_none'] ) { |
|
1144 | - $off_by_default = in_array( $args['type'], array( 'select', 'radio', 'radio_inline' ), true ); |
|
1145 | - $args['show_option_none'] = $off_by_default ? false : esc_html__( 'None', 'cmb2' ); |
|
1143 | + if ( null === $args[ 'show_option_none' ] ) { |
|
1144 | + $off_by_default = in_array( $args[ 'type' ], array( 'select', 'radio', 'radio_inline' ), true ); |
|
1145 | + $args[ 'show_option_none' ] = $off_by_default ? false : esc_html__( 'None', 'cmb2' ); |
|
1146 | 1146 | } |
1147 | 1147 | |
1148 | 1148 | } |
1149 | 1149 | |
1150 | - $args['has_supporting_data'] = in_array( |
|
1151 | - $args['type'], |
|
1150 | + $args[ 'has_supporting_data' ] = in_array( |
|
1151 | + $args[ 'type' ], |
|
1152 | 1152 | array( |
1153 | 1153 | // CMB2_Sanitize::_save_file_id_value()/CMB2_Sanitize::_get_group_file_value_array() |
1154 | 1154 | 'file', |
@@ -1171,10 +1171,10 @@ discard block |
||
1171 | 1171 | protected function get_default_args( $field_args, $field_group = null ) { |
1172 | 1172 | $args = parent::get_default_args( array(), $this->group ); |
1173 | 1173 | |
1174 | - if ( isset( $field_args['field_args'] ) ) { |
|
1174 | + if ( isset( $field_args[ 'field_args' ] ) ) { |
|
1175 | 1175 | $args = wp_parse_args( $field_args, $args ); |
1176 | 1176 | } else { |
1177 | - $args['field_args'] = wp_parse_args( $field_args, $this->args ); |
|
1177 | + $args[ 'field_args' ] = wp_parse_args( $field_args, $this->args ); |
|
1178 | 1178 | } |
1179 | 1179 | |
1180 | 1180 | return $args; |
@@ -1217,43 +1217,43 @@ discard block |
||
1217 | 1217 | */ |
1218 | 1218 | protected function convert_deprecated_params( $args ) { |
1219 | 1219 | |
1220 | - if ( isset( $args['row_classes'] ) ) { |
|
1220 | + if ( isset( $args[ 'row_classes' ] ) ) { |
|
1221 | 1221 | |
1222 | 1222 | // We'll let this one be. |
1223 | 1223 | // $this->deprecated_param( __CLASS__ . '::__construct()', '2.2.3', self::DEPRECATED_PARAM, 'row_classes', 'classes' ); |
1224 | 1224 | |
1225 | 1225 | // row_classes param could be a callback. This is definitely deprecated. |
1226 | - if ( is_callable( $args['row_classes'] ) ) { |
|
1226 | + if ( is_callable( $args[ 'row_classes' ] ) ) { |
|
1227 | 1227 | |
1228 | 1228 | $this->deprecated_param( __CLASS__ . '::__construct()', '2.2.3', self::DEPRECATED_CB_PARAM, 'row_classes', 'classes_cb' ); |
1229 | 1229 | |
1230 | - $args['classes_cb'] = $args['row_classes']; |
|
1231 | - $args['classes'] = null; |
|
1230 | + $args[ 'classes_cb' ] = $args[ 'row_classes' ]; |
|
1231 | + $args[ 'classes' ] = null; |
|
1232 | 1232 | } else { |
1233 | 1233 | |
1234 | - $args['classes'] = $args['row_classes']; |
|
1234 | + $args[ 'classes' ] = $args[ 'row_classes' ]; |
|
1235 | 1235 | } |
1236 | 1236 | |
1237 | - unset( $args['row_classes'] ); |
|
1237 | + unset( $args[ 'row_classes' ] ); |
|
1238 | 1238 | } |
1239 | 1239 | |
1240 | 1240 | |
1241 | 1241 | // default param can be passed a callback as well |
1242 | - if ( is_callable( $args['default'] ) ) { |
|
1242 | + if ( is_callable( $args[ 'default' ] ) ) { |
|
1243 | 1243 | |
1244 | 1244 | $this->deprecated_param( __CLASS__ . '::__construct()', '2.2.3', self::DEPRECATED_CB_PARAM, 'default', 'default_cb' ); |
1245 | 1245 | |
1246 | - $args['default_cb'] = $args['default']; |
|
1247 | - $args['default'] = null; |
|
1246 | + $args[ 'default_cb' ] = $args[ 'default' ]; |
|
1247 | + $args[ 'default' ] = null; |
|
1248 | 1248 | } |
1249 | 1249 | |
1250 | 1250 | // options param can be passed a callback as well |
1251 | - if ( is_callable( $args['options'] ) ) { |
|
1251 | + if ( is_callable( $args[ 'options' ] ) ) { |
|
1252 | 1252 | |
1253 | 1253 | $this->deprecated_param( __CLASS__ . '::__construct()', '2.2.3', self::DEPRECATED_CB_PARAM, 'options', 'options_cb' ); |
1254 | 1254 | |
1255 | - $args['options_cb'] = $args['options']; |
|
1256 | - $args['options'] = array(); |
|
1255 | + $args[ 'options_cb' ] = $args[ 'options' ]; |
|
1256 | + $args[ 'options' ] = array(); |
|
1257 | 1257 | } |
1258 | 1258 | |
1259 | 1259 | return $args; |
@@ -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 | } |
@@ -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++; |