WordPress.org

Ready to get started?Download WordPress

Forums

Google-loaded jQuery doesn't work in wp-admin (3 posts)

  1. Jusi
    Member
    Posted 3 years ago #

    Hello, I'm using Google stored jQuery in my theme, calling it like this in my functions.php file:

    function bb_google_jquery() {
    	wp_deregister_script('jquery');
    	wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js', false, '1.4.4');
    	wp_enqueue_script('jquery');
    }
    
    if(!is_admin()){
    	add_action('init', 'bb_google_jquery');
    }

    The problem is, even if though wrapped in the conditional tag - it stops wp-admin jQuery stuff (sidebar menu dropdowns, dashboard dropdowns) from working. Removing the is_admin makes it work correctly.

    However, I need it to be wrapped into the conditional tag, because otherwise I can't move menu items around...

    Anything I'm doing wrong with this code?

    Thanks in advance

  2. caugb
    Member
    Posted 3 years ago #

    what is wrong with the embeded jQuery?

  3. Jusi
    Member
    Posted 3 years ago #

    I can't make it to work with custom scripts in my theme. I register my scripts in functions.php, like this:

    wp_register_script('selectivizr', get_bloginfo('template_directory').'/_assets/js/selectivizr.js', 'jquery');
    wp_enqueue_script('selectivizr');

    to have them included in wp_head. Then I use wp_enqueue_script("jquery"); in my header.php BEFORE the wp_head but the jQuery is STILL loaded after my scripts anyway.

    Registering Google-hosted version of jQuery forced it to load before my registered scripts to make them work properly. However it made the draggable menu items in Appearance/Menus to stop working. Removing the if(!is_admin()) condition fixes the menu problem, but the dashboard items don't slide down then (there is no jQuery on the page at all).

Topic Closed

This topic has been closed to new replies.

About this Topic