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_Types

CMB field type objects

Package: CMB2
Category: WordPress_Plugin
License: GPL-2.0+
Author: CMB2 team
Since: 1.0.0
Link: https://cmb2.io
Located at includes/CMB2_Types.php

Methods summary

public
# __construct( CMB2_Field $field )
public
# __call( string $fieldtype, array $arguments )

Default fallback. Allows rendering fields via "cmb2_render_$fieldtype" hook

Default fallback. Allows rendering fields via "cmb2_render_$fieldtype" hook

Parameters

$fieldtype
Non-existent field type name
$arguments
All arguments passed to the method

Since

1.0.0
public
# render( )

Render a field (and handle repeatable)

Render a field (and handle repeatable)

Since

1.1.0
protected
# _render( )

Render a field type

Render a field type

Since

1.1.0
protected mixed
# proxy_method( string $method, mixed $default, array $args = array() )

Proxies the method call to the CMB2_Type_Base object, if it exists, otherwise returns a default fallback value.

Proxies the method call to the CMB2_Type_Base object, if it exists, otherwise returns a default fallback value.

Parameters

$method
Method to call on the CMB2_Type_Base object.
$default
Default fallback value if method is not found.
$args
Optional arguments to pass to proxy method.

Returns

mixed
Results from called method.

Since

2.2.2
protected boolean
# guess_type_object( string $method )

If no CMB2_Types::$type object is initiated when a proxy method is called, it means it's a custom field type (which SHOULD be instantiating a Type), but let's try and guess the type object for them and instantiate it.

If no CMB2_Types::$type object is initiated when a proxy method is called, it means it's a custom field type (which SHOULD be instantiating a Type), but let's try and guess the type object for them and instantiate it.

Parameters

$method
Method attempting to be called on the CMB2_Type_Base object.

Returns

boolean

Since

2.2.3
public boolean|array
# maybe_proxy_method( string $method, array $arguments )

Check for methods to be proxied to the CMB2_Type_Base object.

Check for methods to be proxied to the CMB2_Type_Base object.

Parameters

$method
The possible method to proxy.
$arguments
All arguments passed to the method.

Returns

boolean|array
False if not proxied, else array with 'value' key being the return of the method.

Since

2.2.4
public boolean|CMB2_Type_Base
# maybe_custom_field_object( string $fieldtype, array $args = array() )

Checks for a custom field CMB2_Type_Base class to use for rendering.

Checks for a custom field CMB2_Type_Base class to use for rendering.

Parameters

$fieldtype
Non-existent field type name.
$args
Optional field arguments.

Returns

boolean|CMB2_Type_Base

Type object if custom field is an object, false if field was added with cmb2_render_{$field_type} action.

Throws

Exception
if custom field type class does not extend CMB2_Type_Base.

Since

2.2.4
public CMB2_Type_Base
# get_new_render_type( string $fieldtype, string $render_class_name = null, array $args = array(), mixed $additional = '' )

Gets the render type CMB2_Type_Base object to use for rendering the field.

Gets the render type CMB2_Type_Base object to use for rendering the field.

Parameters

$fieldtype
The type of field being rendered.
$render_class_name
The default field type class to use. Defaults to null.
$args
Optional arguments to pass to type class.
$additional
Optional additional argument to pass to type class.

Returns

CMB2_Type_Base
Type object.

Since

2.2.4
public string
# get_render_type_class( string $fieldtype, string $render_class_name = null )

Checks for the render type class to use for rendering the field.

Checks for the render type class to use for rendering the field.

Parameters

$fieldtype
The type of field being rendered.
$render_class_name
The default field type class to use. Defaults to null.

Returns

string
The field type class to use.

Since

2.2.4
public string
# _text( string $text_key, string $fallback = '' )

Retrieve text parameter from field's options array (if it has one), or use fallback text

Retrieve text parameter from field's options array (if it has one), or use fallback text

Parameters

$text_key
Key in field's options array.
$fallback
Fallback text.

Returns

string

Since

2.0.0
public string|false
# get_file_ext( string $file )

Determine a file's extension

Determine a file's extension

Parameters

$file
File url

Returns

string|false
File extension or false

Since

1.0.0
public string
# get_file_name_from_path( string $value )

Get the file name from a url

Get the file name from a url

Parameters

$value
File url or path

Returns

string
File name

Since

2.0.0
public string
# concat_attrs( array $attrs, array $attr_exclude = array() )

Combines attributes into a string for a form element

Combines attributes into a string for a form element

Parameters

$attrs
Attributes to concatenate
$attr_exclude
Attributes that should NOT be concatenated

Returns

string
String of attributes for form element

Since

1.1.0
public
# render_repeatable_field( )

Generates repeatable field table markup

Generates repeatable field table markup

Since

1.0.0
public
# repeatable_rows( )

Generates repeatable field rows

Generates repeatable field rows

Since

1.1.0
protected
# repeat_row( string $classes = 'cmb-repeat-row' )

Generates a repeatable row's markup

Generates a repeatable row's markup

Parameters

$classes
Repeatable table row's class

Since

1.1.0
public string
# _desc( boolean $paragraph = false, boolean $echo = false, boolean $repeat_group = false )

Generates description markup.

Generates description markup.

Parameters

$paragraph
Paragraph tag or span.
$echo
Whether to echo description or only return it.
$repeat_group
Whether to repeat the group.

Returns

string
Field's description markup.

Since

1.0.0
public string
# _name( string $suffix = '' )

Generate field name attribute

Generate field name attribute

Parameters

$suffix
For multi-part fields

Returns

string
Name attribute

Since

1.1.0
public string
# _id( string $suffix = '', boolean $append_repeatable_iterator = true )

Generate field id attribute

Generate field id attribute

Parameters

$suffix
For multi-part fields
$append_repeatable_iterator
Whether to append the iterator attribue if the field is repeatable.

Returns

string
Id attribute

Since

1.1.0
public string
# input( array $args = array(), string $type = __FUNCTION__ )

Handles outputting an 'input' element

Handles outputting an 'input' element

Parameters

$args
Override arguments
$type
Field type

Returns

string
Form input element

Since

1.1.0
public string
# textarea( array $args = array() )

Handles outputting an 'textarea' element

Handles outputting an 'textarea' element

Parameters

$args
Override arguments

Returns

string
Form textarea element

Since

1.1.0
public
# text( )

Begin Field Types

Begin Field Types

public
# hidden( )
public
# text_small( )
public
# text_medium( )
public
# text_email( )
public
# text_url( )
public
# text_money( )
public
# textarea_small( )
public
# textarea_code( $args = array() )
public
# wysiwyg( $args = array() )
public
# text_date( $args = array() )
public
# text_date_timestamp( $args = array() )
public
# text_time( $args = array() )
public
# text_datetime_timestamp( $args = array() )
public
# text_datetime_timestamp_timezone( $args = array() )
public
# select_timezone( $args = array() )
public
# colorpicker( $args = array(), $meta_value = '' )
public
# title( $args = array() )
public
# select( $args = array() )
public
# taxonomy_select( $args = array() )
public
# taxonomy_select_hierarchical( $args = array() )
public
# radio( $args = array(), $type = __FUNCTION__ )
public
# radio_inline( $args = array() )
public
# multicheck( $type = 'checkbox' )
public
# multicheck_inline( )
public
# checkbox( $args = array(), $is_checked = null )
public
# taxonomy_radio( $args = array() )
public
# taxonomy_radio_hierarchical( $args = array() )
public
# taxonomy_radio_inline( $args = array() )
public
# taxonomy_multicheck( $args = array() )
public
# taxonomy_multicheck_hierarchical( $args = array() )
public
# taxonomy_multicheck_inline( $args = array() )
public
# oembed( $args = array() )
public
# file_list( $args = array() )
public
# file( $args = array() )

Properties summary

public integer $iterator

An iterator value for repeatable fields

An iterator value for repeatable fields

Since

1.0.0
# 0
public CMB2_Field $field

Current CMB2_Field field object

Current CMB2_Field field object

Since

1.0.0
#
public CMB2_Type_Base $type

Current CMB2_Type_Base object

Current CMB2_Type_Base object

Since

2.2.2
# null
CMB2 Documentation API documentation generated by ApiGen