Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $main_config = [
- 'title' => __( 'Main Page', 'igm-reviews' ),
- 'id' => 'main-page',
- 'tab_style' => 'box',
- 'tab_default_active' => 'tab_main',
- 'tabs' => [
- 'tab_main' => [
- 'label' => 'Activate TABS',
- 'icon' => 'admin-home',
- ],
- 'tab_1' => [
- 'label' => 'TAB 1',
- 'icon' => '',
- ],
- 'tab_2' => [
- 'label' => 'TAB 2',
- 'icon' => '',
- ]
- ],
- 'fields' => [
- [
- 'tab' => 'tab_main',
- 'name' => __( 'Activate Tab 1?', 'textdomain' ),
- 'id' => 'tab_1',
- 'type' => 'post',
- 'field_type' => 'switch',
- ],
- [
- 'tab' => 'tab_main',
- 'name' => __( 'Activate Tab 2?', 'textdomain' ),
- 'id' => 'tab_2',
- 'type' => 'post',
- 'field_type' => 'switch'
- ],
- ]
- ];
- // Then after saving tabs you check if switch are activated and add configuration array to main array
- $tab_1 = [
- 'tab' => 'tab_1',
- 'name' => __( 'Input Title', 'textdomain' ),
- 'id' => 'title',
- 'type' => 'post',
- 'field_type' => 'text',
- ];
- $tab_2 = [
- 'tab' => 'tab_2',
- 'name' => __( 'Input Name', 'textdomain' ),
- 'id' => 'name',
- 'type' => 'post',
- 'field_type' => 'text',
- ];
- // Read option of main tab saved
- $switch = get_option();
- // then check and add tabs
- if ( $switch( 'tab_1' ) == 'on' ) {
- $main_array['fields'][] = $tab_1;
- }
- return $main_array;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement