ThemeShaper Forums » Thematic

[closed]

JQuery compatibility

(15 posts)
  • Started 5 years ago by Anthrax
  • Latest reply from 72quadrat
  • This topic is resolved

Tags:

  1. I'm totally confused about jquery and how it is to use in different versions?

    Wordpress insert:
    <script type='text/javascript' src='http://localhost/wordpress/wp-includes/js/jquery/jquery.js?ver=1.2.6'></script> in the head.

    I actually need the Version 1.3.2 of Jquery. If i link it to a separate jqery132.js in my plugin folder all works fine.

    But if i replace the jqery.js in the wp-includes\js\jquery with the new Version it doesn't work?

    What is the best way to use a newer Version of JQuery without touching the original jquery.js in Wordpress?

    Posted 5 years ago #
  2. Hey Bjoern,

    have you seen this article: Make your Wordpress plugins use a different version of a bundled JavaScript library?

    Let me know if this works, haven't tested it.

    Cheers,

    Chris

    Posted 5 years ago #
  3. in tons of articles i read i didn't see this one ...but a lot of similar to this.

    This doesn't work:

    function simplyread_head() {
    wp_deregister_script('jquery');
    wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js', false, '1.3.2');
    wp_enqueue_script('jquery');
    
    //echo '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script>';
    };
    add_action('wp_head','simplyread_head',1);

    but if i insert the 'echo' it works fine.

    #there is no Thematic-Hook that works with it. I try 'thematic_before', 'thematic_aboveheader' and 'thematic_header'.

    Posted 5 years ago #
  4. Just put these line into your functions.php ..

    wp_deregister_script('jquery');
    wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"), false, '1.3.2');
    wp_enqueue_script('jquery');

    .. no need to put it into a function.

    1st line will de-register the standard jQuery coming with WP.
    2nd line will register jQuery 1.3.2 with WP
    3rd line will enqueue jQuery into a loader script that will hook the script call into wp_head.

    Cheers,

    Chris

    Posted 5 years ago #
  5. Good Morning Chris,

    thanks for the hint that they don't need a extra function.
    I tryied to copy your code in the functions.php without function but only the

    `//echo '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script>';
    };`

    works ...

    Posted 5 years ago #
  6. Hey Bjoern,

    this is something you could try:

    function swap_jquery() {
    	wp_deregister_script('jquery');
    	wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"), false, '1.3.2');
    	wp_enqueue_script('jquery');
    }
    add_action('init', 'swap_jquery');

    Unfortunately both code snippets are running here without any problem, so it's pretty hard for me to find out what's happening on your system.
    The last code snippet might be better because it's using a more official way to trigger the function at the right time.

    Cheers,

    Chris

    Posted 5 years ago #
  7. Google, nice JS libraries, and a free CDN: that’s a combination to fall in love with. :-D

    And also an easy way to serve gzipped javascript if you are on shared hosting (since gzippig is rare in shared-hosting environments).

    BTW, in the Google API you don’t have to specify the full version if you don’t need to. E.g., you can write:

    wp_register_script('jquery','http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js')

    and google will serve the latest version available at the specified version level, that is, currently, 1.3.2.

    In the same way, you can specify just 1.2, and Google will serve 1.2.6 or whatever is the latest full version currently.

    Posted 5 years ago #
  8. @demetris... thanks for the hint but the Problem is:

    Dont work:

    function swap_jquery() {
    
    wp_deregister_script('jquery');
    
    wp_register_script('jquery','http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js');
    wp_enqueue_script('jquery');
    wp_register_script('scrolltop', get_bloginfo('stylesheet_directory') . '/js/jquery.scroll.pack.js', array('jquery'),'');
    wp_enqueue_script('scrolltop');
    
    }
    add_action('init', 'swap_jquery');

    Work:

    function child_head() { ?>
    
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    <script type="text/javascript" src="<?php bloginfo('stylesheet_directory');?>/js/jquery.scroll.pack.js"></script>
    
    <?php
    }
    add_action('wp_head', 'child_head',1);   //THIS WORK !!!!!!!!!!!

    Posted 5 years ago #
  9. @ Anthrax: Sorry, Anthrax, I have no idea why this happens. But I use code exactly like this (deregister and then register) with Sandbox for the plugin WP Slimbox 2, and it seems to work fine.

    Posted 5 years ago #
  10. Hey Bjoern,

    now I got it. The problem is caused by the differences between WP 2.71 and WP 2.8.

    In WP 2.71 the function wp_register_script will register the script and drop it into wp_head without any priority. That's why your function child_head is working (using priority 1).

    In WP 2.8 the function wp_register_script will only register the script. You still need the function wp_enqueue_script as a loader. And this loader uses priority 1 to put it into the first place of wp_head.

    And the missing function wp_enqueue_script (WP 2.71) doesn't create any error.

    Cheers,

    Chris

    Posted 5 years ago #
  11. Hey Chris, let me understand well:

    function swap_jquery() {
    	wp_deregister_script('jquery');
    	wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"), false, '1.3.2');
    	wp_enqueue_script('jquery');
    }
    add_action('init', 'swap_jquery');

    does will work in 2.8 too? am I wrong?

    Posted 5 years ago #
  12. Hey Danny,

    yes .. this code will run with WordPress >= 2.8

    Cheers,

    Chris

    Posted 5 years ago #
  13. hylopu
    Member

    Hi Guys - just an FYI for anyone finding this thread - I had a problem with posting content after I upgraded to WP 2.8 using the swap_jquery() function posted in this thread.

    Any content typed into the text area would disappear on saving, and I could no longer switch between the html and visual tabs (stuck in place). There may have been some other admin UI problems elsewhere, but those were the obvious ones.

    Once I removed swap_jquery() from my child theme's functions.php, normal functionality returned. Is WP 2.8 reliant on a different version of jquery or something?

    Posted 5 years ago #
  14. Take a look here: WordPress 2.8

    Posted 5 years ago #
  15. O.K. I've a smilar Problem. Now i have a working Function in my functions.php. But it just works on FF, Safari and such but not on IE7 and IE6. I think it's because of the doubled jQuery.?!?

    function simplyread_head() {
    wp_deregister_script('jquery');
    wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js', false, '1.3.2');
    //wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js');
    //wp_register_script('jquery', '/wp-content/themes/hoenerdruck_v3/js/jquery.easing.1.3.js');
    //wp_register_script('jquery', '/wp-content/themes/hoenerdruck_v3/js/jquery.coda-slider-2.0.js');
    wp_enqueue_script('jquery');
    $content .= "\t";
    $content .= '<script type="text/javascript" src="/wp-content/themes/hoenerdruck_v3/js/jquery-1.3.2.min.js"></script>';
    $content .= "\n\t";
    $content .= '<script type="text/javascript" src="/wp-content/themes/hoenerdruck_v3/js/jquery.easing.1.3.js"></script>';
    $content .= "\n\t";
    $content .= '<script type="text/javascript" src="/wp-content/themes/hoenerdruck_v3/js/jquery.coda-slider-2.0.js"></script>';

    $content .= "\n\t";
    $content .= '<script type="text/javascript">';
    $content .= "\n\t\t";
    $content .= '$().ready(function() {';
    $content .= "\n\t\t";
    $content .= '$(\'#coda-slider-1\').codaSlider({';
    $content .= "\n\t\t";
    $content .= 'dynamicArrows: false,';
    $content .= "\n\t\t";
    $content .= 'autoHeightEaseDuration: 500,';
    $content .= "\n\t\t";
    $content .= 'slideEaseDuration: 800,';
    $content .= "\n\t\t";
    $content .= '});';
    $content .= "\n\t\t";
    $content .= '});';
    $content .= "\n\t";
    $content .= '</script>';

    echo $content;
    };
    add_action('wp_head','simplyread_head',1);

    Posted 4 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.