在WordPress customizer脚本中,我试图将值从选择控件传递到显示与所选值关联的分类法的自定义控件(第一个控件)。
$wp_customize->add_control( new Tax_Dropdown_Control( $wp_customize, \'select_tax\', array(
\'section\' => \'section_1\',
\'label\' => __( \'Select Post Taxonomy\', \'textdomain\' ),
\'description\' => __( \'Select a taxonomy based on post type selected.\', \'textdomain\' ),
\'dropdown_args\' => array(
\'post_type\' => $wp_customize->get_setting("select_post_type"), // here I need to pass the first setting\'s value
),
) ) );
// custom controls related snippet
class Tax_Dropdown_Control extends WP_Customize_Control {
.....
$dropdown_args = wp_parse_args( $this->dropdown_args, array(
\'post_type\' => \'post\',
) );
$dropdown_args[\'echo\'] = false;
$taxonomies = get_object_taxonomies($dropdown_args);
if ($taxonomies) {
echo \'<select>\';
foreach ($taxonomies as $taxonomy ) {
echo \'<option>\'. $taxonomy. \'</option>\';
}
echo \'</select>\';
}
....
}
更改select post类型时,需要更新选项live。我不确定
active_callback
是否可以使用更新的变量调用函数?