Kirki: Nested Panels not working

Created on 25 Jun 2017  路  5Comments  路  Source: kirki-framework/kirki

i am creating nested panels

Kirki::add_panel( 'theme_options', array(
    'title'       => esc_html__( 'Theme Options', 'hotelica' ),
    'type'          => 'nested',

) );

Kirki::add_panel( 'homepage_options', array(
    'title'       => esc_html__( 'Homepage Options', 'hotelica' ),
    'panel'          => 'theme_options',
    'type'          => 'nested',

) );

Kirki::add_section( 'banner' ,
    array(
        'title'          => esc_html__( 'Banner' , 'hotelica' ),
        'capability'     => 'edit_theme_options',
        'panel'          => 'homepage_options',
        'priority' => 1,
    ) 
);

I have added fields also but the parent Theme Options panel is not displaying. i have refered to this thread https://github.com/aristath/kirki/issues/1263 but not working

Most helpful comment

Fixed.

You can test with this code:

Kirki::add_config( 'my_config' );

Kirki::add_panel( 'test_panel', array(
    'title' => 'Panel',
));

Kirki::add_panel( 'test_panel_panel', array(
    'title' => 'Panel - Panel',
    'panel' => 'test_panel',
));

Kirki::add_section( 'test_panel_section', array(
    'title' => 'Panel - Section',
    'panel' => 'test_panel',
));

Kirki::add_section( 'test_panel_panel_section', array(
    'title' => 'Panel - Panel - Section',
    'panel' => 'test_panel_panel',
));

Kirki::add_section( 'test_panel_panel_section_section', array(
    'title'   => 'Panel - Panel - Section - Section',
    'section' => 'test_panel_panel_section',
));

foreach ( array( 'test_panel_section', 'test_panel_panel_section', 'test_panel_panel_section_section' ) as $section ) {
    Kirki::add_field( 'my_config', array(
        'type'     => 'text',
        'settings' => $section . '_setting',
        'section'  => $section,
        'label'    => 'A simple text control.',
    ));
}

All 5 comments

There seems to be a bug here... nested sections seem to work fine but not panels.
I'll investigate and hopefully fix this for 3.0.8

Hi have tried but panels are not working for me. My code is this

Kirki::add_panel( 'theme_options', array(
'title'       => esc_html__( 'Theme Options', 'hotelica' ),
'type'          => 'nested',

) );

Kirki::add_panel( 'homepage_options', array(
'title'       => esc_html__( 'Homepage Options', 'hotelica' ),
'panel'          => 'theme_options',
'type'          => 'nested',

) );

Kirki::add_section( 'banner' ,
array(
    'title'          => esc_html__( 'Banner' , 'hotelica' ),
    'capability'     => 'edit_theme_options',
    'panel'          => 'homepage_options',
    'priority' => 1,
) 
);

The 'type' => 'nested' is not necessary.
As soon as you add a parent section or panel it should automatically detect it

Fixed.

You can test with this code:

Kirki::add_config( 'my_config' );

Kirki::add_panel( 'test_panel', array(
    'title' => 'Panel',
));

Kirki::add_panel( 'test_panel_panel', array(
    'title' => 'Panel - Panel',
    'panel' => 'test_panel',
));

Kirki::add_section( 'test_panel_section', array(
    'title' => 'Panel - Section',
    'panel' => 'test_panel',
));

Kirki::add_section( 'test_panel_panel_section', array(
    'title' => 'Panel - Panel - Section',
    'panel' => 'test_panel_panel',
));

Kirki::add_section( 'test_panel_panel_section_section', array(
    'title'   => 'Panel - Panel - Section - Section',
    'section' => 'test_panel_panel_section',
));

foreach ( array( 'test_panel_section', 'test_panel_panel_section', 'test_panel_panel_section_section' ) as $section ) {
    Kirki::add_field( 'my_config', array(
        'type'     => 'text',
        'settings' => $section . '_setting',
        'section'  => $section,
        'label'    => 'A simple text control.',
    ));
}

It works...........

Was this page helpful?
0 / 5 - 0 ratings