WordPress.org

Make WordPress Core

Ticket #7635: reply-to-comments-nojs.patch

File reply-to-comments-nojs.patch, 4.2 KB (added by Viper007Bond, 6 years ago)

Foolin' around with no-JS fallback for replying to comments, may not be ready for commit

  • wp-content/themes/default/comments.php

     
    4444 
    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;"> 
     49<div id="cancel-comment-reply" style="<?php cancel_comment_style(); ?>"> 
    5050        <small><?php echo cancel_comment_reply_link() ?></small> 
    5151</div> 
    5252 
     
    7979 
    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 parent_comment_id(); ?> 
    8383</p> 
    8484<?php do_action('comment_form', $post->ID); ?> 
    8585 
  • wp-includes/comment-template.php

     
    899899        $link = ''; 
    900900 
    901901        if ( get_option('comment_registration') && !$user_ID ) 
    902                 $link = '<a href="' . site_url('wp-login.php?redirect_to=' . get_permalink()) . '">' . $login_text . '</a>'; 
     902                $link = '<a rel="nofollow" href="' . site_url('wp-login.php?redirect_to=' . get_permalink()) . '">' . $login_text . '</a>'; 
    903903        else  
    904                 $link = "<a href='#' onclick='moveAddCommentForm(\"$add_below-$comment->comment_ID\", $comment->comment_ID, \"$respond_id\"); return false;'>$reply_text</a>"; 
     904                $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>"; 
    905905 
    906906        return $link; 
    907907} 
     
    918918function cancel_comment_reply_link($text = '', $respond_id = 'respond', $respond_root = 'content') { 
    919919        if ( empty($text) ) 
    920920                $text = __('Click here to cancel reply.'); 
    921         echo '<a href="#" onclick="cancelCommentReply(\'' . $respond_id . '\', \'' . $respond_root . '\'); return false;">' . $text . '</a>'; 
     921        echo '<a rel="nofollow" href="' . wp_specialchars( remove_query_arg('replytocom') ) . '#respond" onclick="cancelCommentReply(\'' . $respond_id . '\', \'' . $respond_root . '\'); return false;">' . $text . '</a>'; 
    922922} 
    923923 
    924924/** 
     925 * Output inline CSS for cancel comment reply link container. 
     926 * 
     927 * @since 2.7.0 
     928 */ 
     929function cancel_comment_style() { 
     930        if ( empty($_GET['replytocom']) ) 
     931                echo 'display:none;'; 
     932} 
     933 
     934/** 
     935 * Output hidden input HTML for replying to comments. 
     936 * 
     937 * @since 2.7.0 
     938 */ 
     939function parent_comment_id() { 
     940        $replytoid = (int) ( !empty($_GET['replytocom']) ) ? $_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 = (int) ( !empty($_GET['replytocom']) ) ? $_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        } 
     965} 
     966 
     967/** 
    925968 * HTML comment list class. 
    926969 * 
    927970 * @package WordPress 
     
    10371080 
    10381081                <?php echo apply_filters('comment_text', get_comment_text()) ?> 
    10391082 
    1040                 <div class="reply" style="display:none"> 
     1083                <div class="reply"> 
    10411084                <?php echo comment_reply_link(array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['depth'])) ?> 
    10421085                <?php if ( 'ul' == $args['style'] ) : ?> 
    10431086                </div>