taunoha/cmb2-theme-options-with-tabs

How to add more tabs

K15Lmk98 opened this issue · 4 comments

This is an automatic translation.

Hello,
what code should i use to add more tabs?

Thank you, Claudio_

You can use the cmb2_theme_options_tab_tabs hook to do that.
For example:

function cmb2_theme_options_tab_tabs_callback($tabs)
{
    return array(
        'global' => array(
            'translated_name' => 'Global',
            'language_code' => 'global'
        ),
       'global2' => array(
            'translated_name' => 'Global2',
            'language_code' => 'global2'
        )
    );
}
add_filter('cmb2_theme_options_tab_tabs', 'cmb2_theme_options_tab_tabs_callback');

I assume that you aren't using WPML plugin?

Thank you Taunoha for the answer.

I do not use Wpml.

I understand how to create the second "global2" tab.
Now how to assign the fields only to the second "global2" tab?
Claudio

There is a 'show_in_tab' option in field defination that you can use.

array(
            'name'    => 'Facebook URL',
            'id'      => 'facebook_url',
            'type'    => 'text_url',
            'show_in_tab' => 'en' // <- language_Code
)

Thank you Taunoha.
Claudio_