WordPress.org

Ready to get started?Download WordPress

Forums

NextGEN Gallery
NextGen Forces the latest version of JQuery in all Pages (8 posts)

  1. Halex Productions
    Member
    Posted 1 year ago #

    NextGen Version 2.0.21

    NextGen is forcing the latest version of JQuery to all pages, I have some pages that require an older version and using wp_deregister_script won't remove the version that NextGen adds.

    Why is in all pages in the first place? NextGen JS/CSS should be only on the pages that needs them, is there a way to fix this?

    http://wordpress.org/plugins/nextgen-gallery/

  2. Ryan Burnette
    Member
    Posted 1 year ago #

    NGG is definitely being overly forceful about this.

    You can defeat them by using this method for loading jQuery in WordPress.
    http://css-tricks.com/snippets/wordpress/include-jquery-in-wordpress-theme/

    Just hook to "wp_print_scripts" instead of "wp_enqueue_scripts" and you'll defeat NGG. I also added a high priority parameter for future proofing.

    add_action('wp_print_scripts','my_function',999);

  3. newmediologo
    Member
    Posted 1 year ago #

    HI Ryan.. I've the same problem with a theme that use JQuery Backstretch to display the pages background.. If I disable NGG all works fine but if I activate It the backgrounds disapperars and is possible to have a background using the custom-background function of WordPress.. No problem for one site that have an unique background but for another site the clients wants differents background on every pages that the theme supports.. NGG is very useful because I just create the gallery and upload the images and all is ready and linked with Lightbox..

    There is an easy way to fix it..? I dont understand very well how to proceed with the above method..

    Thanks..

  4. Ryan Burnette
    Member
    Posted 1 year ago #

    @newmediologo

    The situation you describe has other factors, so I can't say whether this will help you or not, but if you want to load a specific version of jQuery, rather than the one NGG wants you to load, this code added to your functions.php file will give you that control. At least it will right now. NGG changes a lot so you you never know when they'll edit it and this won't work anymore.

    if (!is_admin()) add_action("wp_print_scripts", "my_jquery_enqueue", 999);
    function my_jquery_enqueue() {
       $jquery_version = "1.10.2"; // set the desired jquery version here
       wp_deregister_script('jquery');
       wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/" . $jquery_version . "/jquery.min.js", false, null);
       wp_enqueue_script('jquery');
    }
  5. Malivuk
    Member
    Posted 1 year ago #

    @Ryan Burnette

    Seriously dude, thank you SO MUCH. You have saved me so much time with your answer...

  6. Malivuk
    Member
    Posted 1 year ago #

    Hm sorry for posting again but it seems I've been quite optimistic.
    Basically, my load function looks like

    function core_mods() {
            if (!is_admin()) {
                wp_deregister_script('jquery');
                wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"));
                wp_register_script('jquery.masonry', (get_template_directory_uri() . "/js/jquery.masonry.min.js"), 'jquery', false, true);
                wp_register_script('gridly.functions', (get_template_directory_uri() . "/js/functions.js"), 'jquery.masonry', false, true);
    
                wp_enqueue_script('jquery');
                wp_enqueue_script('jquery.masonry');
                wp_enqueue_script('gridly.functions');
            }
    }

    That I changed into :

    function core_mods() {
            if (!is_admin()) add_action("wp_print_scripts", "my_jquery_enqueue", 999);
            function my_jquery_enqueue() {
                $jquery_version = "1.7.1";
    
                wp_deregister_script('jquery');
                wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/" . $jquery_version . "/jquery.min.js", false, null);
    
                wp_register_script('jquery.masonry', (get_template_directory_uri() . "/js/jquery.masonry.min.js"), 'jquery', false, true);
                wp_register_script('gridly.functions', (get_template_directory_uri() . "/js/functions.js"), 'jquery.masonry', false, true);
    
                wp_enqueue_script('jquery');
                wp_enqueue_script('jquery.masonry');
                wp_enqueue_script('gridly.functions');
            }
    }
    
    core_mods();

    I need all these scripts to sort posts by day. But it doesn't work for last posts on each page.

    Is there any other tip to avoid NGG to load on my index ?...

  7. Ryan Burnette
    Member
    Posted 1 year ago #

    You could give my plugin NextGEN Query a try. It adds a "Query" menu to NGG with a "Sterilize Header" option to remove NGG's additions to the header.

    At the moment version 2.0.0 misses one script, but I'm going to fix that at some point.

    It might take care of your issue.

    http://wordpress.org/plugins/nextgen-query/

  8. Malivuk
    Member
    Posted 1 year ago #

    Thanks again but it still messes up my homepage :(
    Anyway, I chosed another plugin.

    Thanks :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.