vunamhung/cmb2_tab

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

Installs: 805

Dependents: 0

Suggesters: 2

Security: 0

Stars: 2

Watchers: 5

Forks: 0

Open Issues: 1

Language:JavaScript

1.0.3 2020-02-26 02:45 UTC

This package is auto-updated.

Last update: 2024-03-26 12:26:00 UTC


README

Tabs for CMB2.

How it works?

This plugin adds new parameters to CMB2 boxes:

  • vertical_tabs (bool)
  • tabs (array)

Example

add_action( 'cmb2_admin_init', 'cmb2_sample_metabox' );
function cmb2_sample_metabox() {
	$cmb_demo = new_cmb2_box([
		'id' => 'metabox',
		'title' => __('Test Metabox', 'cmb2'),
		'object_types' => ['page', 'post'], // Post type
		'vertical_tabs' => true, // Set vertical tabs, default false
		'tabs' => [
			[
				'id' => 'tab-1',
				'icon' => 'dashicons-admin-site',
				'title' => 'Tab 1',
				'fields' => ['field_1', 'field_2'],
			],
			[
				'id' => 'tab-2',
				'icon' => 'dashicons-align-left',
				'title' => 'Tab 2',
				'fields' => ['field_3', 'field_4'],
			],
		],
	]);

	$cmb_demo->add_field([
		'name' => __('Test field 1', 'cmb2'),
		'id' => 'field_1',
		'type' => 'text',
	]);

	$cmb_demo->add_field([
		'name' => __('Test field 2', 'cmb2'),
		'id' => 'field_2',
		'type' => 'text',
	]);

	$cmb_demo->add_field([
		'name' => __('Test field 3', 'cmb2'),
		'id' => 'field_3',
		'type' => 'text',
	]);

	$cmb_demo->add_field([
		'name' => __('Test field 4', 'cmb2'),
		'id' => 'field_4',
		'type' => 'text',
	]);
}