get_theme_mod
在这种情况下,只有在保存和刷新后才能工作。要基于另一个控件的值隐藏控件,可以使用active_callback
第二个控件中的参数如下:
Spotlight_Kirki::add_field( \'spotlight_config\', array(
\'type\' => \'radio\',
\'settings\' => \'spotlight_layout_type\',
\'label\' => esc_html__( \'Layout Type\' , \'spotlight\' ),
\'section\' => \'spotlight_general\',
\'default\' => \'layout_dark\',
\'priority\' => 0,
\'choices\' => array(
\'dark\' => esc_html__( \'Dark version\', \'spotlight\' ),
\'light\' => esc_html__( \'Light version\', \'spotlight\' ),
\'coloured\' => esc_html__( \'Coloured version\', \'spotlight\' ),
),
) );
Spotlight_Kirki::add_field( \'spotlight_config\', array(
\'type\' => \'image\',
\'settings\' => \'spotlight_bg_image\',
\'label\' => esc_html__( \'Background Image\' , \'spotlight\' ),
\'section\' => \'spotlight_general\',
\'default\' => esc_html__( \'\', \'spotlight\' ),
\'priority\' => 0
\'active_callback\' => array(
array(
\'setting\' => \'spotlight_layout_type\',
\'operator\' => \'!==\',
\'value\' => \'coloured\',
),
),
) );
可在此处查看该论点的文档:
https://aristath.github.io/kirki/docs/arguments/active_callback.html通常在WordPress自定义程序中active_callback
将接受一个可调用的函数/方法,您必须在其中检查所需的条件,这只是Kirki提供的一个快捷方式,使事情变得更简单。