WordPress.org

Support

Support » Themes and Templates » preventing theme javascripts from loading on wp-login.php

preventing theme javascripts from loading on wp-login.php

  • I am having a problem after the most recent update to Version 3.3.1. I have the following code as part of my theme’s functions.php

    function init_scripts() {
    
    	$jsurl = get_bloginfo('template_directory') . '/js';
    
    	wp_enqueue_script('jquery');
    
    	if ( !is_admin() ) {
    		wp_register_script(
    			'formlabels',
    			$jsurl . '/jquery.formlabels.js',
    			array('jquery'),
    			'1.0' );
    		wp_register_script(
    			'showhide',
    			$jsurl . '/jquery.show-hide.js',
    			array('jquery'),
    			'1.0' );
    		wp_enqueue_script('formlabels');
    		wp_enqueue_script('showhide');
    	}
    }    
    
    add_action('init', 'init_scripts');

    In the past, this !is_admin() has prevented the two scripts from loading on the admin pages. Since the update, the scripts are now loading on wp-login.php, and the formlabels script is messing up the login form.

    Suggestions to prevent these scripts from being enqueued on wp-login.php?

Viewing 1 replies (of 1 total)
  • nevermind. Fixed it. The add_action line should have read:

    add_action('wp_enqueue_scripts', 'init_scripts');
Viewing 1 replies (of 1 total)
  • The topic ‘preventing theme javascripts from loading on wp-login.php’ is closed to new replies.
Skip to toolbar