Ticket #7635: 7635.3.diff
| File 7635.3.diff, 10.3 KB (added by ryan, 5 years ago) |
|---|
-
wp-includes/js/comment-reply.js
1 function 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 22 function 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
227 227 * @param int $comment_id An optional comment ID 228 228 * @param int $post_id An optional post ID 229 229 */ 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 ) ) . '"'; 230 function 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; 233 237 } 234 238 235 239 /** … … 266 270 if ( empty($comment_alt) ) 267 271 $comment_alt = 0; 268 272 269 if ( $comment_alt % 2 ) 273 if ( $comment_alt % 2 ) { 270 274 $classes[] = 'odd'; 271 else 275 $classes[] = 'alt'; 276 } else { 272 277 $classes[] = 'even'; 278 } 273 279 274 280 $comment_alt++; 275 281 … … 835 841 echo '</a>'; 836 842 } 837 843 844 function 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 870 function 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 876 class 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',' ','') ?></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 945 function 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 838 958 ?> 959 No newline at end of file -
wp-includes/link-template.php
531 531 return apply_filters( 'get_edit_comment_link', $location ); 532 532 } 533 533 534 function edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) {534 function edit_comment_link( $link = 'Edit This', $before = '', $after = '', $echo = true ) { 535 535 global $comment, $post; 536 536 537 537 if ( $post->post_type == 'attachment' ) { … … 544 544 } 545 545 546 546 $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; 548 552 } 549 553 550 554 function get_edit_bookmark_link( $link = 0 ) { -
wp-includes/script-loader.php
141 141 $scripts->add( 'jquery-ui-resizable', '/wp-includes/js/jquery/ui.resizable.js', array('jquery-ui-core'), '1.5.2' ); 142 142 $scripts->add( 'jquery-ui-dialog', '/wp-includes/js/jquery/ui.dialog.js', array('jquery-ui-resizable', 'jquery-ui-draggable'), '1.5.2' ); 143 143 144 $scripts->add( 'comment-reply', '/wp-includes/js/comment-reply.js', false, '20080828'); 145 144 146 if ( is_admin() ) { 145 147 $scripts->add( 'ajaxcat', '/wp-admin/js/cat.js', array( 'wp-lists' ), '20071101' ); 146 148 $scripts->localize( 'ajaxcat', 'catL10n', array( -
wp-content/themes/default/comments.php
18 18 <h3 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> to “<?php the_title(); ?>”</h3> 19 19 20 20 <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',' ',''); ?></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); ?> 45 22 </ol> 46 23 47 24 <?php else : // this is displayed if there are no comments so far ?> … … 59 36 60 37 <?php if ('open' == $post->comment_status) : ?> 61 38 62 < h3 id="respond">Leave a Reply</h3>39 <div id="respond"> 63 40 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 64 47 <?php if ( get_option('comment_registration') && !$user_ID ) : ?> 65 48 <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> 66 49 <?php else : ?> … … 90 73 91 74 <p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" /> 92 75 <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" /> 76 <input type="hidden" name="comment_parent" id="comment-parent" value="0" /> 93 77 </p> 94 78 <?php do_action('comment_form', $post->ID); ?> 95 79 96 80 </form> 81 </div> 97 82 98 83 <?php endif; // If registration required and not logged in ?> 99 84 -
wp-content/themes/default/header.php
24 24 25 25 </style> 26 26 27 <?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?> 28 27 29 <?php wp_head(); ?> 28 30 </head> 29 31 <body>
