我正在尝试在Customizer中具有依赖字段。一个字段是复选框Enable Custom Excerpt Length
. 另一个是文本字段Custom Excerpt Length
. 我想使用实现上下文字段active_callback
. 我正在关注这篇文章。https://make.wordpress.org/core/2014/07/08/customizer-improvements-in-4-0/
我在检查回调函数中的控制值时遇到问题。
$wp_customize->add_setting( \'blueplanet_options[theme_enable_custom_excerpt]\',
array(
\'default\' => false,
\'capability\' => \'edit_theme_options\',
)
);
$wp_customize->add_control(
\'theme_enable_custom_excerpt\',
array(
\'label\' => \'Enable Custom Excerpt Length\',
\'section\' => \'admin_section\',
\'settings\' => \'blueplanet_options[theme_enable_custom_excerpt]\',
\'type\' => \'checkbox\',
)
);
$wp_customize->add_setting( \'blueplanet_options[theme_custom_excerpt_length]\',
array(
\'default\' => 20,
\'capability\' => \'edit_theme_options\',
)
);
$wp_customize->add_control(
\'theme_custom_excerpt_length\',
array(
\'label\' => \'Custom Excerpt Length\',
\'section\' => \'admin_section\',
\'settings\' => \'blueplanet_options[theme_custom_excerpt_length]\',
\'type\' => \'text\',
\'active_callback\' => \'flag_is_custom_excerpt_enabled\',
)
);
// Callback function
function flag_is_custom_excerpt_enabled(){
// how to check if `theme_enable_custom_excerpt` is enabled or disabled
}