PHP code example of narmafzam / cmb2-tabs
1. Go to this page and download the library: Download narmafzam/cmb2-tabs 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/ */
narmafzam / cmb2-tabs example snippets
add_action( 'cmb2_admin_init', 'cmb2_sample_metabox' );
function cmb2_sample_metabox() {
$prefix = 'your_prefix_demo_';
$cmb_demo = new_cmb2_box( array(
'id' => $prefix . 'metabox',
'title' => __( 'Test Metabox', 'cmb2' ),
'object_types' => array( 'page', 'post' ), // Post type
'vertical_tabs' => true, // Set vertical tabs, default false
'tabs' => array(
array(
'id' => 'tab-1',
'icon' => 'dashicons-admin-site',
'title' => 'Tab 1',
'fields' => array(
$prefix . '_field_1',
$prefix . '_field_2',
),
),
array(
'id' => 'tab-2',
'icon' => 'dashicons-align-left',
'title' => 'Tab 2',
'fields' => array(
$prefix . '_field_3',
$prefix . '_field_4',
),
),
)
) );
$cmb_demo->add_field( array(
'name' => __( 'Test field 1', 'cmb2' ),
'id' => $prefix . '_field_1',
'type' => 'text',
) );
$cmb_demo->add_field( array(
'name' => __( 'Test field 2', 'cmb2' ),
'id' => $prefix . '_field_2',
'type' => 'text',
) );
$cmb_demo->add_field( array(
'name' => __( 'Test field 3', 'cmb2' ),
'id' => $prefix . '_field_3',
'type' => 'text',
) );
$cmb_demo->add_field( array(
'name' => __( 'Test field 4', 'cmb2' ),
'id' => $prefix . '_field_4',
'type' => 'text',
) );
}