Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've tried searching for the problem here and also went through the trouble deactivating one plugin after the other. I still can't figure out what's going on, so maybe somebody here has an idea?

Suddenly I get a Javascript error: enter image description here

It's caused by Jetpack's Hovercards. I suppose that in a recent Jetpack update they changed something in their Javascript code that is now causing the issue.

The error only occurs on single.php, so I suppose it's a conflict with another script. At first I thought it could be Adsense, but I have Adsense code in my sidebar as well and there the hovercards are working fine (unless I have the single.php open).

The only other script in there are things I haven't updated in a long time. Sharing buttons scripts:

<script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>
  <ul class="social_buttons">
 <li><a href="http://twitter.com/share" class="twitter-share-button"
      data-url="<?php the_permalink(); ?>"
      data-via="zoomingjapan"
      data-text="<?php the_title(); ?>"
      data-related="zoomingjapan: Admin of Zooming Japan"
      data-count="horizontal"
data-lang="en">Tweet</a></li>
<li> <g:plusone size="medium" callback="plusone_vote"></g:plusone></li>
<li style="margin-left:-10px;">
<a href="http://www.facebook.com/sharer.php?u=<?php the_permalink(); ?>&t=<?php the_title(); ?>" target="blank"><img src="<?php bloginfo('template_directory'); ?>/images/facebook-share.jpg" alt="Share this article on Facebook" /></a></li> 
<li style="margin-left:-10px;"><div class="fb-like" id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="<?php echo get_permalink(); ?>" show_faces="false" layout="button_count"></fb:like></li>

And here from my function.php:

function add_my_javascripts() {
    /* If this is the admin area of WordPress, don't do anything */
    if( is_admin() )
        return;

    /* Register all of our scripts */

    wp_register_script('jquerytools', 'http://zoomingjapan.com/wp-content/themes/alltuts/js/jquery.tools.min.js', array('jquery'));
    wp_register_script('tab-renamer', get_template_directory_uri() . '/js/tab-renamer.js', array('jquerytools'));
    wp_register_script('jquery-ui-perso', get_template_directory_uri() . '/js/jquery-ui-personalized-1.5.2.packed.js', array('jquery', 'tab-renamer'));
    wp_register_script('jquery.form', get_template_directory_uri() . '/js/jquery.form.js', array('jquery'));
    wp_register_script('jquery-slides', get_template_directory_uri() . '/js/slides.min.jquery.js', array('jquery'));
    wp_register_script('my-slider', get_template_directory_uri() . '/js/my-slider.js', array('jquery', 'jquery-slides'));
    wp_register_script('tooltip', get_template_directory_uri() . '/js/tooltip.js', array('jquerytools'));
    wp_register_script('scrollable', get_template_directory_uri() . '/js/scrollable.js', array('jquerytools'));
    wp_register_script('sliding_tabs', get_template_directory_uri() . '/js/sliding_tabs.js', array('jquerytools'));
    wp_register_script('sprinkle', get_template_directory_uri() . '/js/sprinkle.js', array('jquery', 'jquery-ui-perso'));
    wp_register_script('custom', get_template_directory_uri() . '/js/custom.js', array('jquery'));
    wp_register_script('contact-form', get_template_directory_uri() . '/js/contact-form.js', array('jquery', 'jquery.form'));
    wp_register_script('welcome_back', get_template_directory_uri() . '/js/welcome_back.js', array('jquery'));


    /* Enqueue the ones that need to be enqueued */
    wp_enqueue_script('my-slider');
    wp_enqueue_script('tooltip');
    wp_enqueue_script('scrollable');
    wp_enqueue_script('sliding_tabs');
    wp_enqueue_script('tab-renamer');
    wp_enqueue_script('sprinkle');
    wp_enqueue_script('custom');
    wp_enqueue_script('contact-form');
    wp_enqueue_script('welcome_back');




}
add_action('wp_enqueue_scripts', 'add_my_javascripts');

I finally found the culprit! It's one of my plugins! I need this plugin, so I won't toss it. Could you help me how to fix this problem?

//Подключаем jQuery
function jcp_jquery() {
    if ( comments_open() && ( is_single() || is_page() ) ) {
        wp_deregister_script('jquery');
        wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"), false, '1.6.3');
        wp_enqueue_script('jquery');
    }
}
add_action('wp_head', 'jcp_jquery', 8);

The plugin is loading an old jquery version from an external source. I don't have the jquery.min.js in my function.php yet, so how can I replace the code above?

Do you have any idea what could be causing the problem? Here's my blog for reference.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You are loading jQuery 1.6.3. .on was included in jQuery 1.7 (I believe). jQuery itself is up to 1.9. You need to be using a more recent version of that library-- basically, just let WordPress load its own version and you should be fine. It looks like most of your scripts are loading from your domain except that one, which you are loading from Google's libraries. You aren't gaining much if anything by doing that and more and more scripts will break if you continue to use that old jQuery. If you want to load to form Google's libraries you need to pay attention and keep up to date, or use one of the several plugins that keep track for you.

Edit:

Change that callback function to match this:

function jcp_jquery() {
    if ( comments_open() && ( is_single() || is_page() ) ) {
        // wp_deregister_script('jquery');
        // wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"), false, '1.6.3');
        wp_enqueue_script('jquery');
    }
}

If the plugin still works you are done. If the plugin does not work then it is probably dependent upon that old version of jQuery and will have to be rewritten to be compatible with the newer jQuery.

share|improve this answer
    
I just checked (see my updated question) and I thought I'm using the Wordpress library already? I couldn't find a link to Google's library. –  japanworm Mar 3 '13 at 15:43
    
I can't tell you what is actually loading that library but if you check the source of the generated page it is loading jQuery 1.6.3. Check you plugins. One of them could be doing it. –  s_ha_dum Mar 3 '13 at 18:43
    
I just spent HOURS trying to find which file or plugin might be loading it, but I just couldn't find it. :( –  japanworm Mar 4 '13 at 5:16
    
I finally found the culprit (see my updated question). I'm just not sure how to fix the link to the external outdated jquery library without breaking anything. Could you write an answer and tell me what to do, please? –  japanworm Mar 5 '13 at 15:40
    
Actually, what I did was just to remove the whole snippet I posted in my question. I removed it and everything still seems to work fine. Thank you. –  japanworm Mar 6 '13 at 4:07
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.