@@ -22,12 +22,12 @@ discard block |
||
| 22 | 22 | 'select_timezone' => array(), |
| 23 | 23 | ) ); |
| 24 | 24 | |
| 25 | - $args['value'] = $field->escaped_value(); |
|
| 26 | - if ( is_array( $args['value'] ) ) { |
|
| 27 | - $args['value'] = ''; |
|
| 25 | + $args[ 'value' ] = $field->escaped_value(); |
|
| 26 | + if ( is_array( $args[ 'value' ] ) ) { |
|
| 27 | + $args[ 'value' ] = ''; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - $datetime = maybe_unserialize( $args['value'] ); |
|
| 30 | + $datetime = maybe_unserialize( $args[ 'value' ] ); |
|
| 31 | 31 | $value = $tzstring = ''; |
| 32 | 32 | |
| 33 | 33 | if ( $datetime && $datetime instanceof DateTime ) { |
@@ -36,19 +36,19 @@ discard block |
||
| 36 | 36 | $value = $datetime->getTimestamp(); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - $timestamp_args = wp_parse_args( $args['text_datetime_timestamp'], array( |
|
| 39 | + $timestamp_args = wp_parse_args( $args[ 'text_datetime_timestamp' ], array( |
|
| 40 | 40 | 'desc' => '', |
| 41 | 41 | 'value' => $value, |
| 42 | 42 | 'rendered' => true, |
| 43 | 43 | ) ); |
| 44 | 44 | $datetime_timestamp = $this->types->text_datetime_timestamp( $timestamp_args ); |
| 45 | 45 | |
| 46 | - $timezone_select_args = wp_parse_args( $args['select_timezone'], array( |
|
| 46 | + $timezone_select_args = wp_parse_args( $args[ 'select_timezone' ], array( |
|
| 47 | 47 | 'class' => 'cmb2_select cmb2-select-timezone', |
| 48 | 48 | 'name' => $this->_name( '[timezone]' ), |
| 49 | 49 | 'id' => $this->_id( '_timezone' ), |
| 50 | 50 | 'options' => wp_timezone_choice( $tzstring ), |
| 51 | - 'desc' => $args['desc'], |
|
| 51 | + 'desc' => $args[ 'desc' ], |
|
| 52 | 52 | 'rendered' => true, |
| 53 | 53 | ) ); |
| 54 | 54 | $select = $this->types->select( $timezone_select_args ); |
@@ -22,16 +22,16 @@ discard block |
||
| 22 | 22 | 'timepicker' => array(), |
| 23 | 23 | ) ); |
| 24 | 24 | |
| 25 | - if ( empty( $args['value'] ) ) { |
|
| 26 | - $args['value'] = $field->escaped_value(); |
|
| 25 | + if ( empty( $args[ 'value' ] ) ) { |
|
| 26 | + $args[ 'value' ] = $field->escaped_value(); |
|
| 27 | 27 | // This will be used if there is a select_timezone set for this field |
| 28 | 28 | $tz_offset = $field->field_timezone_offset(); |
| 29 | 29 | if ( ! empty( $tz_offset ) ) { |
| 30 | - $args['value'] -= $tz_offset; |
|
| 30 | + $args[ 'value' ] -= $tz_offset; |
|
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - $has_good_value = ! empty( $args['value'] ) && ! is_array( $args['value'] ); |
|
| 34 | + $has_good_value = ! empty( $args[ 'value' ] ) && ! is_array( $args[ 'value' ] ); |
|
| 35 | 35 | |
| 36 | 36 | $date_input = parent::render( $this->date_args( $args, $has_good_value ) ); |
| 37 | 37 | $time_input = parent::render( $this->time_args( $args, $has_good_value ) ); |
@@ -40,31 +40,31 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function date_args( $args, $has_good_value ) { |
| 43 | - $date_args = wp_parse_args( $args['datepicker'], array( |
|
| 43 | + $date_args = wp_parse_args( $args[ 'datepicker' ], array( |
|
| 44 | 44 | 'class' => 'cmb2-text-small cmb2-datepicker', |
| 45 | 45 | 'name' => $this->_name( '[date]' ), |
| 46 | 46 | 'id' => $this->_id( '_date' ), |
| 47 | - 'value' => $has_good_value ? $this->field->get_timestamp_format( 'date_format', $args['value'] ) : '', |
|
| 47 | + 'value' => $has_good_value ? $this->field->get_timestamp_format( 'date_format', $args[ 'value' ] ) : '', |
|
| 48 | 48 | 'desc' => '', |
| 49 | 49 | ) ); |
| 50 | 50 | |
| 51 | - $date_args['rendered'] = true; |
|
| 51 | + $date_args[ 'rendered' ] = true; |
|
| 52 | 52 | |
| 53 | 53 | // Let's get the date-format, and set it up as a data attr for the field. |
| 54 | 54 | return $this->parse_picker_options( 'date', $date_args ); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | public function time_args( $args, $has_good_value ) { |
| 58 | - $time_args = wp_parse_args( $args['timepicker'], array( |
|
| 58 | + $time_args = wp_parse_args( $args[ 'timepicker' ], array( |
|
| 59 | 59 | 'class' => 'cmb2-timepicker text-time', |
| 60 | 60 | 'name' => $this->_name( '[time]' ), |
| 61 | 61 | 'id' => $this->_id( '_time' ), |
| 62 | - 'value' => $has_good_value ? $this->field->get_timestamp_format( 'time_format', $args['value'] ) : '', |
|
| 63 | - 'desc' => $args['desc'], |
|
| 62 | + 'value' => $has_good_value ? $this->field->get_timestamp_format( 'time_format', $args[ 'value' ] ) : '', |
|
| 63 | + 'desc' => $args[ 'desc' ], |
|
| 64 | 64 | 'js_dependencies' => array( 'jquery-ui-core', 'jquery-ui-datepicker', 'jquery-ui-datetimepicker' ), |
| 65 | 65 | ) ); |
| 66 | 66 | |
| 67 | - $time_args['rendered'] = true; |
|
| 67 | + $time_args[ 'rendered' ] = true; |
|
| 68 | 68 | |
| 69 | 69 | // Let's get the time-format, and set it up as a data attr for the field. |
| 70 | 70 | return $this->parse_picker_options( 'time', $time_args ); |
@@ -39,6 +39,9 @@ discard block |
||
| 39 | 39 | return $this->rendered( $date_input . "\n" . $time_input ); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | + /** |
|
| 43 | + * @param boolean $has_good_value |
|
| 44 | + */ |
|
| 42 | 45 | public function date_args( $args, $has_good_value ) { |
| 43 | 46 | $date_args = wp_parse_args( $args['datepicker'], array( |
| 44 | 47 | 'class' => 'cmb2-text-small cmb2-datepicker', |
@@ -54,6 +57,9 @@ discard block |
||
| 54 | 57 | return $this->parse_picker_options( 'date', $date_args ); |
| 55 | 58 | } |
| 56 | 59 | |
| 60 | + /** |
|
| 61 | + * @param boolean $has_good_value |
|
| 62 | + */ |
|
| 57 | 63 | public function time_args( $args, $has_good_value ) { |
| 58 | 64 | $time_args = wp_parse_args( $args['timepicker'], array( |
| 59 | 65 | 'class' => 'cmb2-timepicker text-time', |
@@ -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 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | /** |
| 53 | 53 | * Stores the rendered field output. |
| 54 | 54 | * @since 2.2.2 |
| 55 | - * @param string|CMB2_Type_Base $rendered Rendered output. |
|
| 55 | + * @param string $rendered Rendered output. |
|
| 56 | 56 | * @return string|CMB2_Type_Base Rendered output or this object. |
| 57 | 57 | */ |
| 58 | 58 | public function rendered( $rendered ) { |
@@ -107,7 +107,6 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | /** |
| 109 | 109 | * Fall back to CMB2_Types methods |
| 110 | - * @param string $field |
|
| 111 | 110 | * @throws Exception Throws an exception if the field is invalid. |
| 112 | 111 | * @return mixed |
| 113 | 112 | */ |
@@ -128,7 +127,7 @@ discard block |
||
| 128 | 127 | * Magic getter for our object. |
| 129 | 128 | * @param string $field |
| 130 | 129 | * @throws Exception Throws an exception if the field is invalid. |
| 131 | - * @return mixed |
|
| 130 | + * @return CMB2_Field |
|
| 132 | 131 | */ |
| 133 | 132 | public function __get( $field ) { |
| 134 | 133 | switch ( $field ) { |
@@ -50,12 +50,12 @@ |
||
| 50 | 50 | 'js_dependencies' => array(), |
| 51 | 51 | ), $args ); |
| 52 | 52 | |
| 53 | - if ( ! empty( $a['js_dependencies'] ) ) { |
|
| 54 | - $this->field->add_js_dependencies( $a['js_dependencies'] ); |
|
| 53 | + if ( ! empty( $a[ 'js_dependencies' ] ) ) { |
|
| 54 | + $this->field->add_js_dependencies( $a[ 'js_dependencies' ] ); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | return $this->rendered( |
| 58 | - sprintf( '<input%s/>%s', $this->concat_attrs( $a, array( 'desc', 'js_dependencies' ) ), $a['desc'] ) |
|
| 58 | + sprintf( '<input%s/>%s', $this->concat_attrs( $a, array( 'desc', 'js_dependencies' ) ), $a[ 'desc' ] ) |
|
| 59 | 59 | ); |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -735,7 +735,7 @@ discard block |
||
| 735 | 735 | * Return a formatted timestamp for a field |
| 736 | 736 | * @since 2.0.0 |
| 737 | 737 | * @param string $format Either date_format or time_format |
| 738 | - * @param string $meta_value Optional meta value to check |
|
| 738 | + * @param integer $meta_value Optional meta value to check |
|
| 739 | 739 | * @return string Formatted date |
| 740 | 740 | */ |
| 741 | 741 | public function get_timestamp_format( $format = 'date_format', $meta_value = 0 ) { |
@@ -1007,7 +1007,7 @@ discard block |
||
| 1007 | 1007 | * Retrieve options args. Calls options_cb if it exists. |
| 1008 | 1008 | * @since 2.0.0 |
| 1009 | 1009 | * @param string $key Specific option to retrieve |
| 1010 | - * @return array Array of options |
|
| 1010 | + * @return string Array of options |
|
| 1011 | 1011 | */ |
| 1012 | 1012 | public function options( $key = '' ) { |
| 1013 | 1013 | if ( ! empty( $this->field_options ) ) { |
@@ -112,21 +112,21 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | public function __construct( $args ) { |
| 114 | 114 | |
| 115 | - if ( ! empty( $args['group_field'] ) ) { |
|
| 116 | - $this->group = $args['group_field']; |
|
| 115 | + if ( ! empty( $args[ 'group_field' ] ) ) { |
|
| 116 | + $this->group = $args[ 'group_field' ]; |
|
| 117 | 117 | $this->object_id = $this->group->object_id; |
| 118 | 118 | $this->object_type = $this->group->object_type; |
| 119 | 119 | $this->cmb_id = $this->group->cmb_id; |
| 120 | 120 | } else { |
| 121 | - $this->object_id = isset( $args['object_id'] ) && '_' !== $args['object_id'] ? $args['object_id'] : 0; |
|
| 122 | - $this->object_type = isset( $args['object_type'] ) ? $args['object_type'] : 'post'; |
|
| 121 | + $this->object_id = isset( $args[ 'object_id' ] ) && '_' !== $args[ 'object_id' ] ? $args[ 'object_id' ] : 0; |
|
| 122 | + $this->object_type = isset( $args[ 'object_type' ] ) ? $args[ 'object_type' ] : 'post'; |
|
| 123 | 123 | |
| 124 | - if ( isset( $args['cmb_id'] ) ) { |
|
| 125 | - $this->cmb_id = $args['cmb_id']; |
|
| 124 | + if ( isset( $args[ 'cmb_id' ] ) ) { |
|
| 125 | + $this->cmb_id = $args[ 'cmb_id' ]; |
|
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - $this->args = $this->_set_field_defaults( $args['field_args'], $args ); |
|
| 129 | + $this->args = $this->_set_field_defaults( $args[ 'field_args' ], $args ); |
|
| 130 | 130 | |
| 131 | 131 | if ( $this->object_id ) { |
| 132 | 132 | $this->value = $this->get_data(); |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | return call_user_func_array( array( $this, 'get_string' ), $arguments ); |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - $key = isset( $arguments[0] ) ? $arguments[0] : false; |
|
| 148 | + $key = isset( $arguments[ 0 ] ) ? $arguments[ 0 ] : false; |
|
| 149 | 149 | return $this->args( $name, $key ); |
| 150 | 150 | } |
| 151 | 151 | |
@@ -216,9 +216,9 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | public function get_data( $field_id = '', $args = array() ) { |
| 218 | 218 | if ( $field_id ) { |
| 219 | - $args['field_id'] = $field_id; |
|
| 219 | + $args[ 'field_id' ] = $field_id; |
|
| 220 | 220 | } else if ( $this->group ) { |
| 221 | - $args['field_id'] = $this->group->id(); |
|
| 221 | + $args[ 'field_id' ] = $this->group->id(); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | $a = $this->data_args( $args ); |
@@ -259,13 +259,13 @@ discard block |
||
| 259 | 259 | * |
| 260 | 260 | * @since 2.0.0 |
| 261 | 261 | */ |
| 262 | - $data = apply_filters( "cmb2_override_{$a['field_id']}_meta_value", $data, $this->object_id, $a, $this ); |
|
| 262 | + $data = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_value", $data, $this->object_id, $a, $this ); |
|
| 263 | 263 | |
| 264 | 264 | // If no override, get value normally |
| 265 | 265 | if ( 'cmb2_field_no_override_val' === $data ) { |
| 266 | - $data = 'options-page' === $a['type'] |
|
| 267 | - ? cmb2_options( $a['id'] )->get( $a['field_id'] ) |
|
| 268 | - : get_metadata( $a['type'], $a['id'], $a['field_id'], ( $a['single'] || $a['repeat'] ) ); |
|
| 266 | + $data = 'options-page' === $a[ 'type' ] |
|
| 267 | + ? cmb2_options( $a[ 'id' ] )->get( $a[ 'field_id' ] ) |
|
| 268 | + : get_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], ( $a[ 'single' ] || $a[ 'repeat' ] ) ); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | if ( $this->group ) { |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | public function update_data( $new_value, $single = true ) { |
| 288 | 288 | $a = $this->data_args( array( 'single' => $single ) ); |
| 289 | 289 | |
| 290 | - $a['value'] = $a['repeat'] ? array_values( $new_value ) : $new_value; |
|
| 290 | + $a[ 'value' ] = $a[ 'repeat' ] ? array_values( $new_value ) : $new_value; |
|
| 291 | 291 | |
| 292 | 292 | /** |
| 293 | 293 | * Filter whether to override saving of meta value. |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | * |
| 324 | 324 | * @since 2.0.0 |
| 325 | 325 | */ |
| 326 | - $override = apply_filters( "cmb2_override_{$a['field_id']}_meta_save", $override, $a, $this->args(), $this ); |
|
| 326 | + $override = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_save", $override, $a, $this->args(), $this ); |
|
| 327 | 327 | |
| 328 | 328 | // If override, return that |
| 329 | 329 | if ( null !== $override ) { |
@@ -331,22 +331,22 @@ discard block |
||
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | // Options page handling (or temp data store) |
| 334 | - if ( 'options-page' === $a['type'] || empty( $a['id'] ) ) { |
|
| 335 | - return cmb2_options( $a['id'] )->update( $a['field_id'], $a['value'], false, $a['single'] ); |
|
| 334 | + if ( 'options-page' === $a[ 'type' ] || empty( $a[ 'id' ] ) ) { |
|
| 335 | + return cmb2_options( $a[ 'id' ] )->update( $a[ 'field_id' ], $a[ 'value' ], false, $a[ 'single' ] ); |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | // Add metadata if not single |
| 339 | - if ( ! $a['single'] ) { |
|
| 340 | - return add_metadata( $a['type'], $a['id'], $a['field_id'], $a['value'], false ); |
|
| 339 | + if ( ! $a[ 'single' ] ) { |
|
| 340 | + return add_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $a[ 'value' ], false ); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | // Delete meta if we have an empty array |
| 344 | - if ( is_array( $a['value'] ) && empty( $a['value'] ) ) { |
|
| 345 | - return delete_metadata( $a['type'], $a['id'], $a['field_id'], $this->value ); |
|
| 344 | + if ( is_array( $a[ 'value' ] ) && empty( $a[ 'value' ] ) ) { |
|
| 345 | + return delete_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $this->value ); |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | // Update metadata |
| 349 | - return update_metadata( $a['type'], $a['id'], $a['field_id'], $a['value'] ); |
|
| 349 | + return update_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $a[ 'value' ] ); |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | /** |
@@ -396,19 +396,19 @@ discard block |
||
| 396 | 396 | * @param array $field_args All field arguments |
| 397 | 397 | * @param CMB2_Field object $field This field object |
| 398 | 398 | */ |
| 399 | - $override = apply_filters( "cmb2_override_{$a['field_id']}_meta_remove", $override, $a, $this->args(), $this ); |
|
| 399 | + $override = apply_filters( "cmb2_override_{$a[ 'field_id' ]}_meta_remove", $override, $a, $this->args(), $this ); |
|
| 400 | 400 | |
| 401 | 401 | // If no override, remove as usual |
| 402 | 402 | if ( null !== $override ) { |
| 403 | 403 | return $override; |
| 404 | 404 | } |
| 405 | 405 | // Option page handling |
| 406 | - elseif ( 'options-page' === $a['type'] || empty( $a['id'] ) ) { |
|
| 407 | - return cmb2_options( $a['id'] )->remove( $a['field_id'] ); |
|
| 406 | + elseif ( 'options-page' === $a[ 'type' ] || empty( $a[ 'id' ] ) ) { |
|
| 407 | + return cmb2_options( $a[ 'id' ] )->remove( $a[ 'field_id' ] ); |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | // Remove metadata |
| 411 | - return delete_metadata( $a['type'], $a['id'], $a['field_id'], $old ); |
|
| 411 | + return delete_metadata( $a[ 'type' ], $a[ 'id' ], $a[ 'field_id' ], $old ); |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | /** |
@@ -859,7 +859,7 @@ discard block |
||
| 859 | 859 | |
| 860 | 860 | foreach ( $conditional_classes as $class => $condition ) { |
| 861 | 861 | if ( $condition ) { |
| 862 | - $classes[] = $class; |
|
| 862 | + $classes[ ] = $class; |
|
| 863 | 863 | } |
| 864 | 864 | } |
| 865 | 865 | |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | } |
| 871 | 871 | |
| 872 | 872 | if ( $added_classes ) { |
| 873 | - $classes[] = esc_attr( $added_classes ); |
|
| 873 | + $classes[ ] = esc_attr( $added_classes ); |
|
| 874 | 874 | } |
| 875 | 875 | |
| 876 | 876 | /** |
@@ -970,10 +970,10 @@ discard block |
||
| 970 | 970 | public function get_string( $text_key, $fallback ) { |
| 971 | 971 | // If null, populate with our field strings values. |
| 972 | 972 | if ( null === $this->strings ) { |
| 973 | - $this->strings = (array) $this->args['text']; |
|
| 973 | + $this->strings = (array) $this->args[ 'text' ]; |
|
| 974 | 974 | |
| 975 | - if ( is_callable( $this->args['text_cb'] ) ) { |
|
| 976 | - $strings = call_user_func( $this->args['text_cb'], $this ); |
|
| 975 | + if ( is_callable( $this->args[ 'text_cb' ] ) ) { |
|
| 976 | + $strings = call_user_func( $this->args[ 'text_cb' ], $this ); |
|
| 977 | 977 | |
| 978 | 978 | if ( $strings && is_array( $strings ) ) { |
| 979 | 979 | $this->strings += $strings; |
@@ -1007,10 +1007,10 @@ discard block |
||
| 1007 | 1007 | return $this->field_options; |
| 1008 | 1008 | } |
| 1009 | 1009 | |
| 1010 | - $this->field_options = (array) $this->args['options']; |
|
| 1010 | + $this->field_options = (array) $this->args[ 'options' ]; |
|
| 1011 | 1011 | |
| 1012 | - if ( is_callable( $this->args['options_cb'] ) ) { |
|
| 1013 | - $options = call_user_func( $this->args['options_cb'], $this ); |
|
| 1012 | + if ( is_callable( $this->args[ 'options_cb' ] ) ) { |
|
| 1013 | + $options = call_user_func( $this->args[ 'options_cb' ], $this ); |
|
| 1014 | 1014 | |
| 1015 | 1015 | if ( $options && is_array( $options ) ) { |
| 1016 | 1016 | $this->field_options = $options + $this->field_options; |
@@ -1031,7 +1031,7 @@ discard block |
||
| 1031 | 1031 | */ |
| 1032 | 1032 | public function add_js_dependencies( $dependencies = array() ) { |
| 1033 | 1033 | foreach ( (array) $dependencies as $dependency ) { |
| 1034 | - $this->args['js_dependencies'][ $dependency ] = $dependency; |
|
| 1034 | + $this->args[ 'js_dependencies' ][ $dependency ] = $dependency; |
|
| 1035 | 1035 | } |
| 1036 | 1036 | |
| 1037 | 1037 | CMB2_JS::add_dependencies( $dependencies ); |
@@ -1045,17 +1045,17 @@ discard block |
||
| 1045 | 1045 | * @return mixed Default field value |
| 1046 | 1046 | */ |
| 1047 | 1047 | public function get_default() { |
| 1048 | - if ( null !== $this->args['default'] ) { |
|
| 1049 | - return $this->args['default']; |
|
| 1048 | + if ( null !== $this->args[ 'default' ] ) { |
|
| 1049 | + return $this->args[ 'default' ]; |
|
| 1050 | 1050 | } |
| 1051 | 1051 | |
| 1052 | - $param = is_callable( $this->args['default_cb'] ) ? 'default_cb' : 'default'; |
|
| 1052 | + $param = is_callable( $this->args[ 'default_cb' ] ) ? 'default_cb' : 'default'; |
|
| 1053 | 1053 | $default = $this->get_param_callback_result( $param ); |
| 1054 | 1054 | |
| 1055 | 1055 | // Allow a filter override of the default value |
| 1056 | - $this->args['default'] = apply_filters( 'cmb2_default_filter', $default, $this ); |
|
| 1056 | + $this->args[ 'default' ] = apply_filters( 'cmb2_default_filter', $default, $this ); |
|
| 1057 | 1057 | |
| 1058 | - return $this->args['default']; |
|
| 1058 | + return $this->args[ 'default' ]; |
|
| 1059 | 1059 | } |
| 1060 | 1060 | |
| 1061 | 1061 | /** |
@@ -1085,18 +1085,18 @@ discard block |
||
| 1085 | 1085 | 'classes_cb' => '', |
| 1086 | 1086 | 'select_all_button' => true, |
| 1087 | 1087 | 'multiple' => false, |
| 1088 | - 'repeatable' => isset( $args['type'] ) && 'group' == $args['type'], |
|
| 1088 | + 'repeatable' => isset( $args[ 'type' ] ) && 'group' == $args[ 'type' ], |
|
| 1089 | 1089 | 'inline' => false, |
| 1090 | 1090 | 'on_front' => true, |
| 1091 | 1091 | 'show_names' => true, |
| 1092 | 1092 | 'save_field' => true, // Will not save if false |
| 1093 | 1093 | 'date_format' => 'm\/d\/Y', |
| 1094 | 1094 | 'time_format' => 'h:i A', |
| 1095 | - 'description' => isset( $args['desc'] ) ? $args['desc'] : '', |
|
| 1096 | - 'preview_size' => 'file' == $args['type'] ? array( 350, 350 ) : array( 50, 50 ), |
|
| 1095 | + 'description' => isset( $args[ 'desc' ] ) ? $args[ 'desc' ] : '', |
|
| 1096 | + 'preview_size' => 'file' == $args[ 'type' ] ? array( 350, 350 ) : array( 50, 50 ), |
|
| 1097 | 1097 | 'render_row_cb' => array( $this, 'render_field_callback' ), |
| 1098 | 1098 | 'display_cb' => array( $this, 'display_value_callback' ), |
| 1099 | - 'label_cb' => 'title' != $args['type'] ? array( $this, 'label' ) : '', |
|
| 1099 | + 'label_cb' => 'title' != $args[ 'type' ] ? array( $this, 'label' ) : '', |
|
| 1100 | 1100 | 'column' => false, |
| 1101 | 1101 | 'js_dependencies' => array(), |
| 1102 | 1102 | 'show_in_rest' => null, |
@@ -1111,44 +1111,44 @@ discard block |
||
| 1111 | 1111 | */ |
| 1112 | 1112 | $args = $this->convert_deprecated_params( $args ); |
| 1113 | 1113 | |
| 1114 | - $args['repeatable'] = $args['repeatable'] && ! $this->repeatable_exception( $args['type'] ); |
|
| 1115 | - $args['inline'] = $args['inline'] || false !== stripos( $args['type'], '_inline' ); |
|
| 1114 | + $args[ 'repeatable' ] = $args[ 'repeatable' ] && ! $this->repeatable_exception( $args[ 'type' ] ); |
|
| 1115 | + $args[ 'inline' ] = $args[ 'inline' ] || false !== stripos( $args[ 'type' ], '_inline' ); |
|
| 1116 | 1116 | |
| 1117 | - $args['options'] = 'group' == $args['type'] ? wp_parse_args( $args['options'], array( |
|
| 1117 | + $args[ 'options' ] = 'group' == $args[ 'type' ] ? wp_parse_args( $args[ 'options' ], array( |
|
| 1118 | 1118 | 'add_button' => esc_html__( 'Add Group', 'cmb2' ), |
| 1119 | 1119 | 'remove_button' => esc_html__( 'Remove Group', 'cmb2' ), |
| 1120 | - ) ) : $args['options']; |
|
| 1120 | + ) ) : $args[ 'options' ]; |
|
| 1121 | 1121 | |
| 1122 | - $args['_id'] = $args['id']; |
|
| 1123 | - $args['_name'] = $args['id']; |
|
| 1122 | + $args[ '_id' ] = $args[ 'id' ]; |
|
| 1123 | + $args[ '_name' ] = $args[ 'id' ]; |
|
| 1124 | 1124 | |
| 1125 | 1125 | if ( $this->group ) { |
| 1126 | 1126 | |
| 1127 | - $args['id'] = $this->group->args( 'id' ) . '_' . $this->group->index . '_' . $args['id']; |
|
| 1128 | - $args['_name'] = $this->group->args( 'id' ) . '[' . $this->group->index . '][' . $args['_name'] . ']'; |
|
| 1127 | + $args[ 'id' ] = $this->group->args( 'id' ) . '_' . $this->group->index . '_' . $args[ 'id' ]; |
|
| 1128 | + $args[ '_name' ] = $this->group->args( 'id' ) . '[' . $this->group->index . '][' . $args[ '_name' ] . ']'; |
|
| 1129 | 1129 | } |
| 1130 | 1130 | |
| 1131 | - if ( 'wysiwyg' == $args['type'] ) { |
|
| 1132 | - $args['id'] = strtolower( str_ireplace( '-', '_', $args['id'] ) ); |
|
| 1133 | - $args['options']['textarea_name'] = $args['_name']; |
|
| 1131 | + if ( 'wysiwyg' == $args[ 'type' ] ) { |
|
| 1132 | + $args[ 'id' ] = strtolower( str_ireplace( '-', '_', $args[ 'id' ] ) ); |
|
| 1133 | + $args[ 'options' ][ 'textarea_name' ] = $args[ '_name' ]; |
|
| 1134 | 1134 | } |
| 1135 | 1135 | |
| 1136 | 1136 | $option_types = apply_filters( 'cmb2_all_or_nothing_types', array( 'select', 'radio', 'radio_inline', 'taxonomy_select', 'taxonomy_radio', 'taxonomy_radio_inline' ), $this ); |
| 1137 | 1137 | |
| 1138 | - if ( in_array( $args['type'], $option_types, true ) ) { |
|
| 1138 | + if ( in_array( $args[ 'type' ], $option_types, true ) ) { |
|
| 1139 | 1139 | |
| 1140 | - $args['show_option_none'] = isset( $args['show_option_none'] ) ? $args['show_option_none'] : null; |
|
| 1141 | - $args['show_option_none'] = true === $args['show_option_none'] ? esc_html__( 'None', 'cmb2' ) : $args['show_option_none']; |
|
| 1140 | + $args[ 'show_option_none' ] = isset( $args[ 'show_option_none' ] ) ? $args[ 'show_option_none' ] : null; |
|
| 1141 | + $args[ 'show_option_none' ] = true === $args[ 'show_option_none' ] ? esc_html__( 'None', 'cmb2' ) : $args[ 'show_option_none' ]; |
|
| 1142 | 1142 | |
| 1143 | - if ( null === $args['show_option_none'] ) { |
|
| 1144 | - $off_by_default = in_array( $args['type'], array( 'select', 'radio', 'radio_inline' ), true ); |
|
| 1145 | - $args['show_option_none'] = $off_by_default ? false : esc_html__( 'None', 'cmb2' ); |
|
| 1143 | + if ( null === $args[ 'show_option_none' ] ) { |
|
| 1144 | + $off_by_default = in_array( $args[ 'type' ], array( 'select', 'radio', 'radio_inline' ), true ); |
|
| 1145 | + $args[ 'show_option_none' ] = $off_by_default ? false : esc_html__( 'None', 'cmb2' ); |
|
| 1146 | 1146 | } |
| 1147 | 1147 | |
| 1148 | 1148 | } |
| 1149 | 1149 | |
| 1150 | - $args['has_supporting_data'] = in_array( |
|
| 1151 | - $args['type'], |
|
| 1150 | + $args[ 'has_supporting_data' ] = in_array( |
|
| 1151 | + $args[ 'type' ], |
|
| 1152 | 1152 | array( |
| 1153 | 1153 | // CMB2_Sanitize::_save_file_id_value()/CMB2_Sanitize::_get_group_file_value_array() |
| 1154 | 1154 | 'file', |
@@ -1171,10 +1171,10 @@ discard block |
||
| 1171 | 1171 | protected function get_default_args( $field_args, $field_group = null ) { |
| 1172 | 1172 | $args = parent::get_default_args( array(), $this->group ); |
| 1173 | 1173 | |
| 1174 | - if ( isset( $field_args['field_args'] ) ) { |
|
| 1174 | + if ( isset( $field_args[ 'field_args' ] ) ) { |
|
| 1175 | 1175 | $args = wp_parse_args( $field_args, $args ); |
| 1176 | 1176 | } else { |
| 1177 | - $args['field_args'] = wp_parse_args( $field_args, $this->args ); |
|
| 1177 | + $args[ 'field_args' ] = wp_parse_args( $field_args, $this->args ); |
|
| 1178 | 1178 | } |
| 1179 | 1179 | |
| 1180 | 1180 | return $args; |
@@ -1217,43 +1217,43 @@ discard block |
||
| 1217 | 1217 | */ |
| 1218 | 1218 | protected function convert_deprecated_params( $args ) { |
| 1219 | 1219 | |
| 1220 | - if ( isset( $args['row_classes'] ) ) { |
|
| 1220 | + if ( isset( $args[ 'row_classes' ] ) ) { |
|
| 1221 | 1221 | |
| 1222 | 1222 | // We'll let this one be. |
| 1223 | 1223 | // $this->deprecated_param( __CLASS__ . '::__construct()', '2.2.3', self::DEPRECATED_PARAM, 'row_classes', 'classes' ); |
| 1224 | 1224 | |
| 1225 | 1225 | // row_classes param could be a callback. This is definitely deprecated. |
| 1226 | - if ( is_callable( $args['row_classes'] ) ) { |
|
| 1226 | + if ( is_callable( $args[ 'row_classes' ] ) ) { |
|
| 1227 | 1227 | |
| 1228 | 1228 | $this->deprecated_param( __CLASS__ . '::__construct()', '2.2.3', self::DEPRECATED_CB_PARAM, 'row_classes', 'classes_cb' ); |
| 1229 | 1229 | |
| 1230 | - $args['classes_cb'] = $args['row_classes']; |
|
| 1231 | - $args['classes'] = null; |
|
| 1230 | + $args[ 'classes_cb' ] = $args[ 'row_classes' ]; |
|
| 1231 | + $args[ 'classes' ] = null; |
|
| 1232 | 1232 | } else { |
| 1233 | 1233 | |
| 1234 | - $args['classes'] = $args['row_classes']; |
|
| 1234 | + $args[ 'classes' ] = $args[ 'row_classes' ]; |
|
| 1235 | 1235 | } |
| 1236 | 1236 | |
| 1237 | - unset( $args['row_classes'] ); |
|
| 1237 | + unset( $args[ 'row_classes' ] ); |
|
| 1238 | 1238 | } |
| 1239 | 1239 | |
| 1240 | 1240 | |
| 1241 | 1241 | // default param can be passed a callback as well |
| 1242 | - if ( is_callable( $args['default'] ) ) { |
|
| 1242 | + if ( is_callable( $args[ 'default' ] ) ) { |
|
| 1243 | 1243 | |
| 1244 | 1244 | $this->deprecated_param( __CLASS__ . '::__construct()', '2.2.3', self::DEPRECATED_CB_PARAM, 'default', 'default_cb' ); |
| 1245 | 1245 | |
| 1246 | - $args['default_cb'] = $args['default']; |
|
| 1247 | - $args['default'] = null; |
|
| 1246 | + $args[ 'default_cb' ] = $args[ 'default' ]; |
|
| 1247 | + $args[ 'default' ] = null; |
|
| 1248 | 1248 | } |
| 1249 | 1249 | |
| 1250 | 1250 | // options param can be passed a callback as well |
| 1251 | - if ( is_callable( $args['options'] ) ) { |
|
| 1251 | + if ( is_callable( $args[ 'options' ] ) ) { |
|
| 1252 | 1252 | |
| 1253 | 1253 | $this->deprecated_param( __CLASS__ . '::__construct()', '2.2.3', self::DEPRECATED_CB_PARAM, 'options', 'options_cb' ); |
| 1254 | 1254 | |
| 1255 | - $args['options_cb'] = $args['options']; |
|
| 1256 | - $args['options'] = array(); |
|
| 1255 | + $args[ 'options_cb' ] = $args[ 'options' ]; |
|
| 1256 | + $args[ 'options' ] = array(); |
|
| 1257 | 1257 | } |
| 1258 | 1258 | |
| 1259 | 1259 | return $args; |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | if ( is_array( $this->field->value ) ) { |
| 125 | 125 | |
| 126 | 126 | // Then loop and output. |
| 127 | - echo '<ul class="cmb2-'. str_replace( '_', '-', $this->field->type() ) .'">'; |
|
| 127 | + echo '<ul class="cmb2-' . str_replace( '_', '-', $this->field->type() ) . '">'; |
|
| 128 | 128 | foreach ( $this->field->value as $val ) { |
| 129 | 129 | $this->value = $val; |
| 130 | 130 | echo '<li>', $this->_display(), '</li>'; |
@@ -197,8 +197,8 @@ discard block |
||
| 197 | 197 | $options = $this->field->options(); |
| 198 | 198 | |
| 199 | 199 | $fallback = $this->field->args( 'show_option_none' ); |
| 200 | - if ( ! $fallback && isset( $options[''] ) ) { |
|
| 201 | - $fallback = $options['']; |
|
| 200 | + if ( ! $fallback && isset( $options[ '' ] ) ) { |
|
| 201 | + $fallback = $options[ '' ]; |
|
| 202 | 202 | } |
| 203 | 203 | if ( ! $this->value && $fallback ) { |
| 204 | 204 | echo $fallback; |
@@ -225,9 +225,9 @@ discard block |
||
| 225 | 225 | $output = array(); |
| 226 | 226 | foreach ( $this->value as $val ) { |
| 227 | 227 | if ( isset( $options[ $val ] ) ) { |
| 228 | - $output[] = $options[ $val ]; |
|
| 228 | + $output[ ] = $options[ $val ]; |
|
| 229 | 229 | } else { |
| 230 | - $output[] = esc_attr( $val ); |
|
| 230 | + $output[ ] = esc_attr( $val ); |
|
| 231 | 231 | } |
| 232 | 232 | } |
| 233 | 233 | |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | * @since 2.2.2 |
| 252 | 252 | */ |
| 253 | 253 | protected function _display() { |
| 254 | - echo '<xmp class="cmb2-code">'. print_r( $this->value, true ) .'</xmp>'; |
|
| 254 | + echo '<xmp class="cmb2-code">' . print_r( $this->value, true ) . '</xmp>'; |
|
| 255 | 255 | } |
| 256 | 256 | } |
| 257 | 257 | |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | if ( $datetime && $datetime instanceof DateTime ) { |
| 294 | 294 | $tz = $datetime->getTimezone(); |
| 295 | 295 | $tzstring = $tz->getName(); |
| 296 | - $this->value = $datetime->getTimestamp(); |
|
| 296 | + $this->value = $datetime->getTimestamp(); |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | $date = $this->field->get_timestamp_format( 'date_format', $this->value ); |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | if ( is_wp_error( $terms ) || empty( $terms ) && ( $default = $this->field->get_default() ) ) { |
| 318 | 318 | $term = get_term_by( 'slug', $default, $taxonomy ); |
| 319 | 319 | } elseif ( ! empty( $terms ) ) { |
| 320 | - $term = $terms[key( $terms )]; |
|
| 320 | + $term = $terms[ key( $terms ) ]; |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | if ( $term ) { |
@@ -341,10 +341,10 @@ discard block |
||
| 341 | 341 | $terms = array(); |
| 342 | 342 | if ( is_array( $default ) ) { |
| 343 | 343 | foreach ( $default as $slug ) { |
| 344 | - $terms[] = get_term_by( 'slug', $slug, $taxonomy ); |
|
| 344 | + $terms[ ] = get_term_by( 'slug', $slug, $taxonomy ); |
|
| 345 | 345 | } |
| 346 | 346 | } else { |
| 347 | - $terms[] = get_term_by( 'slug', $default, $taxonomy ); |
|
| 347 | + $terms[ ] = get_term_by( 'slug', $default, $taxonomy ); |
|
| 348 | 348 | } |
| 349 | 349 | } |
| 350 | 350 | |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | $links = array(); |
| 354 | 354 | foreach ( $terms as $term ) { |
| 355 | 355 | $link = get_edit_term_link( $term->term_id, $taxonomy ); |
| 356 | - $links[] = '<a href="'. esc_url( $link ) .'">'. esc_html( $term->name ) .'</a>'; |
|
| 356 | + $links[ ] = '<a href="' . esc_url( $link ) . '">' . esc_html( $term->name ) . '</a>'; |
|
| 357 | 357 | } |
| 358 | 358 | // Then loop and output. |
| 359 | 359 | echo '<div class="cmb2-taxonomy-terms-', esc_attr( $taxonomy ), '">'; |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | if ( $id ) { |
| 397 | 397 | $image = wp_get_attachment_image( $id, $img_size, null, array( 'class' => 'cmb-image-display' ) ); |
| 398 | 398 | } else { |
| 399 | - $size = is_array( $img_size ) ? $img_size[0] : 200; |
|
| 399 | + $size = is_array( $img_size ) ? $img_size[ 0 ] : 200; |
|
| 400 | 400 | $image = '<img class="cmb-image-display" style="max-width: ' . absint( $size ) . 'px; width: 100%; height: auto;" src="' . $url_value . '" alt="" />'; |
| 401 | 401 | } |
| 402 | 402 | |
@@ -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,8 +169,8 @@ 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'] . '">' . esc_html__( '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' ] . '">' . esc_html__( 'Remove Embed', 'cmb2' ) . '</a></p></div>'; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | // Otherwise, send back error info that no oEmbeds were found |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | sprintf( |
| 180 | 180 | /* translators: 1: results for. 2: link to codex.wordpress.org/Embeds */ |
| 181 | 181 | esc_html__( 'No oEmbed Results Found for %1$s. View more info at %2$s.', 'cmb2' ), |
| 182 | - $oembed['fallback'], |
|
| 182 | + $oembed[ 'fallback' ], |
|
| 183 | 183 | '<a href="https://codex.wordpress.org/Embeds" target="_blank">codex.wordpress.org/Embeds</a>' |
| 184 | 184 | ) |
| 185 | 185 | ); |
@@ -244,15 +244,15 @@ discard block |
||
| 244 | 244 | */ |
| 245 | 245 | protected function cache_action( $meta_key ) { |
| 246 | 246 | $func_args = func_get_args(); |
| 247 | - $action = isset( $func_args[1] ) ? 'update' : 'get'; |
|
| 247 | + $action = isset( $func_args[ 1 ] ) ? 'update' : 'get'; |
|
| 248 | 248 | |
| 249 | 249 | if ( 'options-page' === $this->object_type ) { |
| 250 | 250 | |
| 251 | 251 | $args = array( $meta_key ); |
| 252 | 252 | |
| 253 | 253 | if ( 'update' === $action ) { |
| 254 | - $args[] = $func_args[1]; |
|
| 255 | - $args[] = true; |
|
| 254 | + $args[ ] = $func_args[ 1 ]; |
|
| 255 | + $args[ ] = true; |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | // Cache the result to our options |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | } else { |
| 261 | 261 | |
| 262 | 262 | $args = array( $this->object_type, $this->object_id, $meta_key ); |
| 263 | - $args[] = 'update' === $action ? $func_args : true; |
|
| 263 | + $args[ ] = 'update' === $action ? $func_args : true; |
|
| 264 | 264 | |
| 265 | 265 | // Cache the result to our metadata |
| 266 | 266 | $status = call_user_func_array( $action . '_metadata', $args ); |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | ) ); |
| 29 | 29 | |
| 30 | 30 | if ( ! $field->group ) { |
| 31 | - return $this->rendered( $this->get_wp_editor( $a ) . $a['desc'] ); |
|
| 31 | + return $this->rendered( $this->get_wp_editor( $a ) . $a[ 'desc' ] ); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | // wysiwyg fields in a group need some special handling. |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | protected function get_wp_editor( $args ) { |
| 54 | 54 | ob_start(); |
| 55 | - wp_editor( $args['value'], $args['id'], $args['options'] ); |
|
| 55 | + wp_editor( $args[ 'value' ], $args[ 'id' ], $args[ 'options' ] ); |
|
| 56 | 56 | return ob_get_clean(); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $group_id = $this->field->group->id(); |
| 61 | 61 | $field_id = $this->field->id( true ); |
| 62 | 62 | $options = $this->field->options(); |
| 63 | - $options['textarea_name'] = 'cmb2_n_' . $group_id . $field_id; |
|
| 63 | + $options[ 'textarea_name' ] = 'cmb2_n_' . $group_id . $field_id; |
|
| 64 | 64 | |
| 65 | 65 | // Initate the editor with special id/value/name so we can retrieve the options in JS. |
| 66 | 66 | $editor = $this->get_wp_editor( array( |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | // And put the editor instance in a JS template wrapper. |
| 84 | 84 | echo '<script type="text/template" id="tmpl-cmb2-wysiwyg-' . $group_id . '-' . $field_id . '">'; |
| 85 | 85 | // Need to wrap the template in a wrapper div w/ specific data attributes which will be used when adding/removing rows. |
| 86 | - echo '<div class="cmb2-wysiwyg-inner-wrap" data-iterator="{{ data.iterator }}" data-groupid="'. $group_id .'" data-id="'. $field_id .'">'. $editor .'</div>'; |
|
| 86 | + echo '<div class="cmb2-wysiwyg-inner-wrap" data-iterator="{{ data.iterator }}" data-groupid="' . $group_id . '" data-id="' . $field_id . '">' . $editor . '</div>'; |
|
| 87 | 87 | echo '</script>'; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -28,10 +28,10 @@ |
||
| 28 | 28 | return $this->rendered( |
| 29 | 29 | sprintf( |
| 30 | 30 | '<%1$s %2$s>%3$s</%1$s>%4$s', |
| 31 | - $a['tag'], |
|
| 31 | + $a[ 'tag' ], |
|
| 32 | 32 | $this->concat_attrs( $a, array( 'tag', 'name', 'desc' ) ), |
| 33 | - $a['name'], |
|
| 34 | - $a['desc'] |
|
| 33 | + $a[ 'name' ], |
|
| 34 | + $a[ 'desc' ] |
|
| 35 | 35 | ) |
| 36 | 36 | ); |
| 37 | 37 | } |