stackadroit/cmb2-extensions

This is a CMB2 Extension repository which help modify the default behavior of CMB2 and extends it's functionality.

dev-master 2017-11-16 23:41 UTC

README

This is a CMB2 Extension repository which help modify the default behavior of CMB2 and extends it's functionality.

Extension are organized into categories (folders) and each Extension is placed in its own file with a name that describes what it does.

Usage

You can view wiki page to usage and setup guide: Documentation

CMB2 Tabs

CMB2 Tabs is an extenstion for CMB2 which allow you to oragnize fields into tabs.

cmb2 tabs

Example

// Classic CMB2 declaration
$cmb = new_cmb2_box( array(
	'id'           => 'prefix-metabox-id',
	'title'        => __( 'Post Info' ),
	'object_types' => array( 'post', ), // Post type
	'tabs'      => array(
		'contact' => array(
			'label' => __( 'Contact', 'cmb2' ),
			//'show_on_cb' => 'yourprefix_show_if_front_page',
		),
		'social'  => array(
			'label' => __( 'Social Media', 'cmb2' ),
			'icon'  => 'dashicons-share', // Dashicon
		),
	),
	'tab_style'   => 'default',
) );

// Add new field
$cmb_demo->add_field( array(
	'name' => esc_html__( 'Test Text Medium', 'cmb2' ),
	'desc' => esc_html__( 'field description (optional)', 'cmb2' ),
	'id'   => $prefix . 'textmedium',
	'type' => 'text_medium',
	'tab'  => 'contact',
	'render_row_cb' => array( 'CMB2_Tabs', 'tabs_render_row_cb' ),
) );

// Add new field
$cmb_demo->add_field( array(
	'name' => esc_html__( 'Test Text Medium', 'cmb2' ),
	'desc' => esc_html__( 'field description (optional)', 'cmb2' ),
	'id'   => $prefix . 'textmedium2',
	'type' => 'text_medium',
	'tab'  => 'social',
	'render_row_cb' => array( 'CMB2_Tabs', 'tabs_render_row_cb' ),
) );