如何将Javascript功能与wordpress的自定义控件链接

时间:2018-08-02 00:32:41

标签: javascript php wordpress wordpress-theming

我在自定义部分添加了一个新部分

function select_theme_stylesheet( $wp_customize ){

    $wp_customize->add_section( 'theme_stylesheet_selector', array(
        'title'     => 'Select Color',
        'priorty'   => 50
    ));

    $wp_customize->add_setting( 'theme_stylesheet_settings', array(
        'default'       => 'green',
        'transport'     => 'postMessage'
    ));

    $wp_customize->add_control( new WP_Customize_Control( $wp_customize,'theme_stylesheet_control',array(
        'type'      => 'radio',
        'label'     => 'Theme Scheme',
        'section'  => 'theme_stylesheet_selector',
        'settings' => 'theme_stylesheet_settings',
        'choices'   => array(
            'green',
            'blue'
        ),
        'selection'  => 'colors',
        'priorty'    => 9
    ) ));
}

add_action('customize_register', 'select_theme_stylesheet');

并且我在'customize.preview.js'中具有以下功能

wp.customize( 'theme_stylesheet_control', function( value ) {
    value.bind( function( newval ) {

        alert("hello" + newval);
    } );
} );

但是没有触发。谁能告诉我我想念的东西。

0 个答案:

没有答案