Ticket #7635: 7635.3.diff

File 7635.3.diff, 10.3 KB (added by ryan, 5 years ago)

Refresh for current trunk

  • 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

     
    227227 * @param int $comment_id An optional comment ID 
    228228 * @param int $post_id An optional post ID 
    229229 */ 
    230 function comment_class( $class = '', $comment_id = null, $post_id = null ) { 
    231         // Separates classes with a single space, collates classes for post DIV 
    232         echo 'class="' . join( ' ', get_comment_class( $class, $comment_id, $post_id ) ) . '"'; 
     230function comment_class( $class = '', $comment_id = null, $post_id = null, $echo = true ) { 
     231        // Separates classes with a single space, collates classes for comment DIV 
     232        $class = 'class="' . join( ' ', get_comment_class( $class, $comment_id, $post_id ) ) . '"'; 
     233        if ( $echo) 
     234                echo $class; 
     235        else 
     236                return $class; 
    233237} 
    234238 
    235239/** 
     
    266270        if ( empty($comment_alt) ) 
    267271                $comment_alt = 0; 
    268272 
    269         if ( $comment_alt % 2 ) 
     273        if ( $comment_alt % 2 ) { 
    270274                $classes[] = 'odd'; 
    271         else 
     275                $classes[] = 'alt'; 
     276        } else { 
    272277                $classes[] = 'even'; 
     278        } 
    273279 
    274280        $comment_alt++; 
    275281 
     
    835841        echo '</a>'; 
    836842} 
    837843 
     844function comment_reply_link($args = array(), $comment = null, $post = null) { 
     845        global $user_ID; 
     846 
     847        $defaults = array('add_below' => 'comment', 'reply_text' => __('Reply'), 
     848                'login_text' => __('Log in to Reply')); 
     849 
     850        $args = wp_parse_args($args, $defaults); 
     851 
     852        extract($args, EXTR_SKIP); 
     853 
     854        $comment = get_comment($comment); 
     855        $post = get_post($post); 
     856 
     857        if ( 'open' != $post->comment_status ) 
     858                return false; 
     859 
     860        $link = ''; 
     861 
     862        if ( get_option('comment_registration') && !$user_ID ) 
     863                $link = '<a href="' . site_url('wp-login.php?redirect_to=' . get_permalink()) . '">' . $login_text . '</a>'; 
     864        else  
     865                $link = "<a href='#' onclick='moveAddCommentForm(\"$add_below-$comment->comment_ID\", $comment->comment_ID); return false;'>$reply_text</a>"; 
     866 
     867        return $link; 
     868} 
     869 
     870function cancel_comment_reply_link($text = '') { 
     871        if ( empty($text) ) 
     872                $text = __('Click here to cancel reply.'); 
     873        echo '<a href="#" onclick="cancelCommentReply(); return false;">' . $text . '</a>'; 
     874} 
     875 
     876class Walker_Comment extends Walker { 
     877        var $tree_type = 'comment'; 
     878        var $db_fields = array ('parent' => 'comment_parent', 'id' => 'comment_ID'); 
     879 
     880        function start_lvl(&$output, $depth, $args) { 
     881                if ( 'div' == $args['style'] ) 
     882                        return; 
     883 
     884                echo "<ul class='children'>\n"; 
     885        } 
     886 
     887        function end_lvl(&$output, $depth, $args) { 
     888                if ( 'div' == $args['style'] ) 
     889                        return; 
     890 
     891                echo "</ul>\n"; 
     892        } 
     893 
     894        function start_el(&$output, $comment, $depth, $args) { 
     895                $depth++; 
     896 
     897                if ( !empty($args['callback']) ) { 
     898                        call_user_func($args['callback'], $comment, $args, $depth); 
     899                        return; 
     900                } 
     901 
     902                $GLOBALS['comment'] = $comment; 
     903                extract($args, EXTR_SKIP); 
     904 
     905                if ( 'div' == $args['style'] ) 
     906                        $tag = 'div'; 
     907                else 
     908                        $tag = 'li'; 
     909?> 
     910                <<?php echo $tag ?> "<?php comment_class() ?>" id="comment-<?php comment_ID() ?>"> 
     911                <?php if ( 'list' == $args['style'] ) : ?> 
     912                <div id="div-comment-<?php comment_ID() ?>"> 
     913                <?php endif; ?> 
     914                <div class="comment-author vcard"> 
     915                <?php echo get_avatar( $comment, 32 ) ?> 
     916                <?php printf(__('<cite>%s</cite> Says:'), get_comment_author_link()) ?> 
     917                </div> 
     918<?php if ($comment->comment_approved == '0') : ?> 
     919                <em><?php _e('Your comment is awaiting moderation.') ?></em> 
     920                <br /> 
     921<?php endif; ?> 
     922 
     923                <div class="comment-meta commentmetadata"><a href="#comment-<?php comment_ID() ?>" title=""><?php printf(__('%1$s at %2$s'), get_comment_date('F jS, Y'),  get_comment_time()) ?></a><?php edit_comment_link('edit','&nbsp;&nbsp;','') ?></div> 
     924 
     925                <?php echo apply_filters('comment_text', get_comment_text()) ?> 
     926 
     927                <div class='reply'> 
     928                <?php if ( $depth < $args['depth'] ) echo comment_reply_link(array('add_below' => 'div-comment')) ?> 
     929                <?php if ( 'list' == $args['style'] ) : ?> 
     930                </div> 
     931                <?php endif; ?> 
     932                </div> 
     933<?php 
     934        } 
     935 
     936        function end_el(&$output, $comment, $depth, $args) { 
     937                if ( 'div' == $args['style'] ) 
     938                        echo "</div>\n"; 
     939                else 
     940                        echo "</li>\n"; 
     941        } 
     942 
     943} 
     944 
     945function wp_list_comments(&$comments, $args = array() ) { 
     946        $defaults = array('walker' => null, 'depth' => 3, 'style' => 'list', 'callback' => null); 
     947 
     948        $r = wp_parse_args( $args, $defaults ); 
     949 
     950        extract( $r, EXTR_SKIP ); 
     951 
     952        if ( empty($walker) ) 
     953                $walker = new Walker_Comment; 
     954 
     955        $walker->walk($comments, $depth, $r); 
     956} 
     957 
    838958?> 
     959 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

     
    141141        $scripts->add( 'jquery-ui-resizable', '/wp-includes/js/jquery/ui.resizable.js', array('jquery-ui-core'), '1.5.2' ); 
    142142        $scripts->add( 'jquery-ui-dialog', '/wp-includes/js/jquery/ui.dialog.js', array('jquery-ui-resizable', 'jquery-ui-draggable'), '1.5.2' ); 
    143143 
     144        $scripts->add( 'comment-reply', '/wp-includes/js/comment-reply.js', false, '20080828'); 
     145 
    144146        if ( is_admin() ) { 
    145147                $scripts->add( 'ajaxcat', '/wp-admin/js/cat.js', array( 'wp-lists' ), '20071101' ); 
    146148                $scripts->localize( 'ajaxcat', 'catL10n', array( 
  • wp-content/themes/default/comments.php

     
    1818        <h3 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> to &#8220;<?php the_title(); ?>&#8221;</h3> 
    1919 
    2020        <ol class="commentlist"> 
    21  
    22         <?php foreach ($comments as $comment) : ?> 
    23  
    24                 <li <?php comment_class($oddcomment) ?> id="comment-<?php comment_ID() ?>"> 
    25                         <?php echo get_avatar( $comment, 32 ); ?> 
    26                         <cite><?php comment_author_link() ?></cite> Says: 
    27                         <?php if ($comment->comment_approved == '0') : ?> 
    28                         <em>Your comment is awaiting moderation.</em> 
    29                         <?php endif; ?> 
    30                         <br /> 
    31  
    32                         <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> 
    33  
    34                         <?php comment_text() ?> 
    35  
    36                 </li> 
    37  
    38         <?php 
    39                 /* Changes every other comment to a different class */ 
    40                 $oddcomment = ( empty( $oddcomment ) ) ? 'alt' : ''; 
    41         ?> 
    42  
    43         <?php endforeach; /* end for each comment */ ?> 
    44  
     21        <?php wp_list_comments($comments); ?> 
    4522        </ol> 
    4623 
    4724 <?php else : // this is displayed if there are no comments so far ?> 
     
    5936 
    6037<?php if ('open' == $post->comment_status) : ?> 
    6138 
    62 <h3 id="respond">Leave a Reply</h3> 
     39<div id="respond"> 
    6340 
     41<h3>Leave a Reply</h3> 
     42 
     43<div id="cancel-comment-reply" style="display: none;"> 
     44        <small><?php echo cancel_comment_reply_link() ?></small> 
     45</div> 
     46 
    6447<?php if ( get_option('comment_registration') && !$user_ID ) : ?> 
    6548<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> 
    6649<?php else : ?> 
     
    9073 
    9174<p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" /> 
    9275<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" /> 
     76<input type="hidden" name="comment_parent" id="comment-parent" value="0" /> 
    9377</p> 
    9478<?php do_action('comment_form', $post->ID); ?> 
    9579 
    9680</form> 
     81</div> 
    9782 
    9883<?php endif; // If registration required and not logged in ?> 
    9984 
  • 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>