Changeset 9112

Show
Ignore:
Timestamp:
10/09/08 07:37:05 (2 months ago)
Author:
azaozz
Message:

No-JS mode for replying to comments and some improvements/cleanup of comment-reply.js, includes patch by Viper007Bond, see #7635

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-content/themes/default/comments.php

    r9025 r9112  
    4545<div id="respond"> 
    4646 
    47 <h3>Leave a Reply</h3> 
     47<h3><?php comment_form_title( 'Leave a Reply', 'Leave a Reply to %s' ); ?></h3> 
    4848 
    49 <div id="cancel-comment-reply" style="display: none;"> 
    50     <small><?php echo cancel_comment_reply_link() ?></small> 
     49<div class="cancel-comment-reply"> 
     50    <small><?php cancel_comment_reply_link(); ?></small> 
    5151</div> 
    5252 
     
    8080<p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" /> 
    8181<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" /> 
    82 <input type="hidden" name="comment_parent" id="comment-parent" value="0" /
     82<?php comment_parent_field(); ?
    8383</p> 
    8484<?php do_action('comment_form', $post->ID); ?> 
  • trunk/wp-includes/comment-template.php

    r9093 r9112  
    909909 
    910910    if ( get_option('comment_registration') && !$user_ID ) 
    911         $link = '<a href="' . site_url('wp-login.php?redirect_to=' . get_permalink()) . '">' . $login_text . '</a>'; 
     911        $link = '<a rel="nofollow" href="' . site_url('wp-login.php?redirect_to=' . get_permalink()) . '">' . $login_text . '</a>'; 
    912912    else  
    913         $link = "<a href='#' onclick='moveAddCommentForm(\"$add_below-$comment->comment_ID\", $comment->comment_ID, \"$respond_id\"); return false;'>$reply_text</a>"; 
     913        $link = "<a rel='nofollow' href='" . wp_specialchars( add_query_arg( 'replytocom', $comment->comment_ID ) ) . "#respond' onclick='moveAddCommentForm(\"$add_below-$comment->comment_ID\", $comment->comment_ID, \"$respond_id\"); return false;'>$reply_text</a>"; 
    914914 
    915915    return $before . $link . $after; 
     
    921921 * @since 2.7.0 
    922922 * 
    923  * @param string $text Optional. Text to display for cancel reply. 
    924  * @param string $respond_id Optional. HTML ID attribute for JS cancelCommentReply function. 
    925  * @param string $respond_root Optional. Second parameter for JS cancelCommentReply function. 
    926  */ 
    927 function cancel_comment_reply_link($text = '', $respond_id = 'respond', $respond_root = 'content') { 
     923 * @param string $text Optional. Text to display for cancel reply link. 
     924 */ 
     925function cancel_comment_reply_link($text = '') { 
    928926    if ( empty($text) ) 
    929927        $text = __('Click here to cancel reply.'); 
    930     echo '<a href="#" onclick="cancelCommentReply(\'' . $respond_id . '\', \'' . $respond_root . '\'); return false;">' . $text . '</a>'; 
     928     
     929    $style = isset($_GET['replytocom']) ? '' : ' style="display:none;"'; 
     930 
     931    echo '<a rel="nofollow" id="cancel-comment-reply-link" href="' . wp_specialchars( remove_query_arg('replytocom') ) . '#respond"' . $style . '>' . $text . '</a>'; 
     932
     933 
     934/** 
     935 * Output hidden input HTML for replying to comments. 
     936 * 
     937 * @since 2.7.0 
     938 */ 
     939function comment_parent_field() { 
     940    $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0; 
     941    echo "<input type='hidden' name='comment_parent' id='comment-parent' value='$replytoid' />\n"; 
     942
     943 
     944/** 
     945 * Display text based on comment reply status. Only affects users with Javascript disabled. 
     946 * 
     947 * @since 2.7.0 
     948 * 
     949 * @param string $noreplytext Optional. Text to display when not replying to a comment. 
     950 * @param string $replytext Optional. Text to display when replying to a comment. Accepts "%s" for the author of the comment being replied to. 
     951 * @param string $linktoparent Optional. Boolean to control making the author's name a link to their comment. 
     952 */ 
     953function comment_form_title( $noreplytext = 'Leave a Reply', $replytext = 'Leave a Reply to %s', $linktoparent = TRUE ) { 
     954    global $comment; 
     955 
     956    $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0; 
     957 
     958    if ( 0 == $replytoid ) 
     959        echo $noreplytext; 
     960    else { 
     961        $comment = get_comment($replytoid); 
     962        $author = ( $linktoparent ) ? '<a href="#comment-' . get_comment_ID() . '">' . get_comment_author() . '</a>' : get_comment_author(); 
     963        printf( $replytext, $author ); 
     964    } 
    931965} 
    932966 
     
    10471081        <?php echo apply_filters('comment_text', get_comment_text()) ?> 
    10481082 
    1049         <div class="reply" style="display:none"
     1083        <div class="reply"
    10501084        <?php echo comment_reply_link(array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['depth'])) ?> 
    10511085        <?php if ( 'ul' == $args['style'] ) : ?> 
  • trunk/wp-includes/js/comment-reply.js

    r9082 r9112  
    1 function moveAddCommentForm(theId,threadId,respondId){ 
    2     jQuery("#"+respondId).appendTo("#"+theId); 
    3     jQuery("#comment-parent").val(threadId); 
    4     jQuery("#cancel-comment-reply").show(); 
     1 
     2function moveAddCommentForm(commId, parentId, respondId) { 
     3    var div = document.createElement('div'); 
     4    jQuery("#"+respondId).before( jQuery(div).attr('id', 'wp-temp-form-div').hide() ).appendTo("#"+commId); 
     5    jQuery("#comment-parent").val(parentId); 
     6    jQuery("#cancel-comment-reply-link").show().click(function(){ 
     7        jQuery("#comment-parent").val("0"); 
     8        jQuery('#wp-temp-form-div').after( jQuery("#"+respondId) ).remove(); 
     9        jQuery(this).hide(); 
     10        return false; 
     11    }); 
    512    jQuery("#comment").focus(); 
    613} 
    7 function cancelCommentReply(respondId,respondRoot){ 
    8     jQuery("#cancel-comment-reply").hide(); 
    9     jQuery("#"+respondId).appendTo("#"+respondRoot); 
    10     document.location.href="#respond"; 
    11     jQuery("#comment").focus(); 
    12     jQuery("#comment-parent").val("0"); 
    13 } 
    14 jQuery(document).ready(function($){ 
    15     $(".thread-odd").find("div.reply").show(); 
    16     $(".thread-even").find("div.reply").show(); 
    17 }); 
  • trunk/wp-includes/script-loader.php

    r9103 r9112  
    140140    $scripts->add( 'jquery-ui-dialog', '/wp-includes/js/jquery/ui.dialog.js', array('jquery-ui-resizable', 'jquery-ui-draggable'), '1.5.2' ); 
    141141 
    142     $scripts->add( 'comment-reply', '/wp-includes/js/comment-reply.js', array('jquery'), '20080929'); 
     142    $scripts->add( 'comment-reply', '/wp-includes/js/comment-reply.js', array('jquery'), '20081009'); 
    143143 
    144144    if ( is_admin() ) {