@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function __construct( CMB2_Types $types, $args = array() ) { |
| 40 | 40 | $this->types = $types; |
| 41 | - $args['rendered'] = isset( $args['rendered'] ) ? (bool) $args['rendered'] : true; |
|
| 41 | + $args[ 'rendered' ] = isset( $args[ 'rendered' ] ) ? (bool) $args[ 'rendered' ] : true; |
|
| 42 | 42 | $this->args = $args; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @return string|CMB2_Type_Base Rendered output or this object. |
| 57 | 57 | */ |
| 58 | 58 | public function rendered( $rendered ) { |
| 59 | - if ( $this->args['rendered'] ) { |
|
| 59 | + if ( $this->args[ 'rendered' ] ) { |
|
| 60 | 60 | return is_a( $rendered, __CLASS__ ) ? $rendered->rendered : $rendered; |
| 61 | 61 | } |
| 62 | 62 | |
@@ -162,7 +162,7 @@ |
||
| 162 | 162 | * @return string String of attributes for form element |
| 163 | 163 | */ |
| 164 | 164 | public function concat_attrs( $attrs, $attr_exclude = array() ) { |
| 165 | - $attr_exclude[] = 'rendered'; |
|
| 165 | + $attr_exclude[ ] = 'rendered'; |
|
| 166 | 166 | $attributes = ''; |
| 167 | 167 | foreach ( $attrs as $attr => $val ) { |
| 168 | 168 | $excluded = in_array( $attr, (array) $attr_exclude, true ); |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | global $wp_locale; |
| 174 | 174 | |
| 175 | - $search = array( $wp_locale->number_format['thousands_sep'], $wp_locale->number_format['decimal_point'] ); |
|
| 175 | + $search = array( $wp_locale->number_format[ 'thousands_sep' ], $wp_locale->number_format[ 'decimal_point' ] ); |
|
| 176 | 176 | $replace = array( '', '.' ); |
| 177 | 177 | |
| 178 | 178 | // for repeatable |
@@ -215,8 +215,8 @@ discard block |
||
| 215 | 215 | return $repeat_value; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - if ( isset( $this->value['date'], $this->value['time'] ) ) { |
|
| 219 | - $this->value = $this->field->get_timestamp_from_value( $this->value['date'] . ' ' . $this->value['time'] ); |
|
| 218 | + if ( isset( $this->value[ 'date' ], $this->value[ 'time' ] ) ) { |
|
| 219 | + $this->value = $this->field->get_timestamp_from_value( $this->value[ 'date' ] . ' ' . $this->value[ 'time' ] ); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | if ( $tz_offset = $this->field->field_timezone_offset() ) { |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | $tzstring = null; |
| 255 | 255 | |
| 256 | 256 | if ( is_array( $this->value ) && array_key_exists( 'timezone', $this->value ) ) { |
| 257 | - $tzstring = $this->value['timezone']; |
|
| 257 | + $tzstring = $this->value[ 'timezone' ]; |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | if ( empty( $tzstring ) ) { |
@@ -274,8 +274,8 @@ discard block |
||
| 274 | 274 | $tzstring = false !== $tzstring ? $tzstring : timezone_name_from_abbr( '', 0, 0 ); |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - $full_format = $this->field->args['date_format'] . ' ' . $this->field->args['time_format']; |
|
| 278 | - $full_date = $this->value['date'] . ' ' . $this->value['time']; |
|
| 277 | + $full_format = $this->field->args[ 'date_format' ] . ' ' . $this->field->args[ 'time_format' ]; |
|
| 278 | + $full_date = $this->value[ 'date' ] . ' ' . $this->value[ 'time' ]; |
|
| 279 | 279 | |
| 280 | 280 | try { |
| 281 | 281 | |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | } else { |
| 299 | 299 | // Save the utc timestamp supporting field |
| 300 | 300 | if ( $repeat ) { |
| 301 | - $utc_values[ $utc_key ][] = $utc_stamp; |
|
| 301 | + $utc_values[ $utc_key ][ ] = $utc_stamp; |
|
| 302 | 302 | } else { |
| 303 | 303 | $this->_save_utc_value( $utc_key, $utc_stamp ); |
| 304 | 304 | } |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | if ( $this->value ) { |
| 434 | 434 | $val = $this->$method( true ); |
| 435 | 435 | if ( ! empty( $val ) ) { |
| 436 | - $new_value[] = $val; |
|
| 436 | + $new_value[ ] = $val; |
|
| 437 | 437 | } |
| 438 | 438 | } |
| 439 | 439 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | $output = ''; |
| 22 | 22 | |
| 23 | 23 | // if options array and 'url' => false, then hide the url field |
| 24 | - $input_type = array_key_exists( 'url', $options ) && false === $options['url'] ? 'hidden' : 'text'; |
|
| 24 | + $input_type = array_key_exists( 'url', $options ) && false === $options[ 'url' ] ? 'hidden' : 'text'; |
|
| 25 | 25 | |
| 26 | 26 | $output .= parent::render( array( |
| 27 | 27 | 'type' => $input_type, |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | if ( $_id_value ) { |
| 72 | 72 | $image = wp_get_attachment_image( $_id_value, $img_size, null, array( 'class' => 'cmb-file-field-image' ) ); |
| 73 | 73 | } else { |
| 74 | - $size = is_array( $img_size ) ? $img_size[0] : 350; |
|
| 74 | + $size = is_array( $img_size ) ? $img_size[ 0 ] : 350; |
|
| 75 | 75 | $image = '<img style="max-width: ' . absint( $size ) . 'px; width: 100%; height: auto;" src="' . $meta_value . '" alt="" />'; |
| 76 | 76 | } |
| 77 | 77 | |
@@ -107,21 +107,21 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | public function __construct( $args ) { |
| 109 | 109 | |
| 110 | - if ( ! empty( $args['group_field'] ) ) { |
|
| 111 | - $this->group = $args['group_field']; |
|
| 110 | + if ( ! empty( $args[ 'group_field' ] ) ) { |
|
| 111 | + $this->group = $args[ 'group_field' ]; |
|
| 112 | 112 | $this->object_id = $this->group->object_id; |
| 113 | 113 | $this->object_type = $this->group->object_type; |
| 114 | 114 | $this->cmb_id = $this->group->cmb_id; |
| 115 | 115 | } else { |
| 116 | - $this->object_id = isset( $args['object_id'] ) && '_' !== $args['object_id'] ? $args['object_id'] : 0; |
|
| 117 | - $this->object_type = isset( $args['object_type'] ) ? $args['object_type'] : 'post'; |
|
| 116 | + $this->object_id = isset( $args[ 'object_id' ] ) && '_' !== $args[ 'object_id' ] ? $args[ 'object_id' ] : 0; |
|
| 117 | + $this->object_type = isset( $args[ 'object_type' ] ) ? $args[ 'object_type' ] : 'post'; |
|
| 118 | 118 | |
| 119 | - if ( isset( $args['cmb_id'] ) ) { |
|
| 120 | - $this->cmb_id = $args['cmb_id']; |
|
| 119 | + if ( isset( $args[ 'cmb_id' ] ) ) { |
|
| 120 | + $this->cmb_id = $args[ 'cmb_id' ]; |
|
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - $this->args = $this->_set_field_defaults( $args['field_args'] ); |
|
| 124 | + $this->args = $this->_set_field_defaults( $args[ 'field_args' ] ); |
|
| 125 | 125 | |
| 126 | 126 | if ( $this->object_id ) { |
| 127 | 127 | $this->value = $this->get_data(); |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | * @return mixed Value of field argument |
| 137 | 137 | */ |
| 138 | 138 | public function __call( $name, $arguments ) { |
| 139 | - $key = isset( $arguments[0] ) ? $arguments[0] : false; |
|
| 139 | + $key = isset( $arguments[ 0 ] ) ? $arguments[ 0 ] : false; |
|
| 140 | 140 | return $this->args( $name, $key ); |
| 141 | 141 | } |
| 142 | 142 | |
@@ -207,9 +207,9 @@ discard block |
||
| 207 | 207 | */ |
| 208 | 208 | public function get_data( $field_id = '', $args = array() ) { |
| 209 | 209 | if ( $field_id ) { |
| 210 | - $args['field_id'] = $field_id; |
|
| 210 | + $args[ 'field_id' ] = $field_id; |
|
| 211 | 211 | } else if ( $this->group ) { |
| 212 | - $args['field_id'] = $this->group->id(); |
|
| 212 | + $args[ 'field_id' ] = $this->group->id(); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | $a = $this->data_args( $args ); |
@@ -250,13 +250,13 @@ discard block |
||
| 250 | 250 | * |
| 251 | 251 | * @since 2.0.0 |
| 252 | 252 | */ |
| 253 | - $data = apply_filters( "cmb2_override_{$a['field_id']}_meta_value", $data, $this->object_id, $a, $this ); |
|
| 253 | + $data = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_value", $data, $this->object_id, $a, $this ); |
|
| 254 | 254 | |
| 255 | 255 | // If no override, get value normally |
| 256 | 256 | if ( 'cmb2_field_no_override_val' === $data ) { |
| 257 | - $data = 'options-page' === $a['type'] |
|
| 258 | - ? cmb2_options( $a['id'] )->get( $a['field_id'] ) |
|
| 259 | - : get_metadata( $a['type'], $a['id'], $a['field_id'], ( $a['single'] || $a['repeat'] ) ); |
|
| 257 | + $data = 'options-page' === $a[ 'type' ] |
|
| 258 | + ? cmb2_options( $a[ 'id' ] )->get( $a[ 'field_id' ] ) |
|
| 259 | + : get_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], ( $a[ 'single' ] || $a[ 'repeat' ] ) ); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | if ( $this->group ) { |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | public function update_data( $new_value, $single = true ) { |
| 279 | 279 | $a = $this->data_args( array( 'single' => $single ) ); |
| 280 | 280 | |
| 281 | - $a['value'] = $a['repeat'] ? array_values( $new_value ) : $new_value; |
|
| 281 | + $a[ 'value' ] = $a[ 'repeat' ] ? array_values( $new_value ) : $new_value; |
|
| 282 | 282 | |
| 283 | 283 | /** |
| 284 | 284 | * Filter whether to override saving of meta value. |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | * |
| 315 | 315 | * @since 2.0.0 |
| 316 | 316 | */ |
| 317 | - $override = apply_filters( "cmb2_override_{$a['field_id']}_meta_save", $override, $a, $this->args(), $this ); |
|
| 317 | + $override = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_save", $override, $a, $this->args(), $this ); |
|
| 318 | 318 | |
| 319 | 319 | // If override, return that |
| 320 | 320 | if ( null !== $override ) { |
@@ -322,22 +322,22 @@ discard block |
||
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | // Options page handling (or temp data store) |
| 325 | - if ( 'options-page' === $a['type'] || empty( $a['id'] ) ) { |
|
| 326 | - return cmb2_options( $a['id'] )->update( $a['field_id'], $a['value'], false, $a['single'] ); |
|
| 325 | + if ( 'options-page' === $a[ 'type' ] || empty( $a[ 'id' ] ) ) { |
|
| 326 | + return cmb2_options( $a[ 'id' ] )->update( $a[ 'field_id' ], $a[ 'value' ], false, $a[ 'single' ] ); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | // Add metadata if not single |
| 330 | - if ( ! $a['single'] ) { |
|
| 331 | - return add_metadata( $a['type'], $a['id'], $a['field_id'], $a['value'], false ); |
|
| 330 | + if ( ! $a[ 'single' ] ) { |
|
| 331 | + return add_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $a[ 'value' ], false ); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | // Delete meta if we have an empty array |
| 335 | - if ( is_array( $a['value'] ) && empty( $a['value'] ) ) { |
|
| 336 | - return delete_metadata( $a['type'], $a['id'], $a['field_id'], $this->value ); |
|
| 335 | + if ( is_array( $a[ 'value' ] ) && empty( $a[ 'value' ] ) ) { |
|
| 336 | + return delete_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $this->value ); |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | // Update metadata |
| 340 | - return update_metadata( $a['type'], $a['id'], $a['field_id'], $a['value'] ); |
|
| 340 | + return update_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $a[ 'value' ] ); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | /** |
@@ -387,19 +387,19 @@ discard block |
||
| 387 | 387 | * @param array $field_args All field arguments |
| 388 | 388 | * @param CMB2_Field object $field This field object |
| 389 | 389 | */ |
| 390 | - $override = apply_filters( "cmb2_override_{$a['field_id']}_meta_remove", $override, $a, $this->args(), $this ); |
|
| 390 | + $override = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_remove", $override, $a, $this->args(), $this ); |
|
| 391 | 391 | |
| 392 | 392 | // If no override, remove as usual |
| 393 | 393 | if ( null !== $override ) { |
| 394 | 394 | return $override; |
| 395 | 395 | } |
| 396 | 396 | // Option page handling |
| 397 | - elseif ( 'options-page' === $a['type'] || empty( $a['id'] ) ) { |
|
| 398 | - return cmb2_options( $a['id'] )->remove( $a['field_id'] ); |
|
| 397 | + elseif ( 'options-page' === $a[ 'type' ] || empty( $a[ 'id' ] ) ) { |
|
| 398 | + return cmb2_options( $a[ 'id' ] )->remove( $a[ 'field_id' ] ); |
|
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | // Remove metadata |
| 402 | - return delete_metadata( $a['type'], $a['id'], $a['field_id'], $old ); |
|
| 402 | + return delete_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $old ); |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | /** |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | |
| 871 | 871 | foreach ( $conditional_classes as $class => $condition ) { |
| 872 | 872 | if ( $condition ) { |
| 873 | - $classes[] = $class; |
|
| 873 | + $classes[ ] = $class; |
|
| 874 | 874 | } |
| 875 | 875 | } |
| 876 | 876 | |
@@ -879,7 +879,7 @@ discard block |
||
| 879 | 879 | } |
| 880 | 880 | |
| 881 | 881 | if ( $added_classes ) { |
| 882 | - $classes[] = esc_attr( $added_classes ); |
|
| 882 | + $classes[ ] = esc_attr( $added_classes ); |
|
| 883 | 883 | } |
| 884 | 884 | |
| 885 | 885 | /** |
@@ -981,10 +981,10 @@ discard block |
||
| 981 | 981 | public function string( $text_key, $fallback ) { |
| 982 | 982 | // If null, populate with our field strings values. |
| 983 | 983 | if ( null === $this->strings ) { |
| 984 | - $this->strings = (array) $this->args['text']; |
|
| 984 | + $this->strings = (array) $this->args[ 'text' ]; |
|
| 985 | 985 | |
| 986 | - if ( is_callable( $this->args['text_cb'] ) ) { |
|
| 987 | - $strings = call_user_func( $this->args['text_cb'], $this ); |
|
| 986 | + if ( is_callable( $this->args[ 'text_cb' ] ) ) { |
|
| 987 | + $strings = call_user_func( $this->args[ 'text_cb' ], $this ); |
|
| 988 | 988 | |
| 989 | 989 | if ( $strings && is_array( $strings ) ) { |
| 990 | 990 | $this->strings += $strings; |
@@ -1018,10 +1018,10 @@ discard block |
||
| 1018 | 1018 | return $this->field_options; |
| 1019 | 1019 | } |
| 1020 | 1020 | |
| 1021 | - $this->field_options = (array) $this->args['options']; |
|
| 1021 | + $this->field_options = (array) $this->args[ 'options' ]; |
|
| 1022 | 1022 | |
| 1023 | - if ( is_callable( $this->args['options_cb'] ) ) { |
|
| 1024 | - $options = call_user_func( $this->args['options_cb'], $this ); |
|
| 1023 | + if ( is_callable( $this->args[ 'options_cb' ] ) ) { |
|
| 1024 | + $options = call_user_func( $this->args[ 'options_cb' ], $this ); |
|
| 1025 | 1025 | |
| 1026 | 1026 | if ( $options && is_array( $options ) ) { |
| 1027 | 1027 | $this->field_options += $options; |
@@ -1043,17 +1043,17 @@ discard block |
||
| 1043 | 1043 | * @return mixed Default field value |
| 1044 | 1044 | */ |
| 1045 | 1045 | public function get_default() { |
| 1046 | - if ( null !== $this->args['default'] ) { |
|
| 1047 | - return $this->args['default']; |
|
| 1046 | + if ( null !== $this->args[ 'default' ] ) { |
|
| 1047 | + return $this->args[ 'default' ]; |
|
| 1048 | 1048 | } |
| 1049 | 1049 | |
| 1050 | - $param = is_callable( $this->args['default_cb'] ) ? 'default_cb' : 'default'; |
|
| 1050 | + $param = is_callable( $this->args[ 'default_cb' ] ) ? 'default_cb' : 'default'; |
|
| 1051 | 1051 | $default = $this->get_param_callback_result( $param, false ); |
| 1052 | 1052 | |
| 1053 | 1053 | // Allow a filter override of the default value |
| 1054 | - $this->args['default'] = apply_filters( 'cmb2_default_filter', $default, $this ); |
|
| 1054 | + $this->args[ 'default' ] = apply_filters( 'cmb2_default_filter', $default, $this ); |
|
| 1055 | 1055 | |
| 1056 | - return $this->args['default']; |
|
| 1056 | + return $this->args[ 'default' ]; |
|
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | 1059 | /** |
@@ -1080,68 +1080,68 @@ discard block |
||
| 1080 | 1080 | 'default_cb' => '', |
| 1081 | 1081 | 'select_all_button' => true, |
| 1082 | 1082 | 'multiple' => false, |
| 1083 | - 'repeatable' => isset( $args['type'] ) && 'group' == $args['type'], |
|
| 1083 | + 'repeatable' => isset( $args[ 'type' ] ) && 'group' == $args[ 'type' ], |
|
| 1084 | 1084 | 'inline' => false, |
| 1085 | 1085 | 'on_front' => true, |
| 1086 | 1086 | 'show_names' => true, |
| 1087 | 1087 | 'date_format' => 'm\/d\/Y', |
| 1088 | 1088 | 'time_format' => 'h:i A', |
| 1089 | - 'description' => isset( $args['desc'] ) ? $args['desc'] : '', |
|
| 1090 | - 'preview_size' => 'file' == $args['type'] ? array( 350, 350 ) : array( 50, 50 ), |
|
| 1089 | + 'description' => isset( $args[ 'desc' ] ) ? $args[ 'desc' ] : '', |
|
| 1090 | + 'preview_size' => 'file' == $args[ 'type' ] ? array( 350, 350 ) : array( 50, 50 ), |
|
| 1091 | 1091 | 'render_row_cb' => array( $this, 'render_field_callback' ), |
| 1092 | - 'label_cb' => 'title' != $args['type'] ? array( $this, 'label' ) : '', |
|
| 1092 | + 'label_cb' => 'title' != $args[ 'type' ] ? array( $this, 'label' ) : '', |
|
| 1093 | 1093 | ) ); |
| 1094 | 1094 | |
| 1095 | 1095 | // default param can be passed a callback as well |
| 1096 | - if ( is_callable( $args['default'] ) ) { |
|
| 1097 | - $args['default_cb'] = $args['default']; |
|
| 1098 | - $args['default'] = null; |
|
| 1096 | + if ( is_callable( $args[ 'default' ] ) ) { |
|
| 1097 | + $args[ 'default_cb' ] = $args[ 'default' ]; |
|
| 1098 | + $args[ 'default' ] = null; |
|
| 1099 | 1099 | } |
| 1100 | 1100 | |
| 1101 | - $args['repeatable'] = $args['repeatable'] && ! $this->repeatable_exception( $args['type'] ); |
|
| 1102 | - $args['inline'] = $args['inline'] || false !== stripos( $args['type'], '_inline' ); |
|
| 1101 | + $args[ 'repeatable' ] = $args[ 'repeatable' ] && ! $this->repeatable_exception( $args[ 'type' ] ); |
|
| 1102 | + $args[ 'inline' ] = $args[ 'inline' ] || false !== stripos( $args[ 'type' ], '_inline' ); |
|
| 1103 | 1103 | |
| 1104 | 1104 | // options param can be passed a callback as well |
| 1105 | - if ( is_callable( $args['options'] ) ) { |
|
| 1106 | - $args['options_cb'] = $args['options']; |
|
| 1107 | - $args['options'] = array(); |
|
| 1105 | + if ( is_callable( $args[ 'options' ] ) ) { |
|
| 1106 | + $args[ 'options_cb' ] = $args[ 'options' ]; |
|
| 1107 | + $args[ 'options' ] = array(); |
|
| 1108 | 1108 | } |
| 1109 | 1109 | |
| 1110 | - $args['options'] = 'group' == $args['type'] ? wp_parse_args( $args['options'], array( |
|
| 1110 | + $args[ 'options' ] = 'group' == $args[ 'type' ] ? wp_parse_args( $args[ 'options' ], array( |
|
| 1111 | 1111 | 'add_button' => __( 'Add Group', 'cmb2' ), |
| 1112 | 1112 | 'remove_button' => __( 'Remove Group', 'cmb2' ), |
| 1113 | - ) ) : $args['options']; |
|
| 1113 | + ) ) : $args[ 'options' ]; |
|
| 1114 | 1114 | |
| 1115 | - $args['_id'] = $args['id']; |
|
| 1116 | - $args['_name'] = $args['id']; |
|
| 1115 | + $args[ '_id' ] = $args[ 'id' ]; |
|
| 1116 | + $args[ '_name' ] = $args[ 'id' ]; |
|
| 1117 | 1117 | |
| 1118 | 1118 | if ( $this->group ) { |
| 1119 | 1119 | |
| 1120 | - $args['id'] = $this->group->args( 'id' ) . '_' . $this->group->index . '_' . $args['id']; |
|
| 1121 | - $args['_name'] = $this->group->args( 'id' ) . '[' . $this->group->index . '][' . $args['_name'] . ']'; |
|
| 1120 | + $args[ 'id' ] = $this->group->args( 'id' ) . '_' . $this->group->index . '_' . $args[ 'id' ]; |
|
| 1121 | + $args[ '_name' ] = $this->group->args( 'id' ) . '[' . $this->group->index . '][' . $args[ '_name' ] . ']'; |
|
| 1122 | 1122 | } |
| 1123 | 1123 | |
| 1124 | - if ( 'wysiwyg' == $args['type'] ) { |
|
| 1125 | - $args['id'] = strtolower( str_ireplace( '-', '_', $args['id'] ) ); |
|
| 1126 | - $args['options']['textarea_name'] = $args['_name']; |
|
| 1124 | + if ( 'wysiwyg' == $args[ 'type' ] ) { |
|
| 1125 | + $args[ 'id' ] = strtolower( str_ireplace( '-', '_', $args[ 'id' ] ) ); |
|
| 1126 | + $args[ 'options' ][ 'textarea_name' ] = $args[ '_name' ]; |
|
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 1129 | 1129 | $option_types = apply_filters( 'cmb2_all_or_nothing_types', array( 'select', 'radio', 'radio_inline', 'taxonomy_select', 'taxonomy_radio', 'taxonomy_radio_inline' ), $this ); |
| 1130 | 1130 | |
| 1131 | - if ( in_array( $args['type'], $option_types, true ) ) { |
|
| 1131 | + if ( in_array( $args[ 'type' ], $option_types, true ) ) { |
|
| 1132 | 1132 | |
| 1133 | - $args['show_option_none'] = isset( $args['show_option_none'] ) ? $args['show_option_none'] : null; |
|
| 1134 | - $args['show_option_none'] = true === $args['show_option_none'] ? __( 'None', 'cmb2' ) : $args['show_option_none']; |
|
| 1133 | + $args[ 'show_option_none' ] = isset( $args[ 'show_option_none' ] ) ? $args[ 'show_option_none' ] : null; |
|
| 1134 | + $args[ 'show_option_none' ] = true === $args[ 'show_option_none' ] ? __( 'None', 'cmb2' ) : $args[ 'show_option_none' ]; |
|
| 1135 | 1135 | |
| 1136 | - if ( null === $args['show_option_none'] ) { |
|
| 1137 | - $off_by_default = in_array( $args['type'], array( 'select', 'radio', 'radio_inline' ), true ); |
|
| 1138 | - $args['show_option_none'] = $off_by_default ? false : __( 'None', 'cmb2' ); |
|
| 1136 | + if ( null === $args[ 'show_option_none' ] ) { |
|
| 1137 | + $off_by_default = in_array( $args[ 'type' ], array( 'select', 'radio', 'radio_inline' ), true ); |
|
| 1138 | + $args[ 'show_option_none' ] = $off_by_default ? false : __( 'None', 'cmb2' ); |
|
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | 1141 | } |
| 1142 | 1142 | |
| 1143 | - $args['has_supporting_data'] = in_array( |
|
| 1144 | - $args['type'], |
|
| 1143 | + $args[ 'has_supporting_data' ] = in_array( |
|
| 1144 | + $args[ 'type' ], |
|
| 1145 | 1145 | array( |
| 1146 | 1146 | // CMB2_Sanitize::_save_file_id_value()/CMB2_Sanitize::_get_group_file_value_array() |
| 1147 | 1147 | 'file', |
@@ -1173,10 +1173,10 @@ discard block |
||
| 1173 | 1173 | 'cmb_id' => $this->cmb_id, |
| 1174 | 1174 | ); |
| 1175 | 1175 | |
| 1176 | - if ( isset( $field_args['field_args'] ) ) { |
|
| 1176 | + if ( isset( $field_args[ 'field_args' ] ) ) { |
|
| 1177 | 1177 | $args = wp_parse_args( $field_args, $args ); |
| 1178 | 1178 | } else { |
| 1179 | - $args['field_args'] = wp_parse_args( $field_args, $this->args ); |
|
| 1179 | + $args[ 'field_args' ] = wp_parse_args( $field_args, $this->args ); |
|
| 1180 | 1180 | } |
| 1181 | 1181 | |
| 1182 | 1182 | return new CMB2_Field( $args ); |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | $dir = wp_upload_dir(); |
| 31 | 31 | |
| 32 | 32 | // Is URL in uploads directory? |
| 33 | - if ( false === strpos( $img_url, $dir['baseurl'] . '/' ) ) { |
|
| 33 | + if ( false === strpos( $img_url, $dir[ 'baseurl' ] . '/' ) ) { |
|
| 34 | 34 | return false; |
| 35 | 35 | } |
| 36 | 36 | |
@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | foreach ( $query->posts as $post_id ) { |
| 57 | 57 | $meta = wp_get_attachment_metadata( $post_id ); |
| 58 | - $original_file = basename( $meta['file'] ); |
|
| 59 | - $cropped_image_files = isset( $meta['sizes'] ) ? wp_list_pluck( $meta['sizes'], 'file' ) : array(); |
|
| 58 | + $original_file = basename( $meta[ 'file' ] ); |
|
| 59 | + $cropped_image_files = isset( $meta[ 'sizes' ] ) ? wp_list_pluck( $meta[ 'sizes' ], 'file' ) : array(); |
|
| 60 | 60 | if ( $original_file === $file || in_array( $file, $cropped_image_files ) ) { |
| 61 | 61 | $attachment_id = $post_id; |
| 62 | 62 | break; |
@@ -140,8 +140,7 @@ discard block |
||
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | return $this->is_valid_time_stamp( $string ) |
| 143 | - ? (int) $string : |
|
| 144 | - strtotime( (string) $string ); |
|
| 143 | + ? (int) $string : strtotime( (string) $string ); |
|
| 145 | 144 | } |
| 146 | 145 | |
| 147 | 146 | /** |
@@ -172,7 +171,7 @@ discard block |
||
| 172 | 171 | * @param mixed $value Value to check |
| 173 | 172 | * @return bool True or false |
| 174 | 173 | */ |
| 175 | - public function notempty( $value ){ |
|
| 174 | + public function notempty( $value ) { |
|
| 176 | 175 | return null !== $value && '' !== $value && false !== $value; |
| 177 | 176 | } |
| 178 | 177 | |
@@ -322,24 +321,24 @@ discard block |
||
| 322 | 321 | |
| 323 | 322 | // order is relevant here, since the replacement will be done sequentially. |
| 324 | 323 | $supported_options = array( |
| 325 | - 'd' => 'dd', // Day, leading 0 |
|
| 326 | - 'j' => 'd', // Day, no 0 |
|
| 327 | - 'z' => 'o', // Day of the year, no leading zeroes, |
|
| 324 | + 'd' => 'dd', // Day, leading 0 |
|
| 325 | + 'j' => 'd', // Day, no 0 |
|
| 326 | + 'z' => 'o', // Day of the year, no leading zeroes, |
|
| 328 | 327 | // 'D' => 'D', // Day name short, not sure how it'll work with translations |
| 329 | 328 | // 'l' => 'DD', // Day name full, idem before |
| 330 | - 'm' => 'mm', // Month of the year, leading 0 |
|
| 331 | - 'n' => 'm', // Month of the year, no leading 0 |
|
| 329 | + 'm' => 'mm', // Month of the year, leading 0 |
|
| 330 | + 'n' => 'm', // Month of the year, no leading 0 |
|
| 332 | 331 | // 'M' => 'M', // Month, Short name |
| 333 | 332 | // 'F' => 'MM', // Month, full name, |
| 334 | - 'y' => 'y', // Year, two digit |
|
| 335 | - 'Y' => 'yy', // Year, full |
|
| 336 | - 'H' => 'HH', // Hour with leading 0 (24 hour) |
|
| 337 | - 'G' => 'H', // Hour with no leading 0 (24 hour) |
|
| 338 | - 'h' => 'hh', // Hour with leading 0 (12 hour) |
|
| 339 | - 'g' => 'h', // Hour with no leading 0 (12 hour), |
|
| 340 | - 'i' => 'mm', // Minute with leading 0, |
|
| 341 | - 's' => 'ss', // Second with leading 0, |
|
| 342 | - 'a' => 'tt', // am/pm |
|
| 333 | + 'y' => 'y', // Year, two digit |
|
| 334 | + 'Y' => 'yy', // Year, full |
|
| 335 | + 'H' => 'HH', // Hour with leading 0 (24 hour) |
|
| 336 | + 'G' => 'H', // Hour with no leading 0 (24 hour) |
|
| 337 | + 'h' => 'hh', // Hour with leading 0 (12 hour) |
|
| 338 | + 'g' => 'h', // Hour with no leading 0 (12 hour), |
|
| 339 | + 'i' => 'mm', // Minute with leading 0, |
|
| 340 | + 's' => 'ss', // Second with leading 0, |
|
| 341 | + 'a' => 'tt', // am/pm |
|
| 343 | 342 | 'A' => 'TT' // AM/PM |
| 344 | 343 | ); |
| 345 | 344 | |
@@ -360,7 +359,7 @@ discard block |
||
| 360 | 359 | * @return string Modified value |
| 361 | 360 | */ |
| 362 | 361 | public function wrap_escaped_chars( $value ) { |
| 363 | - return "'" . str_replace( '\\', '', $value[0] ) . "'"; |
|
| 362 | + return "'" . str_replace( '\\', '', $value[ 0 ] ) . "'"; |
|
| 364 | 363 | } |
| 365 | 364 | |
| 366 | 365 | /** |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | public function render() { |
| 16 | 16 | $names = $this->get_object_terms(); |
| 17 | 17 | |
| 18 | - $saved_term = is_wp_error( $names ) || empty( $names ) ? $this->field->get_default() : $names[key( $names )]->slug; |
|
| 18 | + $saved_term = is_wp_error( $names ) || empty( $names ) ? $this->field->get_default() : $names[ key( $names ) ]->slug; |
|
| 19 | 19 | $terms = $this->get_terms(); |
| 20 | 20 | $options = ''; |
| 21 | 21 | $option_none = $this->field->args( 'show_option_none' ); |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | ), $this->args ); |
| 30 | 30 | |
| 31 | 31 | return $this->rendered( |
| 32 | - sprintf( '<%1$s %2$s>%3$s</%1$s>%4$s', $a['tag'], $this->concat_attrs( $a, array( 'tag', 'name', 'desc' ) ), $a['name'], $a['desc'] ) |
|
| 32 | + sprintf( '<%1$s %2$s>%3$s</%1$s>%4$s', $a[ 'tag' ], $this->concat_attrs( $a, array( 'tag', 'name', 'desc' ) ), $a[ 'name' ], $a[ 'desc' ] ) |
|
| 33 | 33 | ); |
| 34 | 34 | } |
| 35 | 35 | |
@@ -59,12 +59,12 @@ discard block |
||
| 59 | 59 | public function oembed_handler() { |
| 60 | 60 | |
| 61 | 61 | // Verify our nonce |
| 62 | - if ( ! ( isset( $_REQUEST['cmb2_ajax_nonce'], $_REQUEST['oembed_url'] ) && wp_verify_nonce( $_REQUEST['cmb2_ajax_nonce'], 'ajax_nonce' ) ) ) { |
|
| 62 | + if ( ! ( isset( $_REQUEST[ 'cmb2_ajax_nonce' ], $_REQUEST[ 'oembed_url' ] ) && wp_verify_nonce( $_REQUEST[ 'cmb2_ajax_nonce' ], 'ajax_nonce' ) ) ) { |
|
| 63 | 63 | die(); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // Sanitize our search string |
| 67 | - $oembed_string = sanitize_text_field( $_REQUEST['oembed_url'] ); |
|
| 67 | + $oembed_string = sanitize_text_field( $_REQUEST[ 'oembed_url' ] ); |
|
| 68 | 68 | |
| 69 | 69 | // Send back error if empty |
| 70 | 70 | if ( empty( $oembed_string ) ) { |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // Set width of embed |
| 75 | - $embed_width = isset( $_REQUEST['oembed_width'] ) && intval( $_REQUEST['oembed_width'] ) < 640 ? intval( $_REQUEST['oembed_width'] ) : '640'; |
|
| 75 | + $embed_width = isset( $_REQUEST[ 'oembed_width' ] ) && intval( $_REQUEST[ 'oembed_width' ] ) < 640 ? intval( $_REQUEST[ 'oembed_width' ] ) : '640'; |
|
| 76 | 76 | |
| 77 | 77 | // Set url |
| 78 | 78 | $oembed_url = esc_url( $oembed_string ); |
@@ -85,10 +85,10 @@ discard block |
||
| 85 | 85 | // Get embed code (or fallback link) |
| 86 | 86 | $html = $this->get_oembed( array( |
| 87 | 87 | 'url' => $oembed_url, |
| 88 | - 'object_id' => $_REQUEST['object_id'], |
|
| 89 | - 'object_type' => isset( $_REQUEST['object_type'] ) ? $_REQUEST['object_type'] : 'post', |
|
| 88 | + 'object_id' => $_REQUEST[ 'object_id' ], |
|
| 89 | + 'object_type' => isset( $_REQUEST[ 'object_type' ] ) ? $_REQUEST[ 'object_type' ] : 'post', |
|
| 90 | 90 | 'oembed_args' => $embed_args, |
| 91 | - 'field_id' => $_REQUEST['field_id'], |
|
| 91 | + 'field_id' => $_REQUEST[ 'field_id' ], |
|
| 92 | 92 | ) ); |
| 93 | 93 | |
| 94 | 94 | wp_send_json_success( $html ); |
@@ -103,10 +103,10 @@ discard block |
||
| 103 | 103 | public function get_oembed_no_edit( $args ) { |
| 104 | 104 | global $wp_embed; |
| 105 | 105 | |
| 106 | - $oembed_url = esc_url( $args['url'] ); |
|
| 106 | + $oembed_url = esc_url( $args[ 'url' ] ); |
|
| 107 | 107 | |
| 108 | 108 | // Sanitize object_id |
| 109 | - $this->object_id = is_numeric( $args['object_id'] ) ? absint( $args['object_id'] ) : sanitize_text_field( $args['object_id'] ); |
|
| 109 | + $this->object_id = is_numeric( $args[ 'object_id' ] ) ? absint( $args[ 'object_id' ] ) : sanitize_text_field( $args[ 'object_id' ] ); |
|
| 110 | 110 | |
| 111 | 111 | $args = wp_parse_args( $args, array( |
| 112 | 112 | 'object_type' => 'post', |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | 'wp_error' => false, |
| 116 | 116 | ) ); |
| 117 | 117 | |
| 118 | - $this->embed_args =& $args; |
|
| 118 | + $this->embed_args = & $args; |
|
| 119 | 119 | |
| 120 | 120 | /** |
| 121 | 121 | * Set the post_ID so oEmbed won't fail |
@@ -124,9 +124,9 @@ discard block |
||
| 124 | 124 | $wp_embed->post_ID = $this->object_id; |
| 125 | 125 | |
| 126 | 126 | // Special scenario if NOT a post object |
| 127 | - if ( isset( $args['object_type'] ) && 'post' != $args['object_type'] ) { |
|
| 127 | + if ( isset( $args[ 'object_type' ] ) && 'post' != $args[ 'object_type' ] ) { |
|
| 128 | 128 | |
| 129 | - if ( 'options-page' == $args['object_type'] ) { |
|
| 129 | + if ( 'options-page' == $args[ 'object_type' ] ) { |
|
| 130 | 130 | |
| 131 | 131 | // Bogus id to pass some numeric checks. Issue with a VERY large WP install? |
| 132 | 132 | $wp_embed->post_ID = 1987645321; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | // Ok, we need to hijack the oembed cache system |
| 136 | 136 | $this->hijack = true; |
| 137 | - $this->object_type = $args['object_type']; |
|
| 137 | + $this->object_type = $args[ 'object_type' ]; |
|
| 138 | 138 | |
| 139 | 139 | // Gets ombed cache from our object's meta (vs postmeta) |
| 140 | 140 | add_filter( 'get_post_metadata', array( $this, 'hijack_oembed_cache_get' ), 10, 3 ); |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | $embed_args = ''; |
| 148 | 148 | |
| 149 | - foreach ( $args['oembed_args'] as $key => $val ) { |
|
| 149 | + foreach ( $args[ 'oembed_args' ] as $key => $val ) { |
|
| 150 | 150 | $embed_args .= " $key=\"$val\""; |
| 151 | 151 | } |
| 152 | 152 | |
@@ -169,12 +169,12 @@ discard block |
||
| 169 | 169 | $oembed = $this->get_oembed_no_edit( $args ); |
| 170 | 170 | |
| 171 | 171 | // Send back our embed |
| 172 | - if ( $oembed['embed'] && $oembed['embed'] != $oembed['fallback'] ) { |
|
| 173 | - return '<div class="cmb2-oembed embed-status">' . $oembed['embed'] . '<p class="cmb2-remove-wrapper"><a href="#" class="cmb2-remove-file-button" rel="' . $oembed['args']['field_id'] . '">' . __( 'Remove Embed', 'cmb2' ) . '</a></p></div>'; |
|
| 172 | + if ( $oembed[ 'embed' ] && $oembed[ 'embed' ] != $oembed[ 'fallback' ] ) { |
|
| 173 | + return '<div class="cmb2-oembed embed-status">' . $oembed[ 'embed' ] . '<p class="cmb2-remove-wrapper"><a href="#" class="cmb2-remove-file-button" rel="' . $oembed[ 'args' ][ 'field_id' ] . '">' . __( 'Remove Embed', 'cmb2' ) . '</a></p></div>'; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | // Otherwise, send back error info that no oEmbeds were found |
| 177 | - return '<p class="ui-state-error-text">' . sprintf( __( 'No oEmbed Results Found for %s. View more info at', 'cmb2' ), $oembed['fallback'] ) . ' <a href="http://codex.wordpress.org/Embeds" target="_blank">codex.wordpress.org/Embeds</a>.</p>'; |
|
| 177 | + return '<p class="ui-state-error-text">' . sprintf( __( 'No oEmbed Results Found for %s. View more info at', 'cmb2' ), $oembed[ 'fallback' ] ) . ' <a href="http://codex.wordpress.org/Embeds" target="_blank">codex.wordpress.org/Embeds</a>.</p>'; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -236,15 +236,15 @@ discard block |
||
| 236 | 236 | */ |
| 237 | 237 | protected function cache_action( $meta_key ) { |
| 238 | 238 | $func_args = func_get_args(); |
| 239 | - $action = isset( $func_args[1] ) ? 'update' : 'get'; |
|
| 239 | + $action = isset( $func_args[ 1 ] ) ? 'update' : 'get'; |
|
| 240 | 240 | |
| 241 | 241 | if ( 'options-page' === $this->object_type ) { |
| 242 | 242 | |
| 243 | 243 | $args = array( $meta_key ); |
| 244 | 244 | |
| 245 | 245 | if ( 'update' === $action ) { |
| 246 | - $args[] = $func_args[1]; |
|
| 247 | - $args[] = true; |
|
| 246 | + $args[ ] = $func_args[ 1 ]; |
|
| 247 | + $args[ ] = true; |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | // Cache the result to our options |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | } else { |
| 253 | 253 | |
| 254 | 254 | $args = array( $this->object_type, $this->object_id, $meta_key ); |
| 255 | - $args[] = 'update' === $action ? $func_args : true; |
|
| 255 | + $args[ ] = 'update' === $action ? $func_args : true; |
|
| 256 | 256 | |
| 257 | 257 | // Cache the result to our metadata |
| 258 | 258 | $status = call_user_func_array( $action . '_metadata', $args ); |