Done !
| Server IP : 46.105.57.169 / Your IP : 216.73.216.67 Web Server : Apache System : Linux webm002.cluster120.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64 User : verseaumee ( 152031) PHP Version : 8.5.7 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/verseaumee/blueversion/wp-content/plugins/wp-freeio/libraries/cmb2/cmb2-tabs/ |
Upload File : |
<?php
/*
* Example metabox
*/
add_filter( 'cmb2_init', 'cmbt_example_metaboxes' );
function cmbt_example_metaboxes() {
$box_options = array(
'id' => 'example_tabs_metaboxes',
'title' => __( 'Example tabs', 'wp-freeio' ),
'object_types' => array( 'page' ),
'show_names' => true,
);
// Setup meta box
$cmb = new_cmb2_box( $box_options );
// Setting tabs
$tabs_setting = array(
'config' => $box_options,
// 'layout' => 'vertical', // Default : horizontal
'tabs' => array()
);
$tabs_setting['tabs'][] = array(
'id' => 'tab1',
'title' => __( 'Tab 1', 'wp-freeio' ),
'fields' => array(
array(
'name' => __( 'Title', 'wp-freeio' ),
'id' => 'header_title',
'type' => 'text'
),
array(
'name' => __( 'Subtitle', 'wp-freeio' ),
'id' => 'header_subtitle',
'type' => 'text'
),
array(
'name' => __( 'Background image', 'wp-freeio' ),
'id' => 'header_background',
'type' => 'file',
'options' => array(
'url' => false
)
)
)
);
$tabs_setting['tabs'][] = array(
'id' => 'tab2',
'title' => __( 'Tab 2', 'wp-freeio' ),
'fields' => array(
array(
'name' => __( 'Title', 'wp-freeio' ),
'id' => 'review_title',
'type' => 'text'
),
array(
'name' => __( 'Subtitle', 'wp-freeio' ),
'id' => 'review_subtitle',
'type' => 'text'
),
array(
'id' => 'reviews',
'type' => 'group',
'options' => array(
'group_title' => __( 'Review {#}', 'wp-freeio' ),
'add_button' => __( 'Add review', 'wp-freeio' ),
'remove_button' => __( 'Remove review', 'wp-freeio' ),
'sortable' => false
),
'fields' => array(
array(
'name' => __( 'Author name', 'wp-freeio' ),
'id' => 'name',
'type' => 'text'
),
array(
'name' => __( 'Author avatar', 'wp-freeio' ),
'id' => 'avatar',
'type' => 'file',
'options' => array(
'url' => false
)
),
array(
'name' => __( 'Comment', 'wp-freeio' ),
'id' => 'comment',
'type' => 'textarea'
)
)
)
)
);
// Set tabs
$cmb->add_field( array(
'id' => '__tabs',
'type' => 'tabs',
'tabs' => $tabs_setting
) );
}
/*
* Example options page
*/
add_action( 'cmb2_admin_init', 'cmbt_example_options_page_metabox' );
function cmbt_example_options_page_metabox() {
$box_options = array(
'id' => 'myprefix_option_metabox',
'title' => __( 'Example tabs', 'wp-freeio' ),
'show_names' => true,
'object_type' => 'options-page',
'show_on' => array(
// These are important, don't remove
'key' => 'options-page',
'value' => array( 'myprefix_options' )
),
);
// Setup meta box
$cmb = new_cmb2_box( $box_options );
// setting tabs
$tabs_setting = array(
'config' => $box_options,
// 'layout' => 'vertical', // Default : horizontal
'tabs' => array()
);
$tabs_setting['tabs'][] = array(
'id' => 'tab1',
'title' => __( 'Tab 1', 'wp-freeio' ),
'fields' => array(
array(
'name' => __( 'Title', 'wp-freeio' ),
'id' => 'header_title',
'type' => 'text'
),
array(
'name' => __( 'Subtitle', 'wp-freeio' ),
'id' => 'header_subtitle',
'type' => 'text'
),
array(
'name' => __( 'Background image', 'wp-freeio' ),
'id' => 'header_background',
'type' => 'file',
'options' => array(
'url' => false
)
)
)
);
$tabs_setting['tabs'][] = array(
'id' => 'tab2',
'title' => __( 'Tab 2', 'wp-freeio' ),
'fields' => array(
array(
'name' => __( 'Title', 'wp-freeio' ),
'id' => 'review_title',
'type' => 'text'
),
array(
'name' => __( 'Subtitle', 'wp-freeio' ),
'id' => 'review_subtitle',
'type' => 'text'
),
array(
'id' => 'reviews',
'type' => 'group',
'options' => array(
'group_title' => __( 'Review {#}', 'wp-freeio' ),
'add_button' => __( 'Add review', 'wp-freeio' ),
'remove_button' => __( 'Remove review', 'wp-freeio' ),
'sortable' => false
),
'fields' => array(
array(
'name' => __( 'Author name', 'wp-freeio' ),
'id' => 'name',
'type' => 'text'
),
array(
'name' => __( 'Author avatar', 'wp-freeio' ),
'id' => 'avatar',
'type' => 'file',
'options' => array(
'url' => false
)
),
array(
'name' => __( 'Comment', 'wp-freeio' ),
'id' => 'comment',
'type' => 'textarea'
)
)
)
)
);
$cmb->add_field( array(
'id' => '__tabs',
'type' => 'tabs',
'tabs' => $tabs_setting
) );
}