@@ -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 | |
@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | if ( ! empty( $links ) ) { |
| 169 | - $data['_links'] = $links; |
|
| 169 | + $data[ '_links' ] = $links; |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | return $data; |
@@ -183,21 +183,21 @@ discard block |
||
| 183 | 183 | |
| 184 | 184 | $schema = $this->get_item_schema(); |
| 185 | 185 | foreach ( $data as $key => $value ) { |
| 186 | - if ( empty( $schema['properties'][ $key ] ) || empty( $schema['properties'][ $key ]['context'] ) ) { |
|
| 186 | + if ( empty( $schema[ 'properties' ][ $key ] ) || empty( $schema[ 'properties' ][ $key ][ 'context' ] ) ) { |
|
| 187 | 187 | continue; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - if ( ! in_array( $context, $schema['properties'][ $key ]['context'] ) ) { |
|
| 190 | + if ( ! in_array( $context, $schema[ 'properties' ][ $key ][ 'context' ] ) ) { |
|
| 191 | 191 | unset( $data[ $key ] ); |
| 192 | 192 | continue; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - if ( 'object' === $schema['properties'][ $key ]['type'] && ! empty( $schema['properties'][ $key ]['properties'] ) ) { |
|
| 196 | - foreach ( $schema['properties'][ $key ]['properties'] as $attribute => $details ) { |
|
| 197 | - if ( empty( $details['context'] ) ) { |
|
| 195 | + if ( 'object' === $schema[ 'properties' ][ $key ][ 'type' ] && ! empty( $schema[ 'properties' ][ $key ][ 'properties' ] ) ) { |
|
| 196 | + foreach ( $schema[ 'properties' ][ $key ][ 'properties' ] as $attribute => $details ) { |
|
| 197 | + if ( empty( $details[ 'context' ] ) ) { |
|
| 198 | 198 | continue; |
| 199 | 199 | } |
| 200 | - if ( ! in_array( $context, $details['context'] ) ) { |
|
| 200 | + if ( ! in_array( $context, $details[ 'context' ] ) ) { |
|
| 201 | 201 | if ( isset( $data[ $key ][ $attribute ] ) ) { |
| 202 | 202 | unset( $data[ $key ][ $attribute ] ); |
| 203 | 203 | } |
@@ -227,9 +227,9 @@ discard block |
||
| 227 | 227 | |
| 228 | 228 | $schema = $this->get_item_schema(); |
| 229 | 229 | |
| 230 | - foreach ( $schema['properties'] as &$property ) { |
|
| 231 | - if ( isset( $property['arg_options'] ) ) { |
|
| 232 | - unset( $property['arg_options'] ); |
|
| 230 | + foreach ( $schema[ 'properties' ] as &$property ) { |
|
| 231 | + if ( isset( $property[ 'arg_options' ] ) ) { |
|
| 232 | + unset( $property[ 'arg_options' ] ); |
|
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 | |
@@ -286,18 +286,18 @@ discard block |
||
| 286 | 286 | 'validate_callback' => 'rest_validate_request_arg', |
| 287 | 287 | ); |
| 288 | 288 | $schema = $this->get_item_schema(); |
| 289 | - if ( empty( $schema['properties'] ) ) { |
|
| 289 | + if ( empty( $schema[ 'properties' ] ) ) { |
|
| 290 | 290 | return array_merge( $param_details, $args ); |
| 291 | 291 | } |
| 292 | 292 | $contexts = array(); |
| 293 | - foreach ( $schema['properties'] as $attributes ) { |
|
| 294 | - if ( ! empty( $attributes['context'] ) ) { |
|
| 295 | - $contexts = array_merge( $contexts, $attributes['context'] ); |
|
| 293 | + foreach ( $schema[ 'properties' ] as $attributes ) { |
|
| 294 | + if ( ! empty( $attributes[ 'context' ] ) ) { |
|
| 295 | + $contexts = array_merge( $contexts, $attributes[ 'context' ] ); |
|
| 296 | 296 | } |
| 297 | 297 | } |
| 298 | 298 | if ( ! empty( $contexts ) ) { |
| 299 | - $param_details['enum'] = array_unique( $contexts ); |
|
| 300 | - rsort( $param_details['enum'] ); |
|
| 299 | + $param_details[ 'enum' ] = array_unique( $contexts ); |
|
| 300 | + rsort( $param_details[ 'enum' ] ); |
|
| 301 | 301 | } |
| 302 | 302 | return array_merge( $param_details, $args ); |
| 303 | 303 | } |
@@ -315,11 +315,11 @@ discard block |
||
| 315 | 315 | |
| 316 | 316 | foreach ( $additional_fields as $field_name => $field_options ) { |
| 317 | 317 | |
| 318 | - if ( ! $field_options['get_callback'] ) { |
|
| 318 | + if ( ! $field_options[ 'get_callback' ] ) { |
|
| 319 | 319 | continue; |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - $object[ $field_name ] = call_user_func( $field_options['get_callback'], $object, $field_name, $request, $this->get_object_type() ); |
|
| 322 | + $object[ $field_name ] = call_user_func( $field_options[ 'get_callback' ], $object, $field_name, $request, $this->get_object_type() ); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | return $object; |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | |
| 338 | 338 | foreach ( $additional_fields as $field_name => $field_options ) { |
| 339 | 339 | |
| 340 | - if ( ! $field_options['update_callback'] ) { |
|
| 340 | + if ( ! $field_options[ 'update_callback' ] ) { |
|
| 341 | 341 | continue; |
| 342 | 342 | } |
| 343 | 343 | |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | continue; |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - call_user_func( $field_options['update_callback'], $request[ $field_name ], $object, $field_name, $request, $this->get_object_type() ); |
|
| 349 | + call_user_func( $field_options[ 'update_callback' ], $request[ $field_name ], $object, $field_name, $request, $this->get_object_type() ); |
|
| 350 | 350 | } |
| 351 | 351 | } |
| 352 | 352 | |
@@ -358,23 +358,23 @@ discard block |
||
| 358 | 358 | * @param array $schema Schema array. |
| 359 | 359 | */ |
| 360 | 360 | protected function add_additional_fields_schema( $schema ) { |
| 361 | - if ( empty( $schema['title'] ) ) { |
|
| 361 | + if ( empty( $schema[ 'title' ] ) ) { |
|
| 362 | 362 | return $schema; |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | /** |
| 366 | 366 | * Can't use $this->get_object_type otherwise we cause an inf loop. |
| 367 | 367 | */ |
| 368 | - $object_type = $schema['title']; |
|
| 368 | + $object_type = $schema[ 'title' ]; |
|
| 369 | 369 | |
| 370 | 370 | $additional_fields = $this->get_additional_fields( $object_type ); |
| 371 | 371 | |
| 372 | 372 | foreach ( $additional_fields as $field_name => $field_options ) { |
| 373 | - if ( ! $field_options['schema'] ) { |
|
| 373 | + if ( ! $field_options[ 'schema' ] ) { |
|
| 374 | 374 | continue; |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | - $schema['properties'][ $field_name ] = $field_options['schema']; |
|
| 377 | + $schema[ 'properties' ][ $field_name ] = $field_options[ 'schema' ]; |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | return $schema; |
@@ -413,11 +413,11 @@ discard block |
||
| 413 | 413 | protected function get_object_type() { |
| 414 | 414 | $schema = $this->get_item_schema(); |
| 415 | 415 | |
| 416 | - if ( ! $schema || ! isset( $schema['title'] ) ) { |
|
| 416 | + if ( ! $schema || ! isset( $schema[ 'title' ] ) ) { |
|
| 417 | 417 | return null; |
| 418 | 418 | } |
| 419 | 419 | |
| 420 | - return $schema['title']; |
|
| 420 | + return $schema[ 'title' ]; |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | /** |
@@ -433,13 +433,13 @@ discard block |
||
| 433 | 433 | public function get_endpoint_args_for_item_schema( $method = WP_REST_Server::CREATABLE ) { |
| 434 | 434 | |
| 435 | 435 | $schema = $this->get_item_schema(); |
| 436 | - $schema_properties = ! empty( $schema['properties'] ) ? $schema['properties'] : array(); |
|
| 436 | + $schema_properties = ! empty( $schema[ 'properties' ] ) ? $schema[ 'properties' ] : array(); |
|
| 437 | 437 | $endpoint_args = array(); |
| 438 | 438 | |
| 439 | 439 | foreach ( $schema_properties as $field_id => $params ) { |
| 440 | 440 | |
| 441 | 441 | // Arguments specified as `readonly` are not allowed to be set. |
| 442 | - if ( ! empty( $params['readonly'] ) ) { |
|
| 442 | + if ( ! empty( $params[ 'readonly' ] ) ) { |
|
| 443 | 443 | continue; |
| 444 | 444 | } |
| 445 | 445 | |
@@ -448,16 +448,16 @@ discard block |
||
| 448 | 448 | 'sanitize_callback' => 'rest_sanitize_request_arg', |
| 449 | 449 | ); |
| 450 | 450 | |
| 451 | - if ( isset( $params['description'] ) ) { |
|
| 452 | - $endpoint_args[ $field_id ]['description'] = $params['description']; |
|
| 451 | + if ( isset( $params[ 'description' ] ) ) { |
|
| 452 | + $endpoint_args[ $field_id ][ 'description' ] = $params[ 'description' ]; |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | - if ( WP_REST_Server::CREATABLE === $method && isset( $params['default'] ) ) { |
|
| 456 | - $endpoint_args[ $field_id ]['default'] = $params['default']; |
|
| 455 | + if ( WP_REST_Server::CREATABLE === $method && isset( $params[ 'default' ] ) ) { |
|
| 456 | + $endpoint_args[ $field_id ][ 'default' ] = $params[ 'default' ]; |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | - if ( WP_REST_Server::CREATABLE === $method && ! empty( $params['required'] ) ) { |
|
| 460 | - $endpoint_args[ $field_id ]['required'] = true; |
|
| 459 | + if ( WP_REST_Server::CREATABLE === $method && ! empty( $params[ 'required' ] ) ) { |
|
| 460 | + $endpoint_args[ $field_id ][ 'required' ] = true; |
|
| 461 | 461 | } |
| 462 | 462 | |
| 463 | 463 | foreach ( array( 'type', 'format', 'enum' ) as $schema_prop ) { |
@@ -467,14 +467,14 @@ discard block |
||
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | // Merge in any options provided by the schema property. |
| 470 | - if ( isset( $params['arg_options'] ) ) { |
|
| 470 | + if ( isset( $params[ 'arg_options' ] ) ) { |
|
| 471 | 471 | |
| 472 | 472 | // Only use required / default from arg_options on CREATABLE endpoints. |
| 473 | 473 | if ( WP_REST_Server::CREATABLE !== $method ) { |
| 474 | - $params['arg_options'] = array_diff_key( $params['arg_options'], array( 'required' => '', 'default' => '' ) ); |
|
| 474 | + $params[ 'arg_options' ] = array_diff_key( $params[ 'arg_options' ], array( 'required' => '', 'default' => '' ) ); |
|
| 475 | 475 | } |
| 476 | 476 | |
| 477 | - $endpoint_args[ $field_id ] = array_merge( $endpoint_args[ $field_id ], $params['arg_options'] ); |
|
| 477 | + $endpoint_args[ $field_id ] = array_merge( $endpoint_args[ $field_id ], $params[ 'arg_options' ] ); |
|
| 478 | 478 | } |
| 479 | 479 | } |
| 480 | 480 | |
@@ -52,9 +52,9 @@ |
||
| 52 | 52 | |
| 53 | 53 | // Get object hash.. This bypasses issues with serializing closures. |
| 54 | 54 | if ( is_object( $hook ) ) { |
| 55 | - $args[1] = spl_object_hash( $args[1] ); |
|
| 56 | - } elseif ( is_array( $hook ) && is_object( $hook[0] ) ) { |
|
| 57 | - $args[1][0] = spl_object_hash( $hook[0] ); |
|
| 55 | + $args[ 1 ] = spl_object_hash( $args[ 1 ] ); |
|
| 56 | + } elseif ( is_array( $hook ) && is_object( $hook[ 0 ] ) ) { |
|
| 57 | + $args[ 1 ][ 0 ] = spl_object_hash( $hook[ 0 ] ); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | $key = md5( serialize( $args ) ); |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | * @return WP_REST_Response $response |
| 227 | 227 | */ |
| 228 | 228 | public function prepare_item_for_response( $data, $request = null ) { |
| 229 | - $data = $this->filter_response_by_context( $data, $this->request['context'] ); |
|
| 229 | + $data = $this->filter_response_by_context( $data, $this->request[ 'context' ] ); |
|
| 230 | 230 | |
| 231 | 231 | /** |
| 232 | 232 | * Filter the prepared CMB2 item response. |
@@ -297,12 +297,12 @@ discard block |
||
| 297 | 297 | |
| 298 | 298 | } else { |
| 299 | 299 | |
| 300 | - if ( isset( $this->request['object_id'] ) ) { |
|
| 301 | - $this->rest_box->cmb->object_id( sanitize_text_field( $this->request['object_id'] ) ); |
|
| 300 | + if ( isset( $this->request[ 'object_id' ] ) ) { |
|
| 301 | + $this->rest_box->cmb->object_id( sanitize_text_field( $this->request[ 'object_id' ] ) ); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | - if ( isset( $this->request['object_type'] ) ) { |
|
| 305 | - $this->rest_box->cmb->object_type( sanitize_text_field( $this->request['object_type'] ) ); |
|
| 304 | + if ( isset( $this->request[ 'object_type' ] ) ) { |
|
| 305 | + $this->rest_box->cmb->object_type( sanitize_text_field( $this->request[ 'object_type' ] ) ); |
|
| 306 | 306 | } |
| 307 | 307 | } |
| 308 | 308 | } |
@@ -320,8 +320,8 @@ discard block |
||
| 320 | 320 | public function initiate_request( $request, $request_type ) { |
| 321 | 321 | $this->request = $request; |
| 322 | 322 | |
| 323 | - if ( ! isset( $this->request['context'] ) || empty( $this->request['context'] ) ) { |
|
| 324 | - $this->request['context'] = 'view'; |
|
| 323 | + if ( ! isset( $this->request[ 'context' ] ) || empty( $this->request[ 'context' ] ) ) { |
|
| 324 | + $this->request[ 'context' ] = 'view'; |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | if ( ! self::$request_type ) { |