WordPress.org

Ready to get started?Download WordPress

Forums

preventing theme javascripts from loading on wp-login.php (2 posts)

  1. Magi182
    Member
    Posted 2 years ago #

    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?

  2. Magi182
    Member
    Posted 2 years ago #

    nevermind. Fixed it. The add_action line should have read:

    add_action('wp_enqueue_scripts', 'init_scripts');

Topic Closed

This topic has been closed to new replies.

About this Topic