@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | ) ); |
50 | 50 | |
51 | 51 | $delete_args = $args; |
52 | - $delete_args['object_id']['required'] = true; |
|
53 | - $delete_args['object_type']['required'] = true; |
|
52 | + $delete_args[ 'object_id' ][ 'required' ] = true; |
|
53 | + $delete_args[ 'object_type' ][ 'required' ] = true; |
|
54 | 54 | |
55 | 55 | // Returns specific field data. |
56 | 56 | register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<cmb_id>[\w-]+)/fields/(?P<field_id>[\w-]+)', array( |
@@ -122,13 +122,13 @@ discard block |
||
122 | 122 | foreach ( $this->rest_box->cmb->prop( 'fields', array() ) as $field ) { |
123 | 123 | |
124 | 124 | // Make sure this field can be read. |
125 | - $this->field = $this->rest_box->field_can_read( $field['id'], true ); |
|
125 | + $this->field = $this->rest_box->field_can_read( $field[ 'id' ], true ); |
|
126 | 126 | |
127 | 127 | // And make sure current user can view this box. |
128 | 128 | if ( $this->field && $this->get_item_permissions_check_filter() ) { |
129 | - $fields[ $field['id'] ] = $this->server->response_to_data( |
|
129 | + $fields[ $field[ 'id' ] ] = $this->server->response_to_data( |
|
130 | 130 | $this->prepare_field_response(), |
131 | - isset( $this->request['_embed'] ) |
|
131 | + isset( $this->request[ '_embed' ] ) |
|
132 | 132 | ); |
133 | 133 | } |
134 | 134 | } |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | public function update_item( $request ) { |
235 | 235 | $this->initiate_rest_read_box( $request, 'field_value_update' ); |
236 | 236 | |
237 | - if ( ! $this->request['value'] ) { |
|
237 | + if ( ! $this->request[ 'value' ] ) { |
|
238 | 238 | return new WP_Error( 'cmb2_rest_update_field_error', __( 'CMB2 Field value cannot be updated without the value parameter specified.', 'cmb2' ), array( 'status' => 400 ) ); |
239 | 239 | } |
240 | 240 | |
@@ -291,9 +291,9 @@ discard block |
||
291 | 291 | * @param string $activity The modification activity (updated or deleted). |
292 | 292 | * @return WP_Error|WP_REST_Response |
293 | 293 | */ |
294 | - public function modify_field_value( $activity) { |
|
294 | + public function modify_field_value( $activity ) { |
|
295 | 295 | |
296 | - if ( ! $this->request['object_id'] || ! $this->request['object_type'] ) { |
|
296 | + if ( ! $this->request[ 'object_id' ] || ! $this->request[ 'object_type' ] ) { |
|
297 | 297 | return new WP_Error( 'cmb2_rest_modify_field_value_error', __( 'CMB2 Field value cannot be modified without the object_id and object_type parameters specified.', 'cmb2' ), array( 'status' => 400 ) ); |
298 | 298 | } |
299 | 299 | |
@@ -310,13 +310,13 @@ discard block |
||
310 | 310 | return new WP_Error( 'cmb2_rest_no_field_by_id_error', __( 'No field found by that id.', 'cmb2' ), array( 'status' => 403 ) ); |
311 | 311 | } |
312 | 312 | |
313 | - $this->field->args["value_{$activity}"] = (bool) 'deleted' === $activity |
|
313 | + $this->field->args[ "value_{$activity}" ] = (bool) 'deleted' === $activity |
|
314 | 314 | ? $this->field->remove_data() |
315 | - : $this->field->save_field( $this->request['value'] ); |
|
315 | + : $this->field->save_field( $this->request[ 'value' ] ); |
|
316 | 316 | |
317 | 317 | // If options page, save the $activity options |
318 | - if ( 'options-page' == $this->request['object_type'] ) { |
|
319 | - $this->field->args["value_{$activity}"] = cmb2_options( $this->request['object_id'] )->set(); |
|
318 | + if ( 'options-page' == $this->request[ 'object_type' ] ) { |
|
319 | + $this->field->args[ "value_{$activity}" ] = cmb2_options( $this->request[ 'object_id' ] )->set(); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | return $this->prepare_read_field( $this->field ); |
@@ -391,13 +391,13 @@ discard block |
||
391 | 391 | $value = $field->options(); |
392 | 392 | } elseif ( in_array( $key, CMB2_Field::$callable_fields, true ) ) { |
393 | 393 | |
394 | - if ( isset( $this->request['_rendered'] ) ) { |
|
394 | + if ( isset( $this->request[ '_rendered' ] ) ) { |
|
395 | 395 | $value = $key === 'render_row_cb' ? $rendered : $field->get_param_callback_result( $key ); |
396 | 396 | } elseif ( is_array( $value ) ) { |
397 | 397 | // We need to rewrite callbacks as string as they will cause |
398 | 398 | // JSON recursion errors. |
399 | - $class = is_string( $value[0] ) ? $value[0] : get_class( $value[0] ); |
|
400 | - $value = $class . '::' . $value[1]; |
|
399 | + $class = is_string( $value[ 0 ] ) ? $value[ 0 ] : get_class( $value[ 0 ] ); |
|
400 | + $value = $class . '::' . $value[ 1 ]; |
|
401 | 401 | } |
402 | 402 | } |
403 | 403 | |
@@ -410,8 +410,8 @@ discard block |
||
410 | 410 | } |
411 | 411 | } |
412 | 412 | |
413 | - if ( $this->request['object_id'] && $this->request['object_type'] ) { |
|
414 | - $field_data['value'] = $field->get_data(); |
|
413 | + if ( $this->request[ 'object_id' ] && $this->request[ 'object_type' ] ) { |
|
414 | + $field_data[ 'value' ] = $field->get_data(); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | return $field_data; |