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_Option

Handles getting/setting of values to an option array for a specific option key

Package: CMB2
License: GPL-2.0+
Author: CMB2 team
Located at includes/CMB2_Options.php

Methods summary

public
# __construct( string $option_key = '' )

Initiate option object

Initiate option object

Parameters

$option_key

Option key where data will be saved. Leave empty for temporary data store.

Since

2.0.0
public mixed
# delete_option( )

Delete the option from the db

Delete the option from the db

Returns

mixed
Delete success or failure

Since

2.0.0
public array
# remove( string $field_id, boolean $resave = false )

Removes an option from an option array

Removes an option from an option array

Parameters

$field_id
Option array field key.
$resave
Whether or not to resave.

Returns

array
Modified options

Since

1.0.1
public array
# get( string $field_id, mixed $default = false )

Retrieves an option from an option array

Retrieves an option from an option array

Parameters

$field_id
Option array field key.
$default
Fallback value for the option.

Returns

array
Requested field or default

Since

1.0.1
public boolean
# update( string $field_id, mixed $value = '', boolean $resave = false, boolean $single = true )

Updates Option data

Updates Option data

Parameters

$field_id
Option array field key.
$value
Value to update data with.
$resave
Whether to re-save the data.
$single
Whether data should not be an array.

Returns

boolean
Return status of update.

Since

1.0.1
public boolean
# set( array $options = array() )

Saves the option array Needs to be run after finished using remove/update_option

Saves the option array Needs to be run after finished using remove/update_option

Parameters

$options
Optional options to override.

Returns

boolean
Success/Failure

Since

1.0.1

Uses

apply_filters() Calls 'cmb2_override_option_save_{$this->key}' hook to allow overwriting the option value to be stored.


public mixed
# get_options( mixed $default = null )

Retrieve option value based on name of option.

Retrieve option value based on name of option.

Parameters

$default
Optional. Default value to return if the option does not exist.

Returns

mixed
Value set for the option.

Since

1.0.1

Uses

apply_filters() Calls 'cmb2_override_option_get_{$this->key}' hook to allow overwriting the option value to be retrieved.


public mixed
# __get( string $field )

Magic getter for our object.

Magic getter for our object.

Parameters

$field
Requested property.

Returns

mixed

Throws

Exception
Throws an exception if the field is invalid.

Since

2.6.0

Properties summary

protected array $options

Options array

Options array

# array()
protected string $key

Current option key

Current option key

# ''
CMB2 Documentation API documentation generated by ApiGen