@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * Get object property and optionally set a fallback |
160 | 160 | * @since 2.0.0 |
161 | 161 | * @param string $property Metabox config property to retrieve |
162 | - * @param mixed $fallback Fallback value to set if no value found |
|
162 | + * @param boolean|null $fallback Fallback value to set if no value found |
|
163 | 163 | * @return mixed Metabox config property value or false |
164 | 164 | */ |
165 | 165 | public function prop( $property, $fallback = null ) { |
@@ -464,7 +464,6 @@ discard block |
||
464 | 464 | * Allows overloading the object with methods... Whooaaa oooh it's magic, y'knoooow. |
465 | 465 | * @since 1.0.0 |
466 | 466 | * @param string $method Non-existent method. |
467 | - * @param array $arguments All arguments passed to the method |
|
468 | 467 | */ |
469 | 468 | public function __call( $method, $args ) { |
470 | 469 | $object_class = strtolower( get_class( $this ) ); |
@@ -315,10 +315,10 @@ |
||
315 | 315 | * which is callable. If so, it registers the callback, and if not, |
316 | 316 | * converts the maybe-modified $val to a boolean for return. |
317 | 317 | * |
318 | - * The registered handlers will have a parameter name which matches the filter, except: |
|
319 | - * - The 'cmb2_api' prefix will be removed |
|
320 | - * - A '_cb' suffix will be added (to stay inline with other '*_cb' parameters). |
|
321 | - * |
|
318 | + * The registered handlers will have a parameter name which matches the filter, except: |
|
319 | + * - The 'cmb2_api' prefix will be removed |
|
320 | + * - A '_cb' suffix will be added (to stay inline with other '*_cb' parameters). |
|
321 | + * |
|
322 | 322 | * @since 2.2.3 |
323 | 323 | * |
324 | 324 | * @param string $hook_name The hook name. |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | } |
359 | 359 | |
360 | 360 | // Cast to bool. |
361 | - return !! $val; |
|
361 | + return ! ! $val; |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | /** |
@@ -386,11 +386,11 @@ discard block |
||
386 | 386 | switch ( $message ) { |
387 | 387 | |
388 | 388 | case self::DEPRECATED_PARAM: |
389 | - $message = sprintf( __( 'The "%s" field parameter has been deprecated in favor of the "%s" parameter.', 'cmb2' ), $args[3], $args[4] ); |
|
389 | + $message = sprintf( __( 'The "%s" field parameter has been deprecated in favor of the "%s" parameter.', 'cmb2' ), $args[ 3 ], $args[ 4 ] ); |
|
390 | 390 | break; |
391 | 391 | |
392 | 392 | case self::DEPRECATED_CB_PARAM: |
393 | - $message = sprintf( __( 'Using the "%s" field parameter as a callback has been deprecated in favor of the "%s" parameter.', 'cmb2' ), $args[3], $args[4] ); |
|
393 | + $message = sprintf( __( 'Using the "%s" field parameter as a callback has been deprecated in favor of the "%s" parameter.', 'cmb2' ), $args[ 3 ], $args[ 4 ] ); |
|
394 | 394 | break; |
395 | 395 | |
396 | 396 | default: |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | public function __call( $method, $args ) { |
470 | 470 | $object_class = strtolower( get_class( $this ) ); |
471 | 471 | |
472 | - if ( ! has_filter( "{$object_class}_inherit_{$method}" ) ) { |
|
472 | + if ( ! has_filter( "{$object_class}_inherit_{$method}" ) ) { |
|
473 | 473 | throw new Exception( sprintf( esc_html__( 'Invalid %1$s method: %2$s', 'give' ), get_class( $this ), $method ) ); |
474 | 474 | } |
475 | 475 |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @since 2.2.3 |
199 | 199 | * |
200 | 200 | * @param mixed $cb Callable function/method. |
201 | - * @return mixed Results of output buffer after calling function/method. |
|
201 | + * @return string Results of output buffer after calling function/method. |
|
202 | 202 | */ |
203 | 203 | public function get_cb_results( $cb ) { |
204 | 204 | $args = func_get_args(); |
@@ -214,7 +214,6 @@ discard block |
||
214 | 214 | * |
215 | 215 | * @since 2.2.3 |
216 | 216 | * |
217 | - * @param mixed $item WordPress representation of the item. |
|
218 | 217 | * @param WP_REST_Request $request Request object. |
219 | 218 | * @return WP_REST_Response $response |
220 | 219 | */ |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | 'schema' => array( $this, 'get_item_schema' ), |
69 | 69 | ) ); |
70 | 70 | |
71 | - $args['_rendered'] = array( |
|
71 | + $args[ '_rendered' ] = array( |
|
72 | 72 | 'description' => __( 'Includes the fully rendered attributes, \'form_open\', \'form_close\', as well as the enqueued \'js_dependencies\' script handles, and \'css_dependencies\' stylesheet handles.', 'cmb2' ), |
73 | 73 | ); |
74 | 74 | |
@@ -132,9 +132,9 @@ discard block |
||
132 | 132 | // And make sure current user can view this box. |
133 | 133 | && $this->get_item_permissions_check_filter( $this->request ) |
134 | 134 | ) { |
135 | - $boxes_data[] = $this->server->response_to_data( |
|
135 | + $boxes_data[ ] = $this->server->response_to_data( |
|
136 | 136 | $this->get_rest_box(), |
137 | - isset( $this->request['_embed'] ) |
|
137 | + isset( $this->request[ '_embed' ] ) |
|
138 | 138 | ); |
139 | 139 | } |
140 | 140 | } |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | |
211 | 211 | $boxes_data = $cmb->meta_box; |
212 | 212 | |
213 | - if ( isset( $this->request['_rendered'] ) && $this->namespace_base !== ltrim( CMB2_REST_Controller::get_intial_route(), '/' ) ) { |
|
214 | - $boxes_data['form_open'] = $this->get_cb_results( array( $cmb, 'render_form_open' ) ); |
|
215 | - $boxes_data['form_close'] = $this->get_cb_results( array( $cmb, 'render_form_close' ) ); |
|
213 | + if ( isset( $this->request[ '_rendered' ] ) && $this->namespace_base !== ltrim( CMB2_REST_Controller::get_intial_route(), '/' ) ) { |
|
214 | + $boxes_data[ 'form_open' ] = $this->get_cb_results( array( $cmb, 'render_form_open' ) ); |
|
215 | + $boxes_data[ 'form_close' ] = $this->get_cb_results( array( $cmb, 'render_form_close' ) ); |
|
216 | 216 | |
217 | 217 | global $wp_scripts, $wp_styles; |
218 | 218 | $before_css = $wp_styles->queue; |
@@ -220,15 +220,15 @@ discard block |
||
220 | 220 | |
221 | 221 | CMB2_JS::enqueue(); |
222 | 222 | |
223 | - $boxes_data['js_dependencies'] = array_values( array_diff( $wp_scripts->queue, $before_js ) ); |
|
224 | - $boxes_data['css_dependencies'] = array_values( array_diff( $wp_styles->queue, $before_css ) ); |
|
223 | + $boxes_data[ 'js_dependencies' ] = array_values( array_diff( $wp_scripts->queue, $before_js ) ); |
|
224 | + $boxes_data[ 'css_dependencies' ] = array_values( array_diff( $wp_styles->queue, $before_css ) ); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | // TODO: look into 'embed' parameter. |
228 | 228 | // http://demo.wp-api.org/wp-json/wp/v2/posts?_embed |
229 | - unset( $boxes_data['fields'] ); |
|
229 | + unset( $boxes_data[ 'fields' ] ); |
|
230 | 230 | // Handle callable properties. |
231 | - unset( $boxes_data['show_on_cb'] ); |
|
231 | + unset( $boxes_data[ 'show_on_cb' ] ); |
|
232 | 232 | |
233 | 233 | $response = rest_ensure_response( $boxes_data ); |
234 | 234 |
@@ -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; |