CMB2 Documentation
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  • Hooks
  • Download Docs
  • Github

Packages

  • CMB2
  • Demo
    • CMB2
  • None
  • Tests
    • CMB2

Classes

  • CMB2
  • CMB2_Ajax
  • CMB2_Base
  • CMB2_Bootstrap_2101
  • CMB2_Boxes
  • CMB2_Display_Checkbox
  • CMB2_Display_Colorpicker
  • CMB2_Display_File
  • CMB2_Display_File_List
  • CMB2_Display_Multicheck
  • CMB2_Display_oEmbed
  • CMB2_Display_Select
  • CMB2_Display_Taxonomy_Multicheck
  • CMB2_Display_Taxonomy_Radio
  • CMB2_Display_Text_Date
  • CMB2_Display_Text_Date_Timezone
  • CMB2_Display_Text_Money
  • CMB2_Display_Text_Time
  • CMB2_Display_Text_Url
  • CMB2_Display_Textarea
  • CMB2_Display_Textarea_Code
  • CMB2_Field
  • CMB2_Field_Display
  • CMB2_Hookup
  • CMB2_Hookup_Base
  • CMB2_JS
  • CMB2_Option
  • CMB2_Options
  • CMB2_Options_Hookup
  • CMB2_REST
  • CMB2_REST_Controller
  • CMB2_REST_Controller_Boxes
  • CMB2_REST_Controller_Fields
  • CMB2_Sanitize
  • CMB2_Show_Filters
  • CMB2_Type_Base
  • CMB2_Type_Checkbox
  • CMB2_Type_Colorpicker
  • CMB2_Type_Counter_Base
  • CMB2_Type_File
  • CMB2_Type_File_Base
  • CMB2_Type_File_List
  • CMB2_Type_Multi_Base
  • CMB2_Type_Multicheck
  • CMB2_Type_Oembed
  • CMB2_Type_Picker_Base
  • CMB2_Type_Radio
  • CMB2_Type_Select
  • CMB2_Type_Select_Timezone
  • CMB2_Type_Taxonomy_Base
  • CMB2_Type_Taxonomy_Multicheck
  • CMB2_Type_Taxonomy_Multicheck_Hierarchical
  • CMB2_Type_Taxonomy_Radio
  • CMB2_Type_Taxonomy_Radio_Hierarchical
  • CMB2_Type_Taxonomy_Select
  • CMB2_Type_Taxonomy_Select_Hierarchical
  • CMB2_Type_Text
  • CMB2_Type_Text_Date
  • CMB2_Type_Text_Datetime_Timestamp
  • CMB2_Type_Text_Datetime_Timestamp_Timezone
  • CMB2_Type_Text_Time
  • CMB2_Type_Textarea
  • CMB2_Type_Textarea_Code
  • CMB2_Type_Title
  • CMB2_Type_Wysiwyg
  • CMB2_Types
  • CMB2_Utils
  • Test_CMB2_Utils_WIN

Functions

  • _tests_cmb2_manually_load_plugin
  • cmb2_ajax
  • cmb2_autoload_classes
  • cmb2_bootstrap
  • cmb2_dir
  • cmb2_do_oembed
  • cmb2_get_field
  • cmb2_get_field_value
  • cmb2_get_metabox
  • cmb2_get_metabox_form
  • cmb2_get_metabox_sanitized_values
  • cmb2_get_oembed
  • cmb2_get_option
  • cmb2_metabox_form
  • cmb2_options
  • cmb2_print_metabox_form
  • cmb2_update_option
  • cmb2_utils
  • date_create_from_format
  • date_timestamp_get
  • new_cmb2_box

Hooks

  • Hook Reference

Class CMB2_REST_Controller_Fields

CMB2 objects/fields endpoint for WordPres REST API. Allows access to fields registered to a specific box.

WP_REST_Controller
Extended by CMB2_REST_Controller
Extended by CMB2_REST_Controller_Boxes
Extended by CMB2_REST_Controller_Fields
Package: CMB2
Category: WordPress_Plugin
License: GPL-2.0+
Author: CMB2 team
Since: 2.2.3
Link: https://cmb2.io
Todo: Add better documentation.
Todo: Research proper schema.
Located at includes/rest-api/CMB2_REST_Controller_Fields.php

Methods summary

public
# register_routes( )

Register the routes for the objects of the controller.

Register the routes for the objects of the controller.

Since

2.2.3

Overrides

CMB2_REST_Controller_Boxes::register_routes
public WP_Error|boolean
# get_items_permissions_check( WP_REST_Request $request )

Check if a given request has access to get fields. By default, no special permissions needed, but filtering return value.

Check if a given request has access to get fields. By default, no special permissions needed, but filtering return value.

Parameters

$request
Full data about the request.

Returns

WP_Error|boolean

Since

2.2.3

Overrides

CMB2_REST_Controller_Boxes::get_items_permissions_check
public WP_Error|WP_REST_Response
# get_items( WP_REST_Request $request )

Get all public CMB2 box fields.

Get all public CMB2 box fields.

Parameters

$request
Full data about the request.

Returns

WP_Error|WP_REST_Response

Since

2.2.3

Overrides

CMB2_REST_Controller_Boxes::get_items
public WP_Error|boolean
# get_item_permissions_check( WP_REST_Request $request )

Check if a given request has access to a field. By default, no special permissions needed, but filtering return value.

Check if a given request has access to a field. By default, no special permissions needed, but filtering return value.

Parameters

$request
Full details about the request.

Returns

WP_Error|boolean

Since

2.2.3

Overrides

CMB2_REST_Controller_Boxes::get_item_permissions_check
public WP_Error|boolean
# get_item_permissions_check_filter( boolean $can_access = true )

Check by filter if a given request has access to a field. By default, no special permissions needed, but filtering return value.

Check by filter if a given request has access to a field. By default, no special permissions needed, but filtering return value.

Parameters

$can_access
Whether the current request has access to view the field by default.

Returns

WP_Error|boolean

Since

2.2.3

Overrides

CMB2_REST_Controller_Boxes::get_item_permissions_check_filter
public WP_Error|WP_REST_Response
# get_item( WP_REST_Request $request )

Get one CMB2 field from the collection.

Get one CMB2 field from the collection.

Parameters

$request
Full data about the request.

Returns

WP_Error|WP_REST_Response

Since

2.2.3

Overrides

CMB2_REST_Controller_Boxes::get_item
public WP_Error|boolean
# update_item_permissions_check( WP_REST_Request $request )

Check if a given request has access to update a field value. By default, requires 'edit_others_posts' capability, but filtering return value.

Check if a given request has access to update a field value. By default, requires 'edit_others_posts' capability, but filtering return value.

Parameters

$request
Full details about the request.

Returns

WP_Error|boolean

Since

2.2.3

Overrides

WP_REST_Controller::update_item_permissions_check
public WP_Error|WP_REST_Response
# update_item( WP_REST_Request $request )

Update CMB2 field value.

Update CMB2 field value.

Parameters

$request
Full data about the request.

Returns

WP_Error|WP_REST_Response

Since

2.2.3

Overrides

WP_REST_Controller::update_item
public WP_Error|boolean
# delete_item_permissions_check( WP_REST_Request $request )

Check if a given request has access to delete a field value. By default, requires 'delete_others_posts' capability, but filtering return value.

Check if a given request has access to delete a field value. By default, requires 'delete_others_posts' capability, but filtering return value.

Parameters

$request
Full details about the request.

Returns

WP_Error|boolean

Since

2.2.3

Overrides

WP_REST_Controller::delete_item_permissions_check
public WP_Error|WP_REST_Response
# delete_item( WP_REST_Request $request )

Delete CMB2 field value.

Delete CMB2 field value.

Parameters

$request
Full data about the request.

Returns

WP_Error|WP_REST_Response

Since

2.2.3

Overrides

WP_REST_Controller::delete_item
public WP_Error|WP_REST_Response
# modify_field_value( string $activity )

Modify CMB2 field value.

Modify CMB2 field value.

Parameters

$activity
The modification activity (updated or deleted).

Returns

WP_Error|WP_REST_Response

Since

2.2.3
public WP_Error|WP_REST_Response
# prepare_read_field( string\CMB2_Field $field )

Get a response object for a specific field ID.

Get a response object for a specific field ID.

Parameters

$field
id or Field object.

Returns

WP_Error|WP_REST_Response

Since

2.2.3
public array
# prepare_field_response( )

Get a specific field response.

Get a specific field response.

Returns

array
Response array.

Since

2.2.3
protected array
# prepare_field_data( CMB2_Field $field )

Prepare the field data array for JSON.

Prepare the field data array for JSON.

Parameters

$field
field object.

Returns

array
Array of field data.

Since

2.2.3
public array
# get_supporting_data( CMB2_Field $field_data, array $field )

Gets field supporting data (field id and value).

Gets field supporting data (field id and value).

Parameters

$field_data
$field Field object.
$field
$field_data Array of field data.

Returns

array
Array of field data.

Since

2.7.0
protected array
# prepare_links( CMB2_Field $field )

Return an array of contextual links for field/fields.

Return an array of contextual links for field/fields.

Parameters

$field
Field object to build links from.

Returns

array
Array of links

Since

2.2.3

Overrides

CMB2_REST_Controller_Boxes::prepare_links
public boolean
# maybe_hook_registered_callback( string $filter, boolean $default_val )

Checks if the CMB2 box or field has any registered callback parameters for the given filter.

Checks if the CMB2 box or field has any registered callback parameters for the given filter.

The registered handlers will have a property name which matches the filter, except: - The 'cmb2_api' prefix will be removed - A '_cb' suffix will be added (to stay inline with other '*_cb' parameters).

Parameters

$filter
The filter name.
$default_val
The default filter value.

Returns

boolean
The possibly-modified filter value (if the _cb param is a non-callable).

Since

2.2.3

Overrides

CMB2_REST_Controller::maybe_hook_registered_callback
public
# maybe_unhook_registered_callback( string $filter )

Unhooks any CMB2 box or field registered callback parameters for the given filter.

Unhooks any CMB2 box or field registered callback parameters for the given filter.

Parameters

$filter
The filter name.

Since

2.2.3

Overrides

CMB2_REST_Controller::maybe_unhook_registered_callback

Methods inherited from CMB2_REST_Controller_Boxes

__construct(), get_rest_box()

Methods inherited from CMB2_REST_Controller

get_cb_results(), get_intial_request_type(), get_intial_route(), get_item_schema(), get_query_string(), initiate_request(), initiate_rest_box(), initiate_rest_edit_box(), initiate_rest_read_box(), maybe_hook_callback_and_apply_filters(), prepare_item(), prepare_item_for_response()

Methods inherited from WP_REST_Controller

add_additional_fields_schema(), add_additional_fields_to_object(), create_item(), create_item_permissions_check(), filter_response_by_context(), get_additional_fields(), get_collection_params(), get_context_param(), get_endpoint_args_for_item_schema(), get_object_type(), get_post(), get_public_item_schema(), prepare_item_for_database(), prepare_response_for_collection(), update_additional_fields_for_object()

Properties summary

Properties inherited from CMB2_REST_Controller_Boxes

$namespace_base, $rest_base

Properties inherited from CMB2_REST_Controller

$field, $namespace, $object_id, $object_type, $request, $request_type, $rest_box, $route, $server

CMB2 Documentation API documentation generated by ApiGen