프로퍼티 | 타입 | 설명 | |
---|---|---|---|
$data_to_save | array | Array of key => value data for saving. Likely $_POST data. |
프로퍼티 | 타입 | 설명 | |
---|---|---|---|
$cmb_id | string | Current CMB2 instance ID | |
$fields | array | Metabox field objects | |
$generated_nonce | string | Array of key => value data for saving. Likely $_POST data. | |
$has_columns | boolean | Whether there are fields to be shown in columns. Set in CMB2::add_field(). | |
$hidden_fields | array | An array of hidden fields to output at the end of the form | |
$mb_defaults | array | Metabox Defaults | |
$mb_object_type | string | Type of object registered for metabox. (e.g., post, user, or comment) | |
$meta_box | array | Metabox Config array | |
$object_id | mixed | Object ID for metabox meta retrieving/saving | |
$object_type | string | Type of object being saved. (e.g., post, user, or comment) | |
$updated | array | List of fields that are changed/updated on save |
메소드 | 설명 | |
---|---|---|
__construct ( array $meta_box, integer $object_id ) | Get started | |
__get ( string $field ) : mixed | Magic getter for our object. | |
add_field ( array $field, integer $position ) : mixed | Add a field to the metabox | |
add_group_field ( string $parent_field_id, array $field, integer $position ) : mixed | Add a field to a group | |
add_hidden_field ( array $field_args, $field_group = null ) | Add a hidden field to the list of hidden fields to be rendered later | |
after_save ( ) | ||
box_classes ( ) : string | Defines the classes for the CMB2 form/wrap. | |
current_object_type ( ) : string | Get the object type for the current page, based on the $pagenow global. | |
get_field ( string | array | CMB2_Field $field, CMB2_Field $field_group = null ) : CMB2_Field | false | Get a field object | |
get_field_args ( mixed $field_id, mixed $field_args, mixed $sub_field_id, mixed $field_group ) : array | Handles determining which type of arguments to pass to CMB2_Field | |
get_field_ids ( string $field_id, string $parent_field_id = '' ) : mixed | Check if field ids match a field and return the index/field id | |
get_sanitized_values ( array $data_to_sanitize ) | Returns array of sanitized field values (without saving them) | |
is_options_page_mb ( ) : boolean | Determines if metabox is for an options page | |
mb_object_type ( ) : string | Sets the $object_type based on metabox settings | |
nonce ( ) : string | Generate a unique nonce for each registered meta_box | |
nonce_field ( ) : string | Generate a unique nonce field for each registered meta_box | |
object_id ( integer $object_id ) : integer | Get object id from global space if no id is provided | |
object_type ( $object_type = '' ) : string | Returns the object type | |
pre_process ( ) | ||
process_field ( array $field_args ) | Process and save a field | |
process_fields ( ) | Process and save form fields | |
prop ( string $property, mixed $fallback = null ) : mixed | Get metabox property and optionally set a fallback | |
remove_field ( string $field_id, string $parent_field_id = '' ) : boolean | Remove a field from the metabox | |
render_field ( array $field_args ) : mixed | Renders a field based on the field type | |
render_form_close ( integer $object_id, string $object_type = '' ) : void | Outputs the closing form markup and runs corresponding hooks: 'cmb2_after_form' and "cmb2_after_{$object_type}_form_{$this->cmb_id}" | |
render_form_open ( integer $object_id, string $object_type = '' ) : void | Outputs the opening form markup and runs corresponding hooks: 'cmb2_before_form' and "cmb2_before_{$object_type}_form_{$this->cmb_id}" | |
render_group ( array $args ) : CMB2_Field | null | Render a repeatable group. | |
render_group_row ( CMB2_Field $field_group, string $remove_disabled ) | Render a repeatable group row | |
render_hidden_fields ( ) | Loop through and output hidden fields | |
save_fields ( integer $object_id, string $object_type = '', array $data_to_save = [] ) | Loops through and saves field data | |
save_group ( array $args ) : mixed | Save a repeatable group | |
save_group_field ( array $field_group ) : mixed | Save a repeatable group | |
search_old_school_array ( string $field_id, array $fields ) : mixed | When using the old array filter, it is unlikely field array indexes will be the field id | |
set_prop ( string $property, mixed $value ) : mixed | Set metabox property. | |
should_show ( ) : boolean | Determine whether this cmb object should show, based on the 'show_on_cb' callback. | |
show_form ( integer $object_id, string $object_type = '' ) | Loops through and displays fields | |
update_field_property ( string $field_id, string $property, mixed $value, string $parent_field_id = '' ) : mixed | Update or add a property to a field |
메소드 | 설명 | |
---|---|---|
_add_field_to_array ( array $field, &$fields, integer $position ) | Add a field array to a fields array in desired position | |
add_fields ( array $fields, mixed $parent_field_id = null ) | When fields are added in the old-school way, intitate them as they should be | |
get_default_args ( array $field_args, CMB2_Field $field_group = null ) : array | Get default field arguments specific to this CMB2 object. | |
get_new_field ( array $field_args, CMB2_Field $field_group = null ) : CMB2_Field | Get a new field object specific to this CMB2 object. |
public __construct ( array $meta_box, integer $object_id ) | ||
$meta_box | array | Metabox config array |
$object_id | integer | Optional object id |
protected _add_field_to_array ( array $field, &$fields, integer $position ) | ||
$field | array | Metabox field config array |
$position | integer | Optionally specify a position in the array to be inserted |
protected add_fields ( array $fields, mixed $parent_field_id = null ) | ||
$fields | array | Array of fields to add |
$parent_field_id | mixed | Parent field id or null |
public add_group_field ( string $parent_field_id, array $field, integer $position ) : mixed | ||
$parent_field_id | string | The field id of the group field to add the field |
$field | array | Metabox field config array |
$position | integer | (optional) Position of metabox. 1 for first, etc |
리턴 | mixed | Array of parent/field ids or false |
public box_classes ( ) : string | ||
리턴 | string | Space concatenated list of classes |
public current_object_type ( ) : string | ||
리턴 | string | Page object type name. |
protected get_default_args ( array $field_args, CMB2_Field $field_group = null ) : array | ||
$field_args | array | Metabox field config array. |
$field_group | CMB2_Field | (optional) CMB2_Field object (group parent) |
리턴 | array | Array of field arguments. |
public get_field ( string | array | CMB2_Field $field, CMB2_Field $field_group = null ) : CMB2_Field | false | ||
$field | string | array | CMB2_Field | Metabox field id or field config array or CMB2_Field object |
$field_group | CMB2_Field | (optional) CMB2_Field object (group parent) |
리턴 | CMB2_Field | false | CMB2_Field object (or false) |
public get_field_args ( mixed $field_id, mixed $field_args, mixed $sub_field_id, mixed $field_group ) : array | ||
$field_id | mixed | Field (or group field) ID |
$field_args | mixed | Array of field arguments |
$sub_field_id | mixed | Sub field ID (if field_group exists) |
$field_group | mixed | If a sub-field, will be the parent group CMB2_Field object |
리턴 | array | Array of CMB2_Field arguments |
protected get_new_field ( array $field_args, CMB2_Field $field_group = null ) : CMB2_Field | ||
$field_args | array | Metabox field config array. |
$field_group | CMB2_Field | (optional) CMB2_Field object (group parent) |
리턴 | CMB2_Field | CMB2_Field object |
public get_sanitized_values ( array $data_to_sanitize ) | ||
$data_to_sanitize | array | Array of field_id => value data for sanitizing (likely $_POST data). |
public is_options_page_mb ( ) : boolean | ||
리턴 | boolean | True/False |
public mb_object_type ( ) : string | ||
리턴 | string | Object type |
public nonce_field ( ) : string | ||
리턴 | string | unique nonce hidden input |
public object_type ( $object_type = '' ) : string | ||
리턴 | string | Object type |
public process_field ( array $field_args ) | ||
$field_args | array | Array of field arguments |
public render_field ( array $field_args ) : mixed | ||
$field_args | array | A field configuration array. |
리턴 | mixed | CMB2_Field object if successful. |
public render_group ( array $args ) : CMB2_Field | null | ||
$args | array | Array of field arguments for a group field parent. |
리턴 | CMB2_Field | null | Group field object. |
public render_group_row ( CMB2_Field $field_group, string $remove_disabled ) | ||
$field_group | CMB2_Field | CMB2_Field group field object |
$remove_disabled | string | Attribute string to disable the remove button |
public save_group ( array $args ) : mixed | ||
$args | array | Field arguments array |
리턴 | mixed | Return of CMB2_Field::update_data() |
public save_group_field ( array $field_group ) : mixed | ||
$field_group | array | CMB2_Field group field object |
리턴 | mixed | Return of CMB2_Field::update_data() |
public should_show ( ) : boolean | ||
리턴 | boolean | Whether this cmb should be shown. |
public update_field_property ( string $field_id, string $property, mixed $value, string $parent_field_id = '' ) : mixed | ||
$field_id | string | Field id |
$property | string | Field property to set/update |
$value | mixed | Value to set the field property |
$parent_field_id | string | (optional) The field id of the group field to remove field from |
리턴 | mixed | Field id. Strict compare to false, as success can return a falsey value (like 0) |
public array $data_to_save | ||
리턴 | array |
protected string $generated_nonce | ||
리턴 | string |
protected bool $has_columns | ||
리턴 | boolean |
protected string $mb_object_type | ||
리턴 | string |
protected mixed $object_id | ||
리턴 | mixed |
protected string $object_type | ||
리턴 | string |
protected array $updated | ||
리턴 | array |