PHP code example of vunamhung / cmb2_tab

1. Go to this page and download the library: Download vunamhung/cmb2_tab library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vunamhung / cmb2_tab example snippets


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',
	]);
}