@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $cmb_demo = new_cmb2_box( array( |
116 | 116 | 'id' => $prefix . 'metabox', |
117 | 117 | 'title' => esc_html__( 'Test Metabox', 'cmb2' ), |
118 | - 'object_types' => array( 'page', ), // Post type |
|
118 | + 'object_types' => array( 'page',), // Post type |
|
119 | 119 | // 'show_on_cb' => 'yourprefix_show_if_front_page', // function should return a bool value |
120 | 120 | // 'context' => 'normal', |
121 | 121 | // 'priority' => 'high', |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | 'desc' => esc_html__( 'field description (optional)', 'cmb2' ), |
386 | 386 | 'id' => $prefix . 'wysiwyg', |
387 | 387 | 'type' => 'wysiwyg', |
388 | - 'options' => array( 'textarea_rows' => 5, ), |
|
388 | + 'options' => array( 'textarea_rows' => 5,), |
|
389 | 389 | ) ); |
390 | 390 | |
391 | 391 | $cmb_demo->add_field( array( |
@@ -441,11 +441,11 @@ discard block |
||
441 | 441 | $cmb_about_page = new_cmb2_box( array( |
442 | 442 | 'id' => $prefix . 'metabox', |
443 | 443 | 'title' => esc_html__( 'About Page Metabox', 'cmb2' ), |
444 | - 'object_types' => array( 'page', ), // Post type |
|
444 | + 'object_types' => array( 'page',), // Post type |
|
445 | 445 | 'context' => 'normal', |
446 | 446 | 'priority' => 'high', |
447 | 447 | 'show_names' => true, // Show field names on the left |
448 | - 'show_on' => array( 'id' => array( 2, ) ), // Specific post IDs to display this metabox |
|
448 | + 'show_on' => array( 'id' => array( 2,) ), // Specific post IDs to display this metabox |
|
449 | 449 | ) ); |
450 | 450 | |
451 | 451 | $cmb_about_page->add_field( array( |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | $cmb_group = new_cmb2_box( array( |
471 | 471 | 'id' => $prefix . 'metabox', |
472 | 472 | 'title' => esc_html__( 'Repeating Field Group', 'cmb2' ), |
473 | - 'object_types' => array( 'page', ), |
|
473 | + 'object_types' => array( 'page',), |
|
474 | 474 | ) ); |
475 | 475 | |
476 | 476 | // $group_field_id is the field id string, so in this case: $prefix . 'demo' |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | $cmb_rest = new_cmb2_box( array( |
700 | 700 | 'id' => $prefix . 'metabox', |
701 | 701 | 'title' => esc_html__( 'REST Test Box', 'cmb2' ), |
702 | - 'object_types' => array( 'page', ), // Post type |
|
702 | + 'object_types' => array( 'page',), // Post type |
|
703 | 703 | 'show_in_rest' => WP_REST_Server::ALLMETHODS, // WP_REST_Server::READABLE|WP_REST_Server::EDITABLE, // Determines which HTTP methods the box is visible in. |
704 | 704 | // Optional callback to limit box visibility. |
705 | 705 | // See: https://github.com/WebDevStudios/CMB2/wiki/REST-API#permissions |
@@ -15,9 +15,9 @@ discard block |
||
15 | 15 | * Get the bootstrap! If using the plugin from wordpress.org, REMOVE THIS! |
16 | 16 | */ |
17 | 17 | |
18 | -if ( file_exists( dirname( __FILE__ ) . '/cmb2/init.php' ) ) { |
|
18 | +if ( file_exists( dirname( __FILE__ ) . '/cmb2/init.php' ) ) { |
|
19 | 19 | require_once dirname( __FILE__ ) . '/cmb2/init.php'; |
20 | -} elseif ( file_exists( dirname( __FILE__ ) . '/CMB2/init.php' ) ) { |
|
20 | +} elseif ( file_exists( dirname( __FILE__ ) . '/CMB2/init.php' ) ) { |
|
21 | 21 | require_once dirname( __FILE__ ) . '/CMB2/init.php'; |
22 | 22 | } |
23 | 23 | |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return bool True if metabox should show |
30 | 30 | */ |
31 | -function yourprefix_show_if_front_page( $cmb ) { |
|
31 | +function yourprefix_show_if_front_page( $cmb ) { |
|
32 | 32 | // Don't show this metabox if it's not the front page template. |
33 | - if ( get_option( 'page_on_front' ) !== $cmb->object_id ) { |
|
33 | + if ( get_option( 'page_on_front' ) !== $cmb->object_id ) { |
|
34 | 34 | return false; |
35 | 35 | } |
36 | 36 | return true; |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return bool True if metabox should show |
45 | 45 | */ |
46 | -function yourprefix_hide_if_no_cats( $field ) { |
|
46 | +function yourprefix_hide_if_no_cats( $field ) { |
|
47 | 47 | // Don't show this field if not in the cats category. |
48 | - if ( ! has_tag( 'cats', $field->object_id ) ) { |
|
48 | + if ( ! has_tag( 'cats', $field->object_id ) ) { |
|
49 | 49 | return false; |
50 | 50 | } |
51 | 51 | return true; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param array $field_args Array of field arguments. |
58 | 58 | * @param CMB2_Field $field The field object. |
59 | 59 | */ |
60 | -function yourprefix_render_row_cb( $field_args, $field ) { |
|
60 | +function yourprefix_render_row_cb( $field_args, $field ) { |
|
61 | 61 | $classes = $field->row_classes(); |
62 | 62 | $id = $field->args( 'id' ); |
63 | 63 | $label = $field->args( 'name' ); |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @param array $field_args Array of field arguments. |
80 | 80 | * @param CMB2_Field $field The field object. |
81 | 81 | */ |
82 | -function yourprefix_display_text_small_column( $field_args, $field ) { |
|
82 | +function yourprefix_display_text_small_column( $field_args, $field ) { |
|
83 | 83 | ?> |
84 | 84 | <div class="custom-column-display <?php echo esc_attr( $field->row_classes() ); ?>"> |
85 | 85 | <p><?php echo $field->escaped_value(); ?></p> |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | * @param array $field_args Array of field parameters. |
95 | 95 | * @param CMB2_Field object $field Field object. |
96 | 96 | */ |
97 | -function yourprefix_before_row_if_2( $field_args, $field ) { |
|
98 | - if ( 2 == $field->object_id ) { |
|
97 | +function yourprefix_before_row_if_2( $field_args, $field ) { |
|
98 | + if ( 2 == $field->object_id ) { |
|
99 | 99 | echo '<p>Testing <b>"before_row"</b> parameter (on $post_id 2)</p>'; |
100 | - } else { |
|
100 | + } else { |
|
101 | 101 | echo '<p>Testing <b>"before_row"</b> parameter (<b>NOT</b> on $post_id 2)</p>'; |
102 | 102 | } |
103 | 103 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | /** |
107 | 107 | * Hook in and add a demo metabox. Can only happen on the 'cmb2_admin_init' or 'cmb2_init' hook. |
108 | 108 | */ |
109 | -function yourprefix_register_demo_metabox() { |
|
109 | +function yourprefix_register_demo_metabox() { |
|
110 | 110 | $prefix = 'yourprefix_demo_'; |
111 | 111 | |
112 | 112 | /** |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | /** |
433 | 433 | * Hook in and add a metabox that only appears on the 'About' page |
434 | 434 | */ |
435 | -function yourprefix_register_about_page_metabox() { |
|
435 | +function yourprefix_register_about_page_metabox() { |
|
436 | 436 | $prefix = 'yourprefix_about_'; |
437 | 437 | |
438 | 438 | /** |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | /** |
462 | 462 | * Hook in and add a metabox to demonstrate repeatable grouped fields |
463 | 463 | */ |
464 | -function yourprefix_register_repeatable_group_field_metabox() { |
|
464 | +function yourprefix_register_repeatable_group_field_metabox() { |
|
465 | 465 | $prefix = 'yourprefix_group_'; |
466 | 466 | |
467 | 467 | /** |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | /** |
526 | 526 | * Hook in and add a metabox to add fields to the user profile pages |
527 | 527 | */ |
528 | -function yourprefix_register_user_profile_metabox() { |
|
528 | +function yourprefix_register_user_profile_metabox() { |
|
529 | 529 | $prefix = 'yourprefix_user_'; |
530 | 530 | |
531 | 531 | /** |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | /** |
596 | 596 | * Hook in and add a metabox to add fields to taxonomy terms |
597 | 597 | */ |
598 | -function yourprefix_register_taxonomy_metabox() { |
|
598 | +function yourprefix_register_taxonomy_metabox() { |
|
599 | 599 | $prefix = 'yourprefix_term_'; |
600 | 600 | |
601 | 601 | /** |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | /** |
638 | 638 | * Hook in and register a metabox to handle a theme options page |
639 | 639 | */ |
640 | -function yourprefix_register_theme_options_metabox() { |
|
640 | +function yourprefix_register_theme_options_metabox() { |
|
641 | 641 | |
642 | 642 | $option_key = 'yourprefix_theme_options'; |
643 | 643 | |
@@ -680,8 +680,8 @@ discard block |
||
680 | 680 | * |
681 | 681 | * @return bool Whether this box and its fields are allowed to be viewed. |
682 | 682 | */ |
683 | -function yourprefix_limit_rest_view_to_logged_in_users( $is_allowed, $cmb_controller ) { |
|
684 | - if ( ! is_user_logged_in() ) { |
|
683 | +function yourprefix_limit_rest_view_to_logged_in_users( $is_allowed, $cmb_controller ) { |
|
684 | + if ( ! is_user_logged_in() ) { |
|
685 | 685 | $is_allowed = false; |
686 | 686 | } |
687 | 687 | |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | * Hook in and add a box to be available in the CMB2 REST API. Can only happen on the 'cmb2_init' hook. |
694 | 694 | * More info: https://github.com/WebDevStudios/CMB2/wiki/REST-API |
695 | 695 | */ |
696 | -function yourprefix_register_rest_api_box() { |
|
696 | +function yourprefix_register_rest_api_box() { |
|
697 | 697 | $prefix = 'yourprefix_rest_'; |
698 | 698 | |
699 | 699 | $cmb_rest = new_cmb2_box( array( |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | if ( ! $terms ) { |
25 | 25 | $options .= sprintf( '<li><label>%s</label></li>', esc_html( $this->_text( 'no_terms_text', esc_html__( 'No terms', 'cmb2' ) ) ) ); |
26 | 26 | } else { |
27 | - $option_none = $field->args( 'show_option_none' ); |
|
27 | + $option_none = $field->args( 'show_option_none' ); |
|
28 | 28 | if ( ! empty( $option_none ) ) { |
29 | 29 | |
30 | 30 | $field_id = $this->_id(); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | 'label' => $option_none, |
55 | 55 | ); |
56 | 56 | if ( $saved_term == $option_none_value ) { |
57 | - $args['checked'] = 'checked'; |
|
57 | + $args[ 'checked' ] = 'checked'; |
|
58 | 58 | } |
59 | 59 | $options .= $this->list_input( $args, $i ); |
60 | 60 | $i++; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | ); |
68 | 68 | |
69 | 69 | if ( $saved_term == $term->slug ) { |
70 | - $args['checked'] = 'checked'; |
|
70 | + $args[ 'checked' ] = 'checked'; |
|
71 | 71 | } |
72 | 72 | $options .= $this->list_input( $args, $i ); |
73 | 73 | $i++; |
@@ -547,7 +547,7 @@ |
||
547 | 547 | * @since 2.2.3 |
548 | 548 | * |
549 | 549 | * @param mixed $value Value to ensure is array. |
550 | - * @param array $default Default array. Defaults to empty array. |
|
550 | + * @param string[] $default Default array. Defaults to empty array. |
|
551 | 551 | * |
552 | 552 | * @return array The array. |
553 | 553 | */ |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $dir = wp_upload_dir(); |
41 | 41 | |
42 | 42 | // Is URL in uploads directory? |
43 | - if ( false === strpos( $img_url, $dir['baseurl'] . '/' ) ) { |
|
43 | + if ( false === strpos( $img_url, $dir[ 'baseurl' ] . '/' ) ) { |
|
44 | 44 | return false; |
45 | 45 | } |
46 | 46 | |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | |
66 | 66 | foreach ( $query->posts as $post_id ) { |
67 | 67 | $meta = wp_get_attachment_metadata( $post_id ); |
68 | - $original_file = basename( $meta['file'] ); |
|
69 | - $cropped_image_files = isset( $meta['sizes'] ) ? wp_list_pluck( $meta['sizes'], 'file' ) : array(); |
|
68 | + $original_file = basename( $meta[ 'file' ] ); |
|
69 | + $cropped_image_files = isset( $meta[ 'sizes' ] ) ? wp_list_pluck( $meta[ 'sizes' ], 'file' ) : array(); |
|
70 | 70 | if ( $original_file === $file || in_array( $file, $cropped_image_files ) ) { |
71 | 71 | $attachment_id = $post_id; |
72 | 72 | break; |
@@ -128,31 +128,31 @@ discard block |
||
128 | 128 | foreach ( $image_sizes as $_size => $data ) { |
129 | 129 | |
130 | 130 | // If there's an exact match to an existing image size, short circuit. |
131 | - if ( $data['width'] == $size[0] && $data['height'] == $size[1] ) { |
|
132 | - $candidates[ $data['width'] * $data['height'] ] = array( $_size, $data ); |
|
131 | + if ( $data[ 'width' ] == $size[ 0 ] && $data[ 'height' ] == $size[ 1 ] ) { |
|
132 | + $candidates[ $data[ 'width' ] * $data[ 'height' ] ] = array( $_size, $data ); |
|
133 | 133 | break; |
134 | 134 | } |
135 | 135 | |
136 | 136 | // If it's not an exact match, consider larger sizes with the same aspect ratio. |
137 | - if ( $data['width'] >= $size[0] && $data['height'] >= $size[1] ) { |
|
137 | + if ( $data[ 'width' ] >= $size[ 0 ] && $data[ 'height' ] >= $size[ 1 ] ) { |
|
138 | 138 | |
139 | 139 | /* |
140 | 140 | * To test for varying crops, we constrain the dimensions of the larger image |
141 | 141 | * to the dimensions of the smaller image and see if they match. |
142 | 142 | */ |
143 | - if ( $data['width'] > $size[0] ) { |
|
144 | - $constrained_size = wp_constrain_dimensions( $data['width'], $data['height'], $size[0] ); |
|
145 | - $expected_size = array( $size[0], $size[1] ); |
|
143 | + if ( $data[ 'width' ] > $size[ 0 ] ) { |
|
144 | + $constrained_size = wp_constrain_dimensions( $data[ 'width' ], $data[ 'height' ], $size[ 0 ] ); |
|
145 | + $expected_size = array( $size[ 0 ], $size[ 1 ] ); |
|
146 | 146 | } else { |
147 | - $constrained_size = wp_constrain_dimensions( $size[0], $size[1], $data['width'] ); |
|
148 | - $expected_size = array( $data['width'], $data['height'] ); |
|
147 | + $constrained_size = wp_constrain_dimensions( $size[ 0 ], $size[ 1 ], $data[ 'width' ] ); |
|
148 | + $expected_size = array( $data[ 'width' ], $data[ 'height' ] ); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | // If the image dimensions are within 1px of the expected size, we consider it a match. |
152 | - $matched = ( abs( $constrained_size[0] - $expected_size[0] ) <= 1 && abs( $constrained_size[1] - $expected_size[1] ) <= 1 ); |
|
152 | + $matched = ( abs( $constrained_size[ 0 ] - $expected_size[ 0 ] ) <= 1 && abs( $constrained_size[ 1 ] - $expected_size[ 1 ] ) <= 1 ); |
|
153 | 153 | |
154 | 154 | if ( $matched ) { |
155 | - $candidates[ $data['width'] * $data['height'] ] = array( $_size, $data ); |
|
155 | + $candidates[ $data[ 'width' ] * $data[ 'height' ] ] = array( $_size, $data ); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | } |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | } |
165 | 165 | |
166 | 166 | $data = array_shift( $candidates ); |
167 | - $data = $data[0]; |
|
168 | - } elseif ( ! empty( $image_sizes['thumbnail'] ) && $image_sizes['thumbnail']['width'] >= $size[0] && $image_sizes['thumbnail']['width'] >= $size[1] ) { |
|
167 | + $data = $data[ 0 ]; |
|
168 | + } elseif ( ! empty( $image_sizes[ 'thumbnail' ] ) && $image_sizes[ 'thumbnail' ][ 'width' ] >= $size[ 0 ] && $image_sizes[ 'thumbnail' ][ 'width' ] >= $size[ 1 ] ) { |
|
169 | 169 | /* |
170 | 170 | * When the size requested is smaller than the thumbnail dimensions, we |
171 | 171 | * fall back to the thumbnail size. |
@@ -260,8 +260,7 @@ discard block |
||
260 | 260 | } |
261 | 261 | |
262 | 262 | return self::is_valid_time_stamp( $string ) |
263 | - ? (int) $string : |
|
264 | - strtotime( (string) $string ); |
|
263 | + ? (int) $string : strtotime( (string) $string ); |
|
265 | 264 | } |
266 | 265 | |
267 | 266 | /** |
@@ -457,25 +456,25 @@ discard block |
||
457 | 456 | |
458 | 457 | // order is relevant here, since the replacement will be done sequentially. |
459 | 458 | $supported_options = array( |
460 | - 'd' => 'dd', // Day, leading 0 |
|
461 | - 'j' => 'd', // Day, no 0 |
|
462 | - 'z' => 'o', // Day of the year, no leading zeroes, |
|
459 | + 'd' => 'dd', // Day, leading 0 |
|
460 | + 'j' => 'd', // Day, no 0 |
|
461 | + 'z' => 'o', // Day of the year, no leading zeroes, |
|
463 | 462 | // 'D' => 'D', // Day name short, not sure how it'll work with translations |
464 | 463 | // 'l' => 'DD', // Day name full, idem before |
465 | - 'm' => 'mm', // Month of the year, leading 0 |
|
466 | - 'n' => 'm', // Month of the year, no leading 0 |
|
464 | + 'm' => 'mm', // Month of the year, leading 0 |
|
465 | + 'n' => 'm', // Month of the year, no leading 0 |
|
467 | 466 | // 'M' => 'M', // Month, Short name |
468 | 467 | // 'F' => 'MM', // Month, full name, |
469 | - 'y' => 'y', // Year, two digit |
|
470 | - 'Y' => 'yy', // Year, full |
|
471 | - 'H' => 'HH', // Hour with leading 0 (24 hour) |
|
472 | - 'G' => 'H', // Hour with no leading 0 (24 hour) |
|
473 | - 'h' => 'hh', // Hour with leading 0 (12 hour) |
|
474 | - 'g' => 'h', // Hour with no leading 0 (12 hour), |
|
475 | - 'i' => 'mm', // Minute with leading 0, |
|
476 | - 's' => 'ss', // Second with leading 0, |
|
477 | - 'a' => 'tt', // am/pm |
|
478 | - 'A' => 'TT',// AM/PM |
|
468 | + 'y' => 'y', // Year, two digit |
|
469 | + 'Y' => 'yy', // Year, full |
|
470 | + 'H' => 'HH', // Hour with leading 0 (24 hour) |
|
471 | + 'G' => 'H', // Hour with no leading 0 (24 hour) |
|
472 | + 'h' => 'hh', // Hour with leading 0 (12 hour) |
|
473 | + 'g' => 'h', // Hour with no leading 0 (12 hour), |
|
474 | + 'i' => 'mm', // Minute with leading 0, |
|
475 | + 's' => 'ss', // Second with leading 0, |
|
476 | + 'a' => 'tt', // am/pm |
|
477 | + 'A' => 'TT', // AM/PM |
|
479 | 478 | ); |
480 | 479 | |
481 | 480 | foreach ( $supported_options as $php => $js ) { |
@@ -496,7 +495,7 @@ discard block |
||
496 | 495 | * @return string Modified value |
497 | 496 | */ |
498 | 497 | public static function wrap_escaped_chars( $value ) { |
499 | - return ''' . str_replace( '\\', '', $value[0] ) . '''; |
|
498 | + return ''' . str_replace( '\\', '', $value[ 0 ] ) . '''; |
|
500 | 499 | } |
501 | 500 | |
502 | 501 | /** |
@@ -559,7 +558,7 @@ discard block |
||
559 | 558 | * @return string String of attributes for form element. |
560 | 559 | */ |
561 | 560 | public static function concat_attrs( $attrs, $attr_exclude = array() ) { |
562 | - $attr_exclude[] = 'rendered'; |
|
561 | + $attr_exclude[ ] = 'rendered'; |
|
563 | 562 | $attributes = ''; |
564 | 563 | foreach ( $attrs as $attr => $val ) { |
565 | 564 | $excluded = in_array( $attr, (array) $attr_exclude, true ); |
@@ -234,7 +234,8 @@ |
||
234 | 234 | $tzstring = ''; |
235 | 235 | } |
236 | 236 | |
237 | - if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists |
|
237 | + if ( empty( $tzstring ) ) { |
|
238 | +// Create a UTC+- zone if no timezone string exists |
|
238 | 239 | if ( 0 == $current_offset ) { |
239 | 240 | $tzstring = 'UTC+0'; |
240 | 241 | } elseif ( $current_offset < 0 ) { |
@@ -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(); |
@@ -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 = '' ) { |
@@ -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++; |
@@ -24,15 +24,15 @@ discard block |
||
24 | 24 | $img_size_data = parent::get_image_size_data( $img_size, 'large' ); |
25 | 25 | |
26 | 26 | // if options array and 'url' => false, then hide the url field |
27 | - $input_type = array_key_exists( 'url', $options ) && false === $options['url'] ? 'hidden' : 'text'; |
|
27 | + $input_type = array_key_exists( 'url', $options ) && false === $options[ 'url' ] ? 'hidden' : 'text'; |
|
28 | 28 | |
29 | 29 | $output .= parent::render( array( |
30 | 30 | 'type' => $input_type, |
31 | 31 | 'class' => 'cmb2-upload-file regular-text', |
32 | 32 | 'size' => 45, |
33 | 33 | 'desc' => '', |
34 | - 'data-previewsize' => sprintf( '[%d,%d]', $img_size_data['width'], $img_size_data['height'] ), |
|
35 | - 'data-sizename' => $img_size_data['name'], |
|
34 | + 'data-previewsize' => sprintf( '[%d,%d]', $img_size_data[ 'width' ], $img_size_data[ 'height' ] ), |
|
35 | + 'data-sizename' => $img_size_data[ 'name' ], |
|
36 | 36 | 'data-queryargs' => ! empty( $query_args ) ? json_encode( $query_args ) : '', |
37 | 37 | 'js_dependencies' => 'media-editor', |
38 | 38 | ) ); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | if ( $_id_value ) { |
81 | 81 | $image = wp_get_attachment_image( $_id_value, $img_size, null, array( 'class' => 'cmb-file-field-image' ) ); |
82 | 82 | } else { |
83 | - $image = '<img style="max-width: ' . absint( $img_size_data['width'] ) . 'px; width: 100%;" src="' . $meta_value . '" class="cmb-file-field-image" alt="" />'; |
|
83 | + $image = '<img style="max-width: ' . absint( $img_size_data[ 'width' ] ) . 'px; width: 100%;" src="' . $meta_value . '" class="cmb-file-field-image" alt="" />'; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | $output .= $this->img_status_output( array( |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function img_status_output( $args ) { |
57 | 57 | return sprintf( '<%1$s class="img-status cmb2-media-item">%2$s<p class="cmb2-remove-wrapper"><a href="#" class="cmb2-remove-file-button"%3$s>%4$s</a></p>%5$s</%1$s>', |
58 | - $args['tag'], |
|
59 | - $args['image'], |
|
60 | - isset( $args['cached_id'] ) ? ' rel="' . $args['cached_id'] . '"' : '', |
|
58 | + $args[ 'tag' ], |
|
59 | + $args[ 'image' ], |
|
60 | + isset( $args[ 'cached_id' ] ) ? ' rel="' . $args[ 'cached_id' ] . '"' : '', |
|
61 | 61 | esc_html( $this->_text( 'remove_image_text', esc_html__( 'Remove Image', 'cmb2' ) ) ), |
62 | - isset( $args['id_input'] ) ? $args['id_input'] : '' |
|
62 | + isset( $args[ 'id_input' ] ) ? $args[ 'id_input' ] : '' |
|
63 | 63 | ); |
64 | 64 | } |
65 | 65 | |
@@ -71,14 +71,14 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function file_status_output( $args ) { |
73 | 73 | return sprintf( '<%1$s class="file-status cmb2-media-item"><span>%2$s <strong>%3$s</strong></span> (<a href="%4$s" target="_blank" rel="external">%5$s</a> / <a href="#" class="cmb2-remove-file-button"%6$s>%7$s</a>)%8$s</%1$s>', |
74 | - $args['tag'], |
|
74 | + $args[ 'tag' ], |
|
75 | 75 | esc_html( $this->_text( 'file_text', esc_html__( 'File:', 'cmb2' ) ) ), |
76 | - CMB2_Utils::get_file_name_from_path( $args['value'] ), |
|
77 | - $args['value'], |
|
76 | + CMB2_Utils::get_file_name_from_path( $args[ 'value' ] ), |
|
77 | + $args[ 'value' ], |
|
78 | 78 | esc_html( $this->_text( 'file_download_text', esc_html__( 'Download', 'cmb2' ) ) ), |
79 | - isset( $args['cached_id'] ) ? ' rel="' . $args['cached_id'] . '"' : '', |
|
79 | + isset( $args[ 'cached_id' ] ) ? ' rel="' . $args[ 'cached_id' ] . '"' : '', |
|
80 | 80 | esc_html( $this->_text( 'remove_text', esc_html__( 'Remove', 'cmb2' ) ) ), |
81 | - isset( $args['id_input'] ) ? $args['id_input'] : '' |
|
81 | + isset( $args[ 'id_input' ] ) ? $args[ 'id_input' ] : '' |
|
82 | 82 | ); |
83 | 83 | } |
84 | 84 | |
@@ -103,13 +103,13 @@ discard block |
||
103 | 103 | $data = array(); |
104 | 104 | |
105 | 105 | if ( is_array( $img_size ) ) { |
106 | - $data['width'] = intval( $img_size[0] ); |
|
107 | - $data['height'] = intval( $img_size[1] ); |
|
108 | - $data['name'] = ''; |
|
106 | + $data[ 'width' ] = intval( $img_size[ 0 ] ); |
|
107 | + $data[ 'height' ] = intval( $img_size[ 1 ] ); |
|
108 | + $data[ 'name' ] = ''; |
|
109 | 109 | |
110 | 110 | // Try and get the closest named size from our array of dimensions |
111 | 111 | if ( $named_size = CMB2_Utils::get_named_size( $img_size ) ) { |
112 | - $data['name'] = $named_size; |
|
112 | + $data[ 'name' ] = $named_size; |
|
113 | 113 | } |
114 | 114 | } else { |
115 | 115 | |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | } |
127 | 127 | |
128 | 128 | // Get image dimensions from named sizes |
129 | - $data['width'] = intval( $image_sizes[ $img_size ]['width'] ); |
|
130 | - $data['height'] = intval( $image_sizes[ $img_size ]['height'] ); |
|
131 | - $data['name'] = $img_size; |
|
129 | + $data[ 'width' ] = intval( $image_sizes[ $img_size ][ 'width' ] ); |
|
130 | + $data[ 'height' ] = intval( $image_sizes[ $img_size ][ 'height' ] ); |
|
131 | + $data[ 'name' ] = $img_size; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | return $data; |
@@ -150,17 +150,17 @@ discard block |
||
150 | 150 | foreach ( CMB2_Utils::get_available_image_sizes() as $size => $info ) { |
151 | 151 | |
152 | 152 | // registered image size exists for this attachment |
153 | - if ( isset( $meta['sizes'][ $size ] ) ) { |
|
153 | + if ( isset( $meta[ 'sizes' ][ $size ] ) ) { |
|
154 | 154 | |
155 | 155 | $attachment_url = wp_get_attachment_url( $attachment->ID ); |
156 | 156 | $base_url = str_replace( wp_basename( $attachment_url ), '', $attachment_url ); |
157 | - $size_meta = $meta['sizes'][ $size ]; |
|
157 | + $size_meta = $meta[ 'sizes' ][ $size ]; |
|
158 | 158 | |
159 | - $response['sizes'][ $size ] = array( |
|
160 | - 'url' => $base_url . $size_meta['file'], |
|
161 | - 'height' => $size_meta['height'], |
|
162 | - 'width' => $size_meta['width'], |
|
163 | - 'orientation' => $size_meta['height'] > $size_meta['width'] ? 'portrait' : 'landscape', |
|
159 | + $response[ 'sizes' ][ $size ] = array( |
|
160 | + 'url' => $base_url . $size_meta[ 'file' ], |
|
161 | + 'height' => $size_meta[ 'height' ], |
|
162 | + 'width' => $size_meta[ 'width' ], |
|
163 | + 'orientation' => $size_meta[ 'height' ] > $size_meta[ 'width' ] ? 'portrait' : 'landscape', |
|
164 | 164 | ); |
165 | 165 | } |
166 | 166 | } |
@@ -56,24 +56,24 @@ |
||
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 | CMB2_Type_File_Base::output_js_underscore_templates(); |
67 | 67 | } |
68 | 68 | |
69 | 69 | // if timepicker |
70 | - if ( isset( $dependencies['jquery-ui-datetimepicker'] ) ) { |
|
70 | + if ( isset( $dependencies[ 'jquery-ui-datetimepicker' ] ) ) { |
|
71 | 71 | wp_register_script( 'jquery-ui-datetimepicker', CMB2_Utils::url( 'js/jquery-ui-timepicker-addon.min.js' ), array( 'jquery-ui-slider' ), CMB2_VERSION ); |
72 | 72 | } |
73 | 73 | |
74 | 74 | // if cmb2-wysiwyg |
75 | - $enqueue_wysiwyg = isset( $dependencies['cmb2-wysiwyg'] ) && $debug; |
|
76 | - unset( $dependencies['cmb2-wysiwyg'] ); |
|
75 | + $enqueue_wysiwyg = isset( $dependencies[ 'cmb2-wysiwyg' ] ) && $debug; |
|
76 | + unset( $dependencies[ 'cmb2-wysiwyg' ] ); |
|
77 | 77 | |
78 | 78 | // Enqueue cmb JS |
79 | 79 | wp_enqueue_script( self::$handle, CMB2_Utils::url( "js/cmb2{$min}.js" ), $dependencies, CMB2_VERSION, true ); |