Class CMB2_REST
Handles hooking CMB2 objects/fields into the WordPres REST API which can allow fields to be read and/or updated.
- CMB2_Hookup_Base
- CMB2_REST
Direct known subclasses
Category: WordPress_Plugin
License: GPL-2.0+
Author: CMB2 team
Since: 2.2.3
Link: https://cmb2.io
Located at includes/rest-api/CMB2_REST.php
Methods summary
public static
|
#
maybe_init_and_hookup(
A functionalized constructor, used for the hookup action callbacks. |
public
|
|
public
|
|
public static
|
|
public static
|
#
register_cmb2_fields( )
Loop through REST boxes and call register_rest_field for each object type. |
protected static
|
#
register_rest_field( string|array $object_types, string $object_type )
Wrapper for register_rest_field. |
protected
|
|
protected
boolean
|
|
protected
boolean
|
|
public static
mixed
|
#
get_post_rest_values( array $object, string $field_name, WP_REST_Request $request, string $object_type )
Handler for getting post custom field data. |
public static
mixed
|
#
get_user_rest_values( array $object, string $field_name, WP_REST_Request $request, string $object_type )
Handler for getting user custom field data. |
public static
mixed
|
#
get_comment_rest_values( array $object, string $field_name, WP_REST_Request $request, string $object_type )
Handler for getting comment custom field data. |
public static
mixed
|
#
get_term_rest_values( array $object, string $field_name, WP_REST_Request $request, string $object_type )
Handler for getting term custom field data. |
protected static
mixed
|
#
get_rest_values( array $object, WP_REST_Request $request, string $object_type, string $main_object_type = 'post' )
Handler for getting custom field data. |
public static
array
|
#
get_box_rest_values(
Get box rest values. |
public static
boolean|integer
|
#
update_post_rest_values( mixed $values, object $object, string $field_name, WP_REST_Request $request, string $object_type )
Handler for updating post custom field data. |
public static
boolean|integer
|
#
update_user_rest_values( mixed $values, object $object, string $field_name, WP_REST_Request $request, string $object_type )
Handler for updating user custom field data. |
public static
boolean|integer
|
#
update_comment_rest_values( mixed $values, object $object, string $field_name, WP_REST_Request $request, string $object_type )
Handler for updating comment custom field data. |
public static
boolean|integer
|
#
update_term_rest_values( mixed $values, object $object, string $field_name, WP_REST_Request $request, string $object_type )
Handler for updating term custom field data. |
protected static
boolean|integer
|
#
update_rest_values( mixed $values, object $object, WP_REST_Request $request, string $object_type, string $main_object_type = 'post' )
Handler for updating custom field data. |
public static
mixed|boolean
|
#
santize_box_rest_values( array $values,
Updates box rest values. |
public
array
|
|
protected
mixed
|
#
sanitize_field_value( array $values, string $field_id )
Handles returning a sanitized field value. |
protected
mixed
|
#
sanitize_group_value( array $values,
Handles returning a sanitized group field value. |
public
|
#
is_protected_meta( boolean $protected, string $meta_key, string $meta_type )
Filter whether a meta key is protected. |
public static
integer
|
#
get_object_id( mixed $object, string $object_type = 'post' )
Get the object ID for the given object/type. |
public
mixed
|
#
field_can_read( string|
Checks if a given field can be read. |
public
mixed
|
#
field_can_edit( string|
Checks if a given field can be edited. |
protected
mixed
|
#
field_can( string $type, string|
Checks if a given field can be read or edited. |
public static
|
|
public static
|
|
public static
|
|
public static
boolean
|
|
public static
boolean
|
|
public
mixed
|
Methods inherited from CMB2_Hookup_Base
Constants summary
string |
VERSION
The current CMB2 REST endpoint version |
#
'1'
|
string |
NAME_SPACE
The CMB2 REST base namespace (v should always be followed by $version) |
#
'cmb2/v1'
|
Properties summary
public
|
$cmb
object |
|
protected static
|
$boxes
objects |
#
array()
|
protected static
array
|
$type_boxes
Array of cmb ids for each type. |
#
array(
'post' => array(),
'user' => array(),
'comment' => array(),
'term' => array(),
)
|
protected
|
$read_fields
Array of readable field objects. |
#
array()
|
protected
|
$edit_fields
Array of editable field objects. |
#
array()
|
protected
boolean
|
$rest_read
Whether CMB2 object is readable via the rest api. |
#
false
|
protected
boolean
|
$rest_edit
Whether CMB2 object is editable via the rest api. |
#
false
|