如果父控件已取消选中,如何刷新条件控件的值?

时间:2018-05-24 作者:coolpasta

我有两个控件,其中一个取决于另一个控件的显示:

   $wp_customize->add_section(
        \'woo_enchancements\',
        [
            \'title\' => __( \'WooCommerce Enchancements\', \'_amnth\' ),
            \'priority\' => 32,
            \'active_callback\' => \'is_woocommerce_active\',
            \'description\' => \'Must refresh the page after tweaking settings to see effects.\'
    ]
);

$wp_customize->add_setting(
    \'load_woo_custom_functionality\',
    [
        \'default\' => \'0\',
        \'transport\' => \'refresh\'
    ]
);

$wp_customize->add_control(
    new WP_Customize_Control(
        $wp_customize,
        \'load_woo_custom_functionality_control\',
        [
            \'label\'  => __( \'Load up Woo Enchancements?\', \'_amnth\' ),
            \'section\' => \'woo_enchancements\',
            \'settings\' => \'load_woo_custom_functionality\',
            \'type\' => \'checkbox\',
        ]
    )
);

$wp_customize->add_setting(
    \'display_woo_header\',
    [
        \'default\' => \'0\',
        \'transport\' => \'refresh\'
    ]
);

$wp_customize->add_control(
    new WP_Customize_Control(
        $wp_customize,
        \'display_woo_header_control\',
        [
            \'label\'  => __( \'Display Woo Header?\', \'_amnth\' ),
            \'section\' => \'woo_enchancements\',
            \'settings\' => \'display_woo_header\',
            \'type\' => \'checkbox\',
            \'active_callback\' => \'is_woocommerce_enchanced\'
        ]
    )
);
display_header 取决于load_woo_custom_functionality 要加载,but when I set the value of display_header 然后我取消选中load_woo_custom_functionality, 当该值应默认为其默认值时,该值仍然保持不变-在这种情况下,0.

下面是发生的情况的说明:

Customizer not flushing conditioned controls values

没有。我怎样才能确保发生这种情况?

1 个回复
SO网友:coolpasta

后来我发现,确实,这些值被刷新了,but you can only see the effect after you\'ve closed the customizer (a refresh).

不需要任何刷新功能。

结束

相关推荐