@@ -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++; |
@@ -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 ); |
@@ -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 ) { |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | 'single' => $single, |
| 307 | 307 | ) ); |
| 308 | 308 | |
| 309 | - $a['value'] = $a['repeat'] ? array_values( $new_value ) : $new_value; |
|
| 309 | + $a[ 'value' ] = $a[ 'repeat' ] ? array_values( $new_value ) : $new_value; |
|
| 310 | 310 | |
| 311 | 311 | /** |
| 312 | 312 | * Filter whether to override saving of meta value. |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | * |
| 343 | 343 | * @since 2.0.0 |
| 344 | 344 | */ |
| 345 | - $override = apply_filters( "cmb2_override_{$a['field_id']}_meta_save", $override, $a, $this->args(), $this ); |
|
| 345 | + $override = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_save", $override, $a, $this->args(), $this ); |
|
| 346 | 346 | |
| 347 | 347 | // If override, return that |
| 348 | 348 | if ( null !== $override ) { |
@@ -350,22 +350,22 @@ discard block |
||
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | // Options page handling (or temp data store) |
| 353 | - if ( 'options-page' === $a['type'] || empty( $a['id'] ) ) { |
|
| 354 | - return cmb2_options( $a['id'] )->update( $a['field_id'], $a['value'], false, $a['single'] ); |
|
| 353 | + if ( 'options-page' === $a[ 'type' ] || empty( $a[ 'id' ] ) ) { |
|
| 354 | + return cmb2_options( $a[ 'id' ] )->update( $a[ 'field_id' ], $a[ 'value' ], false, $a[ 'single' ] ); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | // Add metadata if not single |
| 358 | - if ( ! $a['single'] ) { |
|
| 359 | - return add_metadata( $a['type'], $a['id'], $a['field_id'], $a['value'], false ); |
|
| 358 | + if ( ! $a[ 'single' ] ) { |
|
| 359 | + return add_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $a[ 'value' ], false ); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | // Delete meta if we have an empty array |
| 363 | - if ( is_array( $a['value'] ) && empty( $a['value'] ) ) { |
|
| 364 | - return delete_metadata( $a['type'], $a['id'], $a['field_id'], $this->value ); |
|
| 363 | + if ( is_array( $a[ 'value' ] ) && empty( $a[ 'value' ] ) ) { |
|
| 364 | + return delete_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $this->value ); |
|
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | // Update metadata |
| 368 | - return update_metadata( $a['type'], $a['id'], $a['field_id'], $a['value'] ); |
|
| 368 | + return update_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $a[ 'value' ] ); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | /** |
@@ -418,19 +418,19 @@ discard block |
||
| 418 | 418 | * @param array $field_args All field arguments |
| 419 | 419 | * @param CMB2_Field object $field This field object |
| 420 | 420 | */ |
| 421 | - $override = apply_filters( "cmb2_override_{$a['field_id']}_meta_remove", $override, $a, $this->args(), $this ); |
|
| 421 | + $override = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_remove", $override, $a, $this->args(), $this ); |
|
| 422 | 422 | |
| 423 | 423 | // If no override, remove as usual |
| 424 | 424 | if ( null !== $override ) { |
| 425 | 425 | return $override; |
| 426 | 426 | } // End if(). |
| 427 | 427 | // Option page handling. |
| 428 | - elseif ( 'options-page' === $a['type'] || empty( $a['id'] ) ) { |
|
| 429 | - return cmb2_options( $a['id'] )->remove( $a['field_id'] ); |
|
| 428 | + elseif ( 'options-page' === $a[ 'type' ] || empty( $a[ 'id' ] ) ) { |
|
| 429 | + return cmb2_options( $a[ 'id' ] )->remove( $a[ 'field_id' ] ); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | // Remove metadata |
| 433 | - return delete_metadata( $a['type'], $a['id'], $a['field_id'], $old ); |
|
| 433 | + return delete_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $old ); |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | /** |
@@ -897,7 +897,7 @@ discard block |
||
| 897 | 897 | |
| 898 | 898 | foreach ( $conditional_classes as $class => $condition ) { |
| 899 | 899 | if ( $condition ) { |
| 900 | - $classes[] = $class; |
|
| 900 | + $classes[ ] = $class; |
|
| 901 | 901 | } |
| 902 | 902 | } |
| 903 | 903 | |
@@ -908,7 +908,7 @@ discard block |
||
| 908 | 908 | } |
| 909 | 909 | |
| 910 | 910 | if ( $added_classes ) { |
| 911 | - $classes[] = esc_attr( $added_classes ); |
|
| 911 | + $classes[ ] = esc_attr( $added_classes ); |
|
| 912 | 912 | } |
| 913 | 913 | |
| 914 | 914 | /** |
@@ -1011,10 +1011,10 @@ discard block |
||
| 1011 | 1011 | public function get_string( $text_key, $fallback ) { |
| 1012 | 1012 | // If null, populate with our field strings values. |
| 1013 | 1013 | if ( null === $this->strings ) { |
| 1014 | - $this->strings = (array) $this->args['text']; |
|
| 1014 | + $this->strings = (array) $this->args[ 'text' ]; |
|
| 1015 | 1015 | |
| 1016 | - if ( is_callable( $this->args['text_cb'] ) ) { |
|
| 1017 | - $strings = call_user_func( $this->args['text_cb'], $this ); |
|
| 1016 | + if ( is_callable( $this->args[ 'text_cb' ] ) ) { |
|
| 1017 | + $strings = call_user_func( $this->args[ 'text_cb' ], $this ); |
|
| 1018 | 1018 | |
| 1019 | 1019 | if ( $strings && is_array( $strings ) ) { |
| 1020 | 1020 | $this->strings += $strings; |
@@ -1049,10 +1049,10 @@ discard block |
||
| 1049 | 1049 | return $this->field_options; |
| 1050 | 1050 | } |
| 1051 | 1051 | |
| 1052 | - $this->field_options = (array) $this->args['options']; |
|
| 1052 | + $this->field_options = (array) $this->args[ 'options' ]; |
|
| 1053 | 1053 | |
| 1054 | - if ( is_callable( $this->args['options_cb'] ) ) { |
|
| 1055 | - $options = call_user_func( $this->args['options_cb'], $this ); |
|
| 1054 | + if ( is_callable( $this->args[ 'options_cb' ] ) ) { |
|
| 1055 | + $options = call_user_func( $this->args[ 'options_cb' ], $this ); |
|
| 1056 | 1056 | |
| 1057 | 1057 | if ( $options && is_array( $options ) ) { |
| 1058 | 1058 | $this->field_options = $options + $this->field_options; |
@@ -1074,7 +1074,7 @@ discard block |
||
| 1074 | 1074 | */ |
| 1075 | 1075 | public function add_js_dependencies( $dependencies = array() ) { |
| 1076 | 1076 | foreach ( (array) $dependencies as $dependency ) { |
| 1077 | - $this->args['js_dependencies'][ $dependency ] = $dependency; |
|
| 1077 | + $this->args[ 'js_dependencies' ][ $dependency ] = $dependency; |
|
| 1078 | 1078 | } |
| 1079 | 1079 | |
| 1080 | 1080 | CMB2_JS::add_dependencies( $dependencies ); |
@@ -1088,17 +1088,17 @@ discard block |
||
| 1088 | 1088 | * @return mixed Default field value |
| 1089 | 1089 | */ |
| 1090 | 1090 | public function get_default() { |
| 1091 | - if ( null !== $this->args['default'] ) { |
|
| 1092 | - return $this->args['default']; |
|
| 1091 | + if ( null !== $this->args[ 'default' ] ) { |
|
| 1092 | + return $this->args[ 'default' ]; |
|
| 1093 | 1093 | } |
| 1094 | 1094 | |
| 1095 | - $param = is_callable( $this->args['default_cb'] ) ? 'default_cb' : 'default'; |
|
| 1095 | + $param = is_callable( $this->args[ 'default_cb' ] ) ? 'default_cb' : 'default'; |
|
| 1096 | 1096 | $default = $this->get_param_callback_result( $param ); |
| 1097 | 1097 | |
| 1098 | 1098 | // Allow a filter override of the default value |
| 1099 | - $this->args['default'] = apply_filters( 'cmb2_default_filter', $default, $this ); |
|
| 1099 | + $this->args[ 'default' ] = apply_filters( 'cmb2_default_filter', $default, $this ); |
|
| 1100 | 1100 | |
| 1101 | - return $this->args['default']; |
|
| 1101 | + return $this->args[ 'default' ]; |
|
| 1102 | 1102 | } |
| 1103 | 1103 | |
| 1104 | 1104 | /** |
@@ -1129,18 +1129,18 @@ discard block |
||
| 1129 | 1129 | 'classes_cb' => '', |
| 1130 | 1130 | 'select_all_button' => true, |
| 1131 | 1131 | 'multiple' => false, |
| 1132 | - 'repeatable' => isset( $args['type'] ) && 'group' == $args['type'], |
|
| 1132 | + 'repeatable' => isset( $args[ 'type' ] ) && 'group' == $args[ 'type' ], |
|
| 1133 | 1133 | 'inline' => false, |
| 1134 | 1134 | 'on_front' => true, |
| 1135 | 1135 | 'show_names' => true, |
| 1136 | 1136 | 'save_field' => true, // Will not save if false |
| 1137 | 1137 | 'date_format' => 'm\/d\/Y', |
| 1138 | 1138 | 'time_format' => 'h:i A', |
| 1139 | - 'description' => isset( $args['desc'] ) ? $args['desc'] : '', |
|
| 1140 | - 'preview_size' => 'file' == $args['type'] ? array( 350, 350 ) : array( 50, 50 ), |
|
| 1139 | + 'description' => isset( $args[ 'desc' ] ) ? $args[ 'desc' ] : '', |
|
| 1140 | + 'preview_size' => 'file' == $args[ 'type' ] ? array( 350, 350 ) : array( 50, 50 ), |
|
| 1141 | 1141 | 'render_row_cb' => array( $this, 'render_field_callback' ), |
| 1142 | 1142 | 'display_cb' => array( $this, 'display_value_callback' ), |
| 1143 | - 'label_cb' => 'title' != $args['type'] ? array( $this, 'label' ) : '', |
|
| 1143 | + 'label_cb' => 'title' != $args[ 'type' ] ? array( $this, 'label' ) : '', |
|
| 1144 | 1144 | 'column' => false, |
| 1145 | 1145 | 'js_dependencies' => array(), |
| 1146 | 1146 | 'show_in_rest' => null, |
@@ -1155,43 +1155,43 @@ discard block |
||
| 1155 | 1155 | */ |
| 1156 | 1156 | $args = $this->convert_deprecated_params( $args ); |
| 1157 | 1157 | |
| 1158 | - $args['repeatable'] = $args['repeatable'] && ! $this->repeatable_exception( $args['type'] ); |
|
| 1159 | - $args['inline'] = $args['inline'] || false !== stripos( $args['type'], '_inline' ); |
|
| 1158 | + $args[ 'repeatable' ] = $args[ 'repeatable' ] && ! $this->repeatable_exception( $args[ 'type' ] ); |
|
| 1159 | + $args[ 'inline' ] = $args[ 'inline' ] || false !== stripos( $args[ 'type' ], '_inline' ); |
|
| 1160 | 1160 | |
| 1161 | - $args['options'] = 'group' == $args['type'] ? wp_parse_args( $args['options'], array( |
|
| 1161 | + $args[ 'options' ] = 'group' == $args[ 'type' ] ? wp_parse_args( $args[ 'options' ], array( |
|
| 1162 | 1162 | 'add_button' => esc_html__( 'Add Group', 'cmb2' ), |
| 1163 | 1163 | 'remove_button' => esc_html__( 'Remove Group', 'cmb2' ), |
| 1164 | - ) ) : $args['options']; |
|
| 1164 | + ) ) : $args[ 'options' ]; |
|
| 1165 | 1165 | |
| 1166 | - $args['_id'] = $args['id']; |
|
| 1167 | - $args['_name'] = $args['id']; |
|
| 1166 | + $args[ '_id' ] = $args[ 'id' ]; |
|
| 1167 | + $args[ '_name' ] = $args[ 'id' ]; |
|
| 1168 | 1168 | |
| 1169 | 1169 | if ( $this->group ) { |
| 1170 | 1170 | |
| 1171 | - $args['id'] = $this->group->args( 'id' ) . '_' . $this->group->index . '_' . $args['id']; |
|
| 1172 | - $args['_name'] = $this->group->args( 'id' ) . '[' . $this->group->index . '][' . $args['_name'] . ']'; |
|
| 1171 | + $args[ 'id' ] = $this->group->args( 'id' ) . '_' . $this->group->index . '_' . $args[ 'id' ]; |
|
| 1172 | + $args[ '_name' ] = $this->group->args( 'id' ) . '[' . $this->group->index . '][' . $args[ '_name' ] . ']'; |
|
| 1173 | 1173 | } |
| 1174 | 1174 | |
| 1175 | - if ( 'wysiwyg' == $args['type'] ) { |
|
| 1176 | - $args['id'] = strtolower( str_ireplace( '-', '_', $args['id'] ) ); |
|
| 1177 | - $args['options']['textarea_name'] = $args['_name']; |
|
| 1175 | + if ( 'wysiwyg' == $args[ 'type' ] ) { |
|
| 1176 | + $args[ 'id' ] = strtolower( str_ireplace( '-', '_', $args[ 'id' ] ) ); |
|
| 1177 | + $args[ 'options' ][ 'textarea_name' ] = $args[ '_name' ]; |
|
| 1178 | 1178 | } |
| 1179 | 1179 | |
| 1180 | 1180 | $option_types = apply_filters( 'cmb2_all_or_nothing_types', array( 'select', 'radio', 'radio_inline', 'taxonomy_select', 'taxonomy_radio', 'taxonomy_radio_inline' ), $this ); |
| 1181 | 1181 | |
| 1182 | - if ( in_array( $args['type'], $option_types, true ) ) { |
|
| 1182 | + if ( in_array( $args[ 'type' ], $option_types, true ) ) { |
|
| 1183 | 1183 | |
| 1184 | - $args['show_option_none'] = isset( $args['show_option_none'] ) ? $args['show_option_none'] : null; |
|
| 1185 | - $args['show_option_none'] = true === $args['show_option_none'] ? esc_html__( 'None', 'cmb2' ) : $args['show_option_none']; |
|
| 1184 | + $args[ 'show_option_none' ] = isset( $args[ 'show_option_none' ] ) ? $args[ 'show_option_none' ] : null; |
|
| 1185 | + $args[ 'show_option_none' ] = true === $args[ 'show_option_none' ] ? esc_html__( 'None', 'cmb2' ) : $args[ 'show_option_none' ]; |
|
| 1186 | 1186 | |
| 1187 | - if ( null === $args['show_option_none'] ) { |
|
| 1188 | - $off_by_default = in_array( $args['type'], array( 'select', 'radio', 'radio_inline' ), true ); |
|
| 1189 | - $args['show_option_none'] = $off_by_default ? false : esc_html__( 'None', 'cmb2' ); |
|
| 1187 | + if ( null === $args[ 'show_option_none' ] ) { |
|
| 1188 | + $off_by_default = in_array( $args[ 'type' ], array( 'select', 'radio', 'radio_inline' ), true ); |
|
| 1189 | + $args[ 'show_option_none' ] = $off_by_default ? false : esc_html__( 'None', 'cmb2' ); |
|
| 1190 | 1190 | } |
| 1191 | 1191 | } |
| 1192 | 1192 | |
| 1193 | - $args['has_supporting_data'] = in_array( |
|
| 1194 | - $args['type'], |
|
| 1193 | + $args[ 'has_supporting_data' ] = in_array( |
|
| 1194 | + $args[ 'type' ], |
|
| 1195 | 1195 | array( |
| 1196 | 1196 | // CMB2_Sanitize::_save_file_id_value()/CMB2_Sanitize::_get_group_file_value_array() |
| 1197 | 1197 | 'file', |
@@ -1215,10 +1215,10 @@ discard block |
||
| 1215 | 1215 | protected function get_default_args( $field_args, $field_group = null ) { |
| 1216 | 1216 | $args = parent::get_default_args( array(), $this->group ); |
| 1217 | 1217 | |
| 1218 | - if ( isset( $field_args['field_args'] ) ) { |
|
| 1218 | + if ( isset( $field_args[ 'field_args' ] ) ) { |
|
| 1219 | 1219 | $args = wp_parse_args( $field_args, $args ); |
| 1220 | 1220 | } else { |
| 1221 | - $args['field_args'] = wp_parse_args( $field_args, $this->args ); |
|
| 1221 | + $args[ 'field_args' ] = wp_parse_args( $field_args, $this->args ); |
|
| 1222 | 1222 | } |
| 1223 | 1223 | |
| 1224 | 1224 | return $args; |
@@ -1262,41 +1262,41 @@ discard block |
||
| 1262 | 1262 | */ |
| 1263 | 1263 | protected function convert_deprecated_params( $args ) { |
| 1264 | 1264 | |
| 1265 | - if ( isset( $args['row_classes'] ) ) { |
|
| 1265 | + if ( isset( $args[ 'row_classes' ] ) ) { |
|
| 1266 | 1266 | |
| 1267 | 1267 | // We'll let this one be. |
| 1268 | 1268 | // $this->deprecated_param( __CLASS__ . '::__construct()', '2.2.3', self::DEPRECATED_PARAM, 'row_classes', 'classes' ); |
| 1269 | 1269 | // row_classes param could be a callback. This is definitely deprecated. |
| 1270 | - if ( is_callable( $args['row_classes'] ) ) { |
|
| 1270 | + if ( is_callable( $args[ 'row_classes' ] ) ) { |
|
| 1271 | 1271 | |
| 1272 | 1272 | $this->deprecated_param( __CLASS__ . '::__construct()', '2.2.3', self::DEPRECATED_CB_PARAM, 'row_classes', 'classes_cb' ); |
| 1273 | 1273 | |
| 1274 | - $args['classes_cb'] = $args['row_classes']; |
|
| 1275 | - $args['classes'] = null; |
|
| 1274 | + $args[ 'classes_cb' ] = $args[ 'row_classes' ]; |
|
| 1275 | + $args[ 'classes' ] = null; |
|
| 1276 | 1276 | } else { |
| 1277 | 1277 | |
| 1278 | - $args['classes'] = $args['row_classes']; |
|
| 1278 | + $args[ 'classes' ] = $args[ 'row_classes' ]; |
|
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | - unset( $args['row_classes'] ); |
|
| 1281 | + unset( $args[ 'row_classes' ] ); |
|
| 1282 | 1282 | } |
| 1283 | 1283 | |
| 1284 | 1284 | // default param can be passed a callback as well |
| 1285 | - if ( is_callable( $args['default'] ) ) { |
|
| 1285 | + if ( is_callable( $args[ 'default' ] ) ) { |
|
| 1286 | 1286 | |
| 1287 | 1287 | $this->deprecated_param( __CLASS__ . '::__construct()', '2.2.3', self::DEPRECATED_CB_PARAM, 'default', 'default_cb' ); |
| 1288 | 1288 | |
| 1289 | - $args['default_cb'] = $args['default']; |
|
| 1290 | - $args['default'] = null; |
|
| 1289 | + $args[ 'default_cb' ] = $args[ 'default' ]; |
|
| 1290 | + $args[ 'default' ] = null; |
|
| 1291 | 1291 | } |
| 1292 | 1292 | |
| 1293 | 1293 | // options param can be passed a callback as well |
| 1294 | - if ( is_callable( $args['options'] ) ) { |
|
| 1294 | + if ( is_callable( $args[ 'options' ] ) ) { |
|
| 1295 | 1295 | |
| 1296 | 1296 | $this->deprecated_param( __CLASS__ . '::__construct()', '2.2.3', self::DEPRECATED_CB_PARAM, 'options', 'options_cb' ); |
| 1297 | 1297 | |
| 1298 | - $args['options_cb'] = $args['options']; |
|
| 1299 | - $args['options'] = array(); |
|
| 1298 | + $args[ 'options_cb' ] = $args[ 'options' ]; |
|
| 1299 | + $args[ 'options' ] = array(); |
|
| 1300 | 1300 | } |
| 1301 | 1301 | |
| 1302 | 1302 | 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 ); |