WordPress.org

Make WordPress Core

Ticket #7635: 7635.diff

File 7635.diff, 8.7 KB (added by ryan, 10 years ago)
  • wp-includes/js/comment-reply.js

     
     1function moveAddCommentForm(theId, threadId) {
     2        var addComment = document.getElementById("respond");
     3        var comment = document.getElementById(theId);
     4        addComment.parentNode.removeChild(addComment);
     5
     6        comment.appendChild(addComment);
     7//      if(comment.className.indexOf("alt")>-1) {
     8//              addComment.className = addComment.className.replace(" alt", "");                                       
     9//      } else {
     10//              addComment.className += " alt";
     11//      }
     12        var replyId = document.getElementById("comment-parent");
     13        replyId.value = threadId;
     14        var reRootElement = document.getElementById("cancel-comment-reply");
     15        reRootElement.style.display = "block";
     16        var aTags = comment.getElementsByTagName("A");
     17        var anc = aTags.item(0).id;
     18        //document.location.href = "#"+anc;
     19        document.getElementById("comment").focus();
     20}
     21
     22function cancelCommentReply() {
     23        var addComment = document.getElementById("respond");                   
     24        var reRootElement = document.getElementById("cancel-comment-reply");
     25        reRootElement.style.display = "none";
     26        var content = document.getElementById("content-main");
     27        if( !content )
     28                content = document.getElementById("content");
     29        if( content ) {
     30                addComment.parentNode.removeChild(addComment);
     31                content.appendChild(addComment);
     32        }
     33//      addComment.className = addComment.className.replace(" alt", "");
     34        document.location.href = "#respond";
     35        document.getElementById("comment").focus();                             
     36        document.getElementById("comment-parent").value = "0";
     37}
     38 No newline at end of file
  • wp-includes/comment-template.php

     
    837837        echo '</a>';
    838838}
    839839
     840function comment_reply_link($comment = null, $post = null, $add_below = 'comment') {
     841        global $user_ID;
     842
     843        $comment = get_comment($comment);
     844        $post = get_post($post);
     845
     846        if ( 'open' != $post->comment_status )
     847                return;
     848
     849        $link = '';
     850
     851        if ( get_option('comment_registration') && !$user_ID )
     852                $link = '<a href="' . site_url('wp-login.php?redirect_to=' . get_permalink()) . '">' . __('Log in to Reply') . '</a>';
     853        else
     854                $link = "<a href='#' onclick='moveAddCommentForm(\"$add_below-$comment->comment_ID\", $comment->comment_ID); return false;'>" . __('Reply to this comment') . '</a>';
     855
     856        return $link;
     857}
     858
     859class Walker_Comment extends Walker {
     860        var $tree_type = 'comment';
     861        var $db_fields = array ('parent' => 'comment_parent', 'id' => 'comment_ID');
     862
     863        function start_lvl(&$output, $depth, $args) {
     864                $indent = str_repeat("\t", $depth);
     865                $output .= "$indent<ul class='children'>\n";
     866        }
     867
     868        function end_lvl(&$output, $depth, $args) {
     869                $indent = str_repeat("\t", $depth);
     870                $output .= "$indent</ul>\n";
     871        }
     872
     873        function start_el(&$output, $comment, $depth, $args) {
     874                $GLOBALS['comment'] = $comment;
     875                extract($args);
     876
     877                $output .= "<li " . get_comment_class() . " id=\"comment-" . get_comment_ID() . '">' . "\n";
     878                $output .= '<div class="comment-author vcard">' . "\n";
     879                $output .= get_avatar( $comment, 32 ) . "\n";
     880                $output .= sprintf(__('<cite>%s</cite> Says:'), get_comment_author_link()) . "\n";
     881                $output .= '</div>' . "\n";
     882
     883                if ($comment->comment_approved == '0')
     884                        $output .= '<em>'  . __('Your comment is awaiting moderation.') . '</em>' . "\n";
     885                $output .= '<br />' . "\n";
     886
     887                $output .= '<div class="comment-meta commentmetadata"><a href="#comment-' . get_comment_ID() . '" title="">' . sprintf(__('%1$s at %2$s'), get_comment_date('F jS, Y'),  get_comment_time()) . '</a>' . edit_comment_link('edit','&nbsp;&nbsp;','', false) . '</div>' . "\n";
     888
     889                $output .= apply_filters('comment_text', get_comment_text());
     890
     891                $output .= "<div class='reply'>";
     892                $output .= comment_reply_link();
     893                $output .= '</div>';
     894        }
     895
     896        function end_el(&$output, $comment, $depth, $args) {
     897                $output .= "</li>\n";
     898        }
     899
     900}
     901
     902function wp_list_comments(&$comments, $args = array() ) {
     903        $defaults = array('walker' => '', 'depth' => 3, 'echo' => true);
     904
     905        $r = wp_parse_args( $args, $defaults );
     906
     907        extract( $r );
     908
     909        if ( empty($walker) )
     910                $walker = new Walker_Comment;
     911
     912        $output = '';
     913        $output .= $walker->walk($comments, $depth, $r);
     914
     915        if ( $echo )
     916                echo $output;
     917        else
     918                return $output;
     919}
     920
    840921?>
     922 No newline at end of file
  • wp-includes/link-template.php

     
    531531        return apply_filters( 'get_edit_comment_link', $location );
    532532}
    533533
    534 function edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) {
     534function edit_comment_link( $link = 'Edit This', $before = '', $after = '', $echo = true ) {
    535535        global $comment, $post;
    536536
    537537        if ( $post->post_type == 'attachment' ) {
     
    544544        }
    545545
    546546        $link = '<a href="' . get_edit_comment_link( $comment->comment_ID ) . '" title="' . __( 'Edit comment' ) . '">' . $link . '</a>';
    547         echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
     547        $link = $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
     548        if ( $echo )
     549                echo $link;
     550        else
     551                return $link;
    548552}
    549553
    550554function get_edit_bookmark_link( $link = 0 ) {
  • wp-includes/script-loader.php

     
    107107        $scripts->add( 'jquery-ui-resizable', '/wp-includes/js/jquery/ui.resizable.js', array('jquery-ui-core'), '1.5.2' );
    108108        $scripts->add( 'jquery-ui-dialog', '/wp-includes/js/jquery/ui.dialog.js', array('jquery-ui-resizable', 'jquery-ui-draggable'), '1.5.2' );
    109109
     110        $scripts->add( 'comment-reply', '/wp-includes/js/comment-reply.js', false, '20080828');
     111
    110112        if ( is_admin() ) {
    111113                $scripts->add( 'ajaxcat', '/wp-admin/js/cat.js', array( 'wp-lists' ), '20071101' );
    112114                $scripts->localize( 'ajaxcat', 'catL10n', array(
  • wp-content/themes/default/comments.php

     
    2323        <h3 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> to &#8220;<?php the_title(); ?>&#8221;</h3>
    2424
    2525        <ol class="commentlist">
    26 
    27         <?php foreach ($comments as $comment) : ?>
    28 
    29                 <li <?php comment_class($oddcomment) ?> id="comment-<?php comment_ID() ?>">
    30                         <?php echo get_avatar( $comment, 32 ); ?>
    31                         <cite><?php comment_author_link() ?></cite> Says:
    32                         <?php if ($comment->comment_approved == '0') : ?>
    33                         <em>Your comment is awaiting moderation.</em>
    34                         <?php endif; ?>
    35                         <br />
    36 
    37                         <small class="commentmetadata"><a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('F jS, Y') ?> at <?php comment_time() ?></a> <?php edit_comment_link('edit','&nbsp;&nbsp;',''); ?></small>
    38 
    39                         <?php comment_text() ?>
    40 
    41                 </li>
    42 
    43         <?php
    44                 /* Changes every other comment to a different class */
    45                 $oddcomment = ( empty( $oddcomment ) ) ? 'alt' : '';
    46         ?>
    47 
    48         <?php endforeach; /* end for each comment */ ?>
    49 
     26        <?php wp_list_comments($comments); ?>
    5027        </ol>
    5128
    5229 <?php else : // this is displayed if there are no comments so far ?>
     
    6441
    6542<?php if ('open' == $post->comment_status) : ?>
    6643
    67 <h3 id="respond">Leave a Reply</h3>
     44<div id="respond">
    6845
     46<div id="cancel-comment-reply" style="display: none;">
     47        <small><a href="#" onclick="cancelCommentReply(); return false;"><?php _e('Click here to cancel "reply".') ?></a></small>
     48</div>
     49<h3>Leave a Reply</h3>
     50
    6951<?php if ( get_option('comment_registration') && !$user_ID ) : ?>
    7052<p>You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>">logged in</a> to post a comment.</p>
    7153<?php else : ?>
     
    9577
    9678<p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
    9779<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
     80<input type="hidden" name="comment_parent" id="comment-parent" value="0" />
    9881</p>
    9982<?php do_action('comment_form', $post->ID); ?>
    10083
    10184</form>
     85</div>
    10286
    10387<?php endif; // If registration required and not logged in ?>
    10488
  • wp-content/themes/default/header.php

     
    2424
    2525</style>
    2626
     27<?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
     28
    2729<?php wp_head(); ?>
    2830</head>
    2931<body>