Skip to content

Latest commit

 

History

History
21 lines (17 loc) · 1.6 KB

Notable-Changes-in-CMB2.md

File metadata and controls

21 lines (17 loc) · 1.6 KB

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' ),
	),
) ),