Make WordPress Core


Ignore:
Timestamp:
10/09/2008 07:37:05 AM (17 years 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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'] ) : ?>
Note: See TracChangeset for help on using the changeset viewer.