Support » Everything else WordPress » quick question about ‘/wp-includes/js/comment-reply.js?ver=20090102’

  • hi there, i am pretty new to WP but loving it so far.

    One thing i cant find an answer for is this line of code which gets inserted on every page (other than the homne/posts page)

    <script type=’text/javascript’ src=’http://www.siteurl.com/wp-includes/js/comment-reply.js?ver=20090102′></script&gt;

    Can anyone shed any light as to what it is and why it appears on all but the homepage? at first i was paranoid it was something malicious but it appears on my localhost copy too.

    Any help would be fantastic as im trying to clean up the head area as much as possible

    Cheers in advance

    james

Viewing 3 replies - 1 through 3 (of 3 total)
  • I think it’s added by <?php wp_enqueue_script( 'comment-reply' );?> and is needed for the threaded comment replay functionality. If you want to keep it on single post pages only, try using:
    <?php if(is_singular()) wp_enqueue_script( 'comment-reply' );?>

    Thread Starter jamesre

    (@jamesre)

    Cool, thanks esmi, will give that a try… the main thing is i know its not something i have done in error or something malicious

    Thanks again Esmi

    J

    See also:
    Including WordPress’s comment-reply.js (the right way)

    Since threaded comments were enabled in WordPress 2.7, most themes include the following line in header.php

    <?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
    This code checks if the visitor is browsing either a page or a post and adds the JavaScript required for threaded comments if they are.

    I prefer a slight variation

    <?php
    if ( is_singular() AND comments_open() AND (get_option('thread_comments') == 1))
      wp_enqueue_script( 'comment-reply' );
    ?>

    My variation checks if the visitor is browsing either a page or a post, if comments are open for the entry, and finally, if threaded comments are enabled. If all of these conditions are met, the JavaScript required for threaded comments is added.

    If you run your wp_enqueue_script calls in functions.php, as I do, this is the code to use:

    <?php
    function theme_queue_js(){
      if (!is_admin()){
        if ( is_singular() AND comments_open() AND (get_option('thread_comments') == 1))
          wp_enqueue_script( 'comment-reply' );
      }
    }
    add_action('get_header', 'theme_queue_js');
    ?>

    The call is added to the get_header action as is_singular and comments_open are unknown during the init action.


    TeMc

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘quick question about ‘/wp-includes/js/comment-reply.js?ver=20090102’’ is closed to new replies.