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_Hookup

Handles hooking CMB2 forms/metaboxes into the post/attachement/user screens and handles hooking in and saving those fields.

CMB2_Hookup_Base
Extended by CMB2_Hookup

Direct known subclasses

CMB2_Options_Hookup

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

Methods summary

public static CMB2_Hookup_Base
# maybe_init_and_hookup( CMB2 $cmb )

A functionalized constructor, used for the hookup action callbacks.

A functionalized constructor, used for the hookup action callbacks.

Parameters

$cmb
The CMB2 object to hookup.

Returns

CMB2_Hookup_Base
$hookup The hookup object.

Throws

Exception
Failed implementation.

Since

2.2.6

Overrides

CMB2_Hookup_Base::maybe_init_and_hookup
public
# universal_hooks( )
public
# post_hooks( )
public
# comment_hooks( )
public
# user_hooks( )
public
# term_hooks( )
public
# options_page_hooks( )
protected static
# register_styles( )

Registers styles for CMB2

Registers styles for CMB2

Since

2.0.7
protected static
# register_js( )

Registers scripts for CMB2

Registers scripts for CMB2

Since

2.0.7
public static
# register_scripts( )

Registers scripts and styles for CMB2

Registers scripts and styles for CMB2

Since

1.0.0
public
# do_scripts( string $hook )

Enqueues scripts and styles for CMB2 in admin_head.

Enqueues scripts and styles for CMB2 in admin_head.

Parameters

$hook
Current hook for the admin page.

Since

1.0.0
public
# register_column_headers( array $columns )

Register the CMB2 field column headers.

Register the CMB2 field column headers.

Parameters

$columns
Array of columns available for the admin page.

Since

2.2.2
public
# column_display( string $column_name, mixed $object_id )

The CMB2 field column display output.

The CMB2 field column display output.

Parameters

$column_name
Current column name.
$object_id
Current object ID.

Since

2.2.2
public array
# columns_sortable( array $columns )

Returns the columns sortable array.

Returns the columns sortable array.

Parameters

$columns
An array of sortable columns.

Returns

array
$columns An array of sortable columns with CMB2 columns.

Since

2.6.1
public
# columns_sortable_orderby( object $query )

Return the query object to order by custom columns if selected

Return the query object to order by custom columns if selected

Parameters

$query
Object query from WordPress

Since

2.6.1
public
# return_column_display( $empty, $custom_column, $object_id )

Returns the column display.

Returns the column display.

Since

2.2.2
public
# add_context_metaboxes( )

Output the CMB2 box/fields in an alternate context (not in a standard metabox area).

Output the CMB2 box/fields in an alternate context (not in a standard metabox area).

Since

2.2.4
public
# output_context_metabox( )

Output the CMB2 box/fields in an alternate context (not in a standard metabox area).

Output the CMB2 box/fields in an alternate context (not in a standard metabox area).

Since

2.2.4
public
# context_box_title_markup_open( boolean $add_handle = true )

Output the opening markup for a context box.

Output the opening markup for a context box.

Parameters

$add_handle
Whether to add the metabox handle and opening div for .inside.

Since

2.2.4
public
# context_box_title_markup_close( boolean $add_inside_close = true )

Output the closing markup for a context box.

Output the closing markup for a context box.

Parameters

$add_inside_close
Whether to add closing div for .inside.

Since

2.2.4
public
# add_metaboxes( )

Add metaboxes (to 'post' or 'comment' object types)

Add metaboxes (to 'post' or 'comment' object types)

Since

1.0.0
public
# remove_default_tax_metaboxes( )

Remove the specified default taxonomy metaboxes for a post-type.

Remove the specified default taxonomy metaboxes for a post-type.

Since

2.2.3
public array
# postbox_classes( array $classes )

Modify metabox postbox classes.

Modify metabox postbox classes.

Parameters

$classes
Array of classes.

Returns

array
Modified array of classes

Since

2.2.4
protected array
# alternate_context_postbox_classes( array $classes )

Modify metabox altnernate context postbox classes.

Modify metabox altnernate context postbox classes.

Parameters

$classes
Array of classes.

Returns

array
Modified array of classes

Since

2.2.4
public
# metabox_callback( )

Display metaboxes for a post or comment object.

Display metaboxes for a post or comment object.

Since

1.0.0
public
# user_new_metabox( mixed $section )

Display metaboxes for new user page.

Display metaboxes for new user page.

Parameters

$section
User section metabox.

Since

1.0.0
public
# user_metabox( )

Display metaboxes for a user object.

Display metaboxes for a user object.

Since

1.0.0
public
# term_metabox( )

Display metaboxes for a taxonomy term object.

Display metaboxes for a taxonomy term object.

Since

2.2.0
public
# show_form_for_type( string $type )

Display metaboxes for an object type.

Display metaboxes for an object type.

Parameters

$type
Object type.

Since

2.2.0
public boolean
# show_on( )

Determines if metabox should be shown in current context.

Determines if metabox should be shown in current context.

Returns

boolean
Whether metabox should be added/shown.

Since

2.0.0
public integer
# get_priority( integer $default = 10 )

Get the CMB priority property set to numeric hook priority.

Get the CMB priority property set to numeric hook priority.

Parameters

$default
Default display hook priority.

Returns

integer
Hook priority.

Since

2.2.0
public
# save_post( integer $post_id, mixed $post = false )

Save data from post metabox

Save data from post metabox

Parameters

$post_id
Post ID.
$post
Post object.

Since

1.0.0
public
# save_comment( integer $comment_id )

Save data from comment metabox.

Save data from comment metabox.

Parameters

$comment_id
Comment ID.

Since

2.0.9
public
# save_user( integer $user_id )

Save data from user fields.

Save data from user fields.

Parameters

$user_id
User ID.

Since

1.0.x
public
# save_term( integer $term_id, integer $tt_id, string $taxonomy = '' )

Save data from term fields

Save data from term fields

Parameters

$term_id
Term ID.
$tt_id
Term Taxonomy ID.
$taxonomy
Taxonomy.

Since

2.2.0
public
# delete_term( integer $term_id, integer $tt_id, string $taxonomy = '' )

Delete term meta when a term is deleted.

Delete term meta when a term is deleted.

Parameters

$term_id
Term ID.
$tt_id
Term Taxonomy ID.
$taxonomy
Taxonomy.

Since

2.2.0
public boolean
# can_save( string $type = '' )

Determines if the current object is able to be saved.

Determines if the current object is able to be saved.

Parameters

$type
Current object type.

Returns

boolean
Whether object can be saved.

Since

2.0.9
public boolean
# taxonomy_can_save( string $taxonomy )

Determine if taxonomy of term being modified is cmb2-editable.

Determine if taxonomy of term being modified is cmb2-editable.

Parameters

$taxonomy
Taxonomy of term being modified.

Returns

boolean
Whether taxonomy is editable.

Since

2.2.0
protected
# maybe_enqueue_column_display_styles( )

Enqueues the 'cmb2-display-styles' if the conditions match (has columns, on the right page, etc).

Enqueues the 'cmb2-display-styles' if the conditions match (has columns, on the right page, etc).

Since

2.2.2.1
public static mixed
# enqueue_cmb_css( string $handle = 'cmb2-styles' )

Includes CMB2 styles.

Includes CMB2 styles.

Parameters

$handle
CSS handle.

Returns

mixed

Since

2.0.0
public static
# enqueue_cmb_js( )

Includes CMB2 JS.

Includes CMB2 JS.

Since

2.0.0

Methods inherited from CMB2_Hookup_Base

__construct(), __get(), once()

Properties summary

protected static boolean $js_registration_done

Only allow JS registration once

Only allow JS registration once

Since

2.0.7
# false
protected static boolean $css_registration_done

Only allow CSS registration once

Only allow CSS registration once

Since

2.0.7
# false
protected array $taxonomies

CMB taxonomies array for term meta

CMB taxonomies array for term meta

Since

2.2.0
# array()
protected array $columns

Custom field columns.

Custom field columns.

Since

2.2.2
# array()
protected CMB2_Options_Hookup[]|null $options_hookup

Array of CMB2_Options_Hookup instances if options page metabox.

Array of CMB2_Options_Hookup instances if options page metabox.

Since

2.2.5
# null

Properties inherited from CMB2_Hookup_Base

$cmb, $object_type

Magic properties inherited from CMB2_Hookup_Base

$cmb, $object_type

CMB2 Documentation API documentation generated by ApiGen