kirki
kirki copied to clipboard
Tweak: Enable Using active_callback Inside Repeater Controls
Hey guys, This is a solution to use the [active_callback] within Repeater controls for the newer version 4.x.x.
And here's a full example:
new \Kirki\Field\Repeater( [
'settings' => '_builder_repeater',
'label' => esc_html__('Builder', 'text-domain'),
'description' => '',
'help' => '',
'section' => 'section_id',
'default' => '',
'priority' => 10,
'row_label' => array(
'type' => 'field',
'value' => esc_html__('Layout', 'text-domain' ),
'field' => 'layout',
),
'default' => array(),
'fields' => array(
'layout' => array(
'type' => 'select',
'label' => esc_html__( 'The Box Layout', 'text-domain' ),
'description' => '',
'default' => 'classic',
'choices' => array(
'classic' => esc_html__( 'Classic', 'text-domain' ),
'horizontal' => esc_html__( 'Horizontal', 'text-domain' ),
'vertical' => esc_html__( 'Vertical', 'text-domain' ),
'review' => esc_html__( 'Best Reviews', 'text-domain' ),
)
),
'title' => array(
'type' => 'text',
'label' => esc_html__( 'Title', 'text-domain' ),
'description' => '',
'default' => '',
),
'category' => array(
'type' => 'select',
'label' => esc_html__( 'Category', 'text-domain' ),
'description' => '',
'default' => 'img',
'choices' => array(
'img' => esc_html__( 'Images', 'text-domain' ),
'video' => esc_html__( 'Video', 'text-domain' ),
'audio' => esc_html__( 'Audio', 'text-domain' ),
),
),
'title_2' => array(
'type' => 'text',
'label' => esc_html__( 'Title #2', 'text-domain' ),
'description' => '',
'default' => '',
'active_callback' => array(
array(
'setting' => 'layout',
'operator' => '==',
'value' => 'vertical',
),
array(
'setting' => 'category',
'operator' => '==',
'value' => 'video',
)
)
),
'cat_2' => array(
'type' => 'select',
'label' => esc_html__( 'Category #2', 'text-domain' ),
'description' => '',
'default' => 'animal',
'choices' => array(
'animal' => esc_html__( 'Animals', 'text-domain' ),
'flys' => esc_html__( 'Flys', 'text-domain' ),
),
'active_callback' => array(
array(
'setting' => 'layout',
'operator' => '==',
'value' => 'vertical',
)
)
),
'rev_title' => array(
'type' => 'text',
'label' => esc_html__( 'Review Title', 'text-domain' ),
'description' => '',
'default' => '',
'active_callback' => array(
array(
'setting' => 'layout',
'operator' => '==',
'value' => 'review',
)
)
),
)
] );
I copied your example and it doesn't work.
@free3p You must modify the main Kirki files [New Files]
@free3p You must modify the main Kirki files [New Files] Ok. Thanks