Quantcast
Channel: WordPress.org Forums » All Posts
Viewing all articles
Browse latest Browse all 95984

basku on "wp_script_is & wp_enqueue_scripts"

$
0
0

Hi :)

I am trying to modify an existing theme on local host to suit my needs. When in debug mode I am getting the following notice:

wp_script_is was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks

turns out the code that causes this notice is

[ Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code may now have been permanently damaged/corrupted by the forum's parser. The blockquote and code combination doesn't work. ]

/**
     * Display Primary Menu
     */

    if($this->display('menu_primary')) {

        // Register
        register_nav_menu( 'primary',  __( 'Primary Menu', 'themater' ) );

        // Display Hook
        $this->add_hook($this->options['menus']['menu-primary']['hook'], 'themater_menu_primary_display');

        if(!wp_script_is('jquery')) {
            wp_enqueue_script('jquery');
        }

        if(!wp_script_is('hoverIntent')) {
            wp_enqueue_script('hoverIntent', THEMATER_URL . '/js/hoverIntent.js');
        }

        if(!wp_script_is('superfish')) {
            wp_enqueue_script('superfish', THEMATER_URL . '/js/superfish.js');
        }

        $this->custom_js(themater_menu_primary_js());
    }

How do i correct this issue ?
What changes do i need to make ?

Any help would be greatly appreciated.
Thanks a lot :)

[ Please do not bump, that's not permitted here. ]


Viewing all articles
Browse latest Browse all 95984

Trending Articles