|
@@ -49,8 +49,8 @@ discard block |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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
|
} |
|
@@ -232,7 +232,7 @@ discard block |
|
|
block discarded – undo |
|
232
|
232
|
public function update_item( $request ) { |
|
233
|
233
|
$this->initiate_rest_read_box( $request, 'field_value_update' ); |
|
234
|
234
|
|
|
235
|
|
- if ( ! $this->request['value'] ) { |
|
|
235
|
+ if ( ! $this->request[ 'value' ] ) { |
|
236
|
236
|
return new WP_Error( 'cmb2_rest_update_field_error', __( 'CMB2 Field value cannot be updated without the value parameter specified.', 'cmb2' ), array( |
|
237
|
237
|
'status' => 400, |
|
238
|
238
|
) ); |
|
@@ -293,7 +293,7 @@ discard block |
|
|
block discarded – undo |
|
293
|
293
|
*/ |
|
294
|
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( |
|
298
|
298
|
'status' => 400, |
|
299
|
299
|
) ); |
|
@@ -316,11 +316,11 @@ discard block |
|
|
block discarded – undo |
|
316
|
316
|
|
|
317
|
317
|
$this->field->args[ "value_{$activity}" ] = (bool) 'deleted' === $activity |
|
318
|
318
|
? $this->field->remove_data() |
|
319
|
|
- : $this->field->save_field( $this->request['value'] ); |
|
|
319
|
+ : $this->field->save_field( $this->request[ 'value' ] ); |
|
320
|
320
|
|
|
321
|
321
|
// If options page, save the $activity options |
|
322
|
|
- if ( 'options-page' == $this->request['object_type'] ) { |
|
323
|
|
- $this->field->args[ "value_{$activity}" ] = cmb2_options( $this->request['object_id'] )->set(); |
|
|
322
|
+ if ( 'options-page' == $this->request[ 'object_type' ] ) { |
|
|
323
|
+ $this->field->args[ "value_{$activity}" ] = cmb2_options( $this->request[ 'object_id' ] )->set(); |
|
324
|
324
|
} |
|
325
|
325
|
|
|
326
|
326
|
return $this->prepare_read_field( $this->field ); |
|
@@ -397,13 +397,13 @@ discard block |
|
|
block discarded – undo |
|
397
|
397
|
$value = $field->options(); |
|
398
|
398
|
} elseif ( in_array( $key, CMB2_Field::$callable_fields, true ) ) { |
|
399
|
399
|
|
|
400
|
|
- if ( isset( $this->request['_rendered'] ) ) { |
|
|
400
|
+ if ( isset( $this->request[ '_rendered' ] ) ) { |
|
401
|
401
|
$value = $key === 'render_row_cb' ? $rendered : $field->get_param_callback_result( $key ); |
|
402
|
402
|
} elseif ( is_array( $value ) ) { |
|
403
|
403
|
// We need to rewrite callbacks as string as they will cause |
|
404
|
404
|
// JSON recursion errors. |
|
405
|
|
- $class = is_string( $value[0] ) ? $value[0] : get_class( $value[0] ); |
|
406
|
|
- $value = $class . '::' . $value[1]; |
|
|
405
|
+ $class = is_string( $value[ 0 ] ) ? $value[ 0 ] : get_class( $value[ 0 ] ); |
|
|
406
|
+ $value = $class . '::' . $value[ 1 ]; |
|
407
|
407
|
} |
|
408
|
408
|
} |
|
409
|
409
|
|
|
@@ -416,8 +416,8 @@ discard block |
|
|
block discarded – undo |
|
416
|
416
|
} |
|
417
|
417
|
} |
|
418
|
418
|
|
|
419
|
|
- if ( $this->request['object_id'] && $this->request['object_type'] ) { |
|
420
|
|
- $field_data['value'] = $field->get_data(); |
|
|
419
|
+ if ( $this->request[ 'object_id' ] && $this->request[ 'object_type' ] ) { |
|
|
420
|
+ $field_data[ 'value' ] = $field->get_data(); |
|
421
|
421
|
} |
|
422
|
422
|
|
|
423
|
423
|
return $field_data; |