Skip to content

Notable Changes in CMB2

Justin Sternberg edited this page May 13, 2019 · 7 revisions

Change 1: The same hooks and filters you're used to will be there, though you'll be required to use the cmb2_ prefix instead of the original cmb_, and the order and type of parameters passed to those actions have likely changed.

Change 2: The main filter for adding metaboxes, 'cmb2_meta_boxes', is still there, but it is recommended that you instead use the registration functions available and use the 'cmb_init' action hook. You can see them demonstrated in example-functions.php.

Change 3: The old method for including the CMB core files is no longer applicable and you're simply required to include it directly. This is not applicable if installing as a standard WordPress plugin.

Change 4: The 'pages' metabox parameter has been changed to 'object_types' to more accurately reflect its purpose, since it will accept post_types as well as other object types like 'user', 'comment', or 'options-page'.

Change 5: The 'options' field parameter for radio and select fields is now created with an id => label key value pairing. i.e.

$cmb->add_field( array(
	'name'    => __( 'Test Select', 'cmb2' ),
	'id'      => 'yourprefix_test_select',
	'type'    => 'select',
	'options' => array(
		'standard' => __( 'Option One', 'cmb2' ),
		'custom'   => __( 'Option Two', 'cmb2' ),
		'none'     => __( 'Option Three', 'cmb2' ),
	),
) ),

Documentation:

  1. Home

  2. Installation
    Installation instructions for various environments

  3. Basic Usage
    Get up and running

  4. Advanced Usage
    Not for the faint of heart

  5. Field Types
    Breakdown of field types

  6. Examples
    Examples for registering fields

  7. Field Parameters
    Breakdown of common field parameters

  8. Display Options
    Limit display of boxes

  9. Box Properties
    Breakdown of box properties

  10. Troubleshooting
    Common issues & how to deal with them

  11. Notable Changes in CMB2 (from original CMB)
    CMB2 — a complete re-write

  12. Tips & Tricks
    10x your CMB2 skills

  13. REST API
    CMB2 data through WordPress REST API

  14. Javascript API
    Work with CMB2 JS events & hooks

Advanced tutorials:

External Resources:

Clone this wiki locally