• Resolved Dimoncheg777

    (@dimoncheg777)


    Hi there.
    I’m trying to make some customizer for my theme, but i’ve got JS error “Uncaught ReferenceError: wp is not defined ” LOL. I wrote all code based on Codex, maybe it is just WP 3.8 bug? Or what i’m doing wrong?

    my code – PHP:

    add_action( 'customize_preview_init', 'customizer_preview' );
    
    function customizer_preview() {
            wp_register_script( 'wproto-customizer-preview', get_template_directory_uri() . '/js/admin/screen-customizer.js', '', true );
            wp_enqueue_script( 'wproto-customizer-preview', array( 'jquery', 'customize-preview' ) );
    }

    JS:

    ( function( $ ) {
    
        // here i've got an error "wp is not defined"
        wp.customize( 'blogname', function( value ) {
            value.bind( function( newval ) {
                $( '#text-logo .site-title' ).html( newval );
            } );
        } );
    } )( jQuery );

    please help 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • Change this:

    add_action( 'customize_preview_init', array( 'customizer_preview' );

    To this:

    add_action( 'customize_preview_init', array( $this, 'customizer_preview' ));

    I’m assuming you’re writing this function inside a class?

    Thread Starter Dimoncheg777

    (@dimoncheg777)

    you’re right, i wrote this function in class, but it doesn’t matter, I just simplified the code here. p.s. i got JS error 🙁

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘WP 3.8 theme customizer error’ is closed to new replies.