Ticket #26687: comment-template.diff
File comment-template.diff, 27.0 KB (added by , 12 years ago) |
---|
-
wp-includes/comment-template.php
26 26 if ( $comment->user_id && $user = get_userdata( $comment->user_id ) ) 27 27 $author = $user->display_name; 28 28 else 29 $author = __( 'Anonymous');29 $author = __( 'Anonymous' ); 30 30 } else { 31 31 $author = $comment->comment_author; 32 32 } … … 158 158 * @param string $comment->comment_author_email The comment author's email address. 159 159 */ 160 160 $email = apply_filters( 'comment_email', $comment->comment_author_email ); 161 if ( (!empty($email)) && ($email != '@')) {162 $display = ($linktext != '') ? $linktext : $email;161 if ( ( !empty( $email ) ) && ( $email != '@' ) ) { 162 $display = ( $linktext != '' ) ? $linktext : $email; 163 163 $return = $before; 164 164 $return .= "<a href='mailto:$email'>$display</a>"; 165 165 $return .= $after; 166 166 return $return; 167 167 } else { 168 168 return ''; … … 253 253 */ 254 254 function get_comment_author_url( $comment_ID = 0 ) { 255 255 $comment = get_comment( $comment_ID ); 256 $url = ( 'http://' == $comment->comment_author_url) ? '' : $comment->comment_author_url;257 $url = esc_url( $url, array( 'http', 'https') );256 $url = ( 'http://' == $comment->comment_author_url ) ? '' : $comment->comment_author_url; 257 $url = esc_url( $url, array( 'http', 'https' ) ); 258 258 /** 259 259 * Filter the comment author's URL. 260 260 * … … 303 303 */ 304 304 function get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) { 305 305 $url = get_comment_author_url(); 306 $display = ( $linktext != '') ? $linktext : $url;306 $display = ( $linktext != '' ) ? $linktext : $url; 307 307 $display = str_replace( 'http://www.', '', $display ); 308 308 $display = str_replace( 'http://', '', $display ); 309 if ( '/' == substr( $display, -1) )310 $display = substr( $display, 0, -1);309 if ( '/' == substr( $display, -1 ) ) 310 $display = substr( $display, 0, -1 ); 311 311 $return = "$before<a href='$url' rel='external'>$display</a>$after"; 312 312 313 313 /** … … 346 346 function comment_class( $class = '', $comment_id = null, $post_id = null, $echo = true ) { 347 347 // Separates classes with a single space, collates classes for comment DIV 348 348 $class = 'class="' . join( ' ', get_comment_class( $class, $comment_id, $post_id ) ) . '"'; 349 if ( $echo )349 if ( $echo ) 350 350 echo $class; 351 351 else 352 352 return $class; … … 365 365 function get_comment_class( $class = '', $comment_id = null, $post_id = null ) { 366 366 global $comment_alt, $comment_depth, $comment_thread_alt; 367 367 368 $comment = get_comment( $comment_id);368 $comment = get_comment( $comment_id ); 369 369 370 370 $classes = array(); 371 371 … … 373 373 $classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type; 374 374 375 375 // If the comment author has an id (registered), then print the log in name 376 if ( $comment->user_id > 0 && $user = get_userdata( $comment->user_id) ) {376 if ( $comment->user_id > 0 && $user = get_userdata( $comment->user_id ) ) { 377 377 // For all registered users, 'byuser' 378 378 $classes[] = 'byuser'; 379 $classes[] = 'comment-author-' . sanitize_html_class( $user->user_nicename, $comment->user_id);379 $classes[] = 'comment-author-' . sanitize_html_class( $user->user_nicename, $comment->user_id ); 380 380 // For comment authors who are the author of the post 381 if ( $post = get_post( $post_id) ) {381 if ( $post = get_post( $post_id ) ) { 382 382 if ( $comment->user_id === $post->post_author ) 383 383 $classes[] = 'bypostauthor'; 384 384 } 385 385 } 386 386 387 if ( empty( $comment_alt) )387 if ( empty( $comment_alt ) ) 388 388 $comment_alt = 0; 389 if ( empty( $comment_depth) )389 if ( empty( $comment_depth ) ) 390 390 $comment_depth = 1; 391 if ( empty( $comment_thread_alt) )391 if ( empty( $comment_thread_alt ) ) 392 392 $comment_thread_alt = 0; 393 393 394 394 if ( $comment_alt % 2 ) { … … 413 413 414 414 $classes[] = "depth-$comment_depth"; 415 415 416 if ( !empty( $class) ) {416 if ( !empty( $class ) ) { 417 417 if ( !is_array( $class ) ) 418 $class = preg_split( '#\s+#', $class);419 $classes = array_merge( $classes, $class);418 $class = preg_split( '#\s+#', $class ); 419 $classes = array_merge( $classes, $class ); 420 420 } 421 421 422 $classes = array_map( 'esc_attr', $classes);422 $classes = array_map( 'esc_attr', $classes ); 423 423 424 424 /** 425 425 * Filter the returned CSS classes for the current comment. … … 446 446 function get_comment_date( $d = '', $comment_ID = 0 ) { 447 447 $comment = get_comment( $comment_ID ); 448 448 if ( '' == $d ) 449 $date = mysql2date( get_option('date_format'), $comment->comment_date);449 $date = mysql2date( get_option( 'date_format' ), $comment->comment_date ); 450 450 else 451 $date = mysql2date( $d, $comment->comment_date);451 $date = mysql2date( $d, $comment->comment_date ); 452 452 /** 453 453 * Filter the returned comment date. 454 454 * … … 486 486 */ 487 487 function get_comment_excerpt( $comment_ID = 0 ) { 488 488 $comment = get_comment( $comment_ID ); 489 $comment_text = strip_tags( $comment->comment_content);490 $blah = explode( ' ', $comment_text);491 if ( count($blah) > 20) {489 $comment_text = strip_tags( $comment->comment_content ); 490 $blah = explode( ' ', $comment_text ); 491 if ( count( $blah ) > 20 ) { 492 492 $k = 20; 493 493 $use_dotdotdot = 1; 494 494 } else { 495 $k = count( $blah);495 $k = count( $blah ); 496 496 $use_dotdotdot = 0; 497 497 } 498 498 $excerpt = ''; 499 for ( $i=0; $i<$k; $i++) {499 for ( $i=0; $i<$k; $i++ ) { 500 500 $excerpt .= $blah[$i] . ' '; 501 501 } 502 $excerpt .= ( $use_dotdotdot) ? '…' : '';503 return apply_filters( 'get_comment_excerpt', $excerpt);502 $excerpt .= ( $use_dotdotdot ) ? '…' : ''; 503 return apply_filters( 'get_comment_excerpt', $excerpt ); 504 504 } 505 505 506 506 /** … … 511 511 * @param int $comment_ID Optional. The ID of the comment for which to print the excerpt. Default current comment. 512 512 */ 513 513 function comment_excerpt( $comment_ID = 0 ) { 514 $comment_excerpt = get_comment_excerpt( $comment_ID);514 $comment_excerpt = get_comment_excerpt( $comment_ID ); 515 515 /** 516 516 * Filter the comment excerpt for display. 517 517 * … … 562 562 function get_comment_link( $comment = null, $args = array() ) { 563 563 global $wp_rewrite, $in_comment_loop; 564 564 565 $comment = get_comment( $comment);565 $comment = get_comment( $comment ); 566 566 567 567 // Backwards compat 568 if ( !is_array( $args) ) {568 if ( !is_array( $args ) ) { 569 569 $page = $args; 570 570 $args = array(); 571 571 $args['page'] = $page; … … 574 574 $defaults = array( 'type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => '' ); 575 575 $args = wp_parse_args( $args, $defaults ); 576 576 577 if ( '' === $args['per_page'] && get_option( 'page_comments') )578 $args['per_page'] = get_option( 'comments_per_page');577 if ( '' === $args['per_page'] && get_option( 'page_comments' ) ) 578 $args['per_page'] = get_option( 'comments_per_page' ); 579 579 580 if ( empty( $args['per_page']) ) {580 if ( empty( $args['per_page'] ) ) { 581 581 $args['per_page'] = 0; 582 582 $args['page'] = 0; 583 583 } 584 584 585 585 if ( $args['per_page'] ) { 586 586 if ( '' == $args['page'] ) 587 $args['page'] = ( !empty( $in_comment_loop) ) ? get_query_var('cpage') : get_page_of_comment( $comment->comment_ID, $args );587 $args['page'] = ( !empty( $in_comment_loop ) ) ? get_query_var( 'cpage' ) : get_page_of_comment( $comment->comment_ID, $args ); 588 588 589 589 if ( $wp_rewrite->using_permalinks() ) 590 590 $link = user_trailingslashit( trailingslashit( get_permalink( $comment->comment_post_ID ) ) . 'comment-page-' . $args['page'], 'comment' ); … … 658 658 if ( !$post_id ) 659 659 $post_id = get_the_ID(); 660 660 661 $post = get_post( $post_id);662 if ( ! isset( $post->comment_count) )661 $post = get_post( $post_id ); 662 if ( ! isset( $post->comment_count ) ) 663 663 $count = 0; 664 664 else 665 665 $count = $post->comment_count; … … 692 692 $number = get_comments_number(); 693 693 694 694 if ( $number > 1 ) 695 $output = str_replace( '%', number_format_i18n($number), ( false === $more ) ? __('% Comments') : $more);695 $output = str_replace( '%', number_format_i18n( $number ), ( false === $more ) ? __( '% Comments' ) : $more ); 696 696 elseif ( $number == 0 ) 697 $output = ( false === $zero ) ? __( 'No Comments') : $zero;697 $output = ( false === $zero ) ? __( 'No Comments' ) : $zero; 698 698 else // must be one 699 $output = ( false === $one ) ? __( '1 Comment') : $one;699 $output = ( false === $one ) ? __( '1 Comment' ) : $one; 700 700 701 701 /** 702 702 * Filter the comments count for display. … … 773 773 global $comment; 774 774 $comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date; 775 775 if ( '' == $d ) 776 $date = mysql2date( get_option('time_format'), $comment_date, $translate);776 $date = mysql2date( get_option( 'time_format' ), $comment_date, $translate ); 777 777 else 778 $date = mysql2date( $d, $comment_date, $translate);778 $date = mysql2date( $d, $comment_date, $translate ); 779 779 780 780 /** 781 781 * Filter the returned comment time. … … 798 798 * @param string $d Optional. The format of the time. Default user's settings. 799 799 */ 800 800 function comment_time( $d = '' ) { 801 echo get_comment_time( $d);801 echo get_comment_time( $d ); 802 802 } 803 803 804 804 /** … … 862 862 * @return string The trackback URL after being filtered. 863 863 */ 864 864 function get_trackback_url() { 865 if ( '' != get_option( 'permalink_structure') )866 $tb_url = trailingslashit( get_permalink()) . user_trailingslashit('trackback', 'single_trackback');865 if ( '' != get_option( 'permalink_structure' ) ) 866 $tb_url = trailingslashit( get_permalink() ) . user_trailingslashit( 'trackback', 'single_trackback' ); 867 867 else 868 $tb_url = get_option( 'siteurl') . '/wp-trackback.php?p=' . get_the_ID();868 $tb_url = get_option( 'siteurl' ) . '/wp-trackback.php?p=' . get_the_ID(); 869 869 870 870 /** 871 871 * Filter the returned trackback URL. … … 887 887 */ 888 888 function trackback_url( $deprecated_echo = true ) { 889 889 if ( $deprecated_echo !== true ) 890 _deprecated_argument( __FUNCTION__, '2.5', __( 'Use <code>get_trackback_url()</code> instead if you do not want the value echoed.') );890 _deprecated_argument( __FUNCTION__, '2.5', __( 'Use <code>get_trackback_url()</code> instead if you do not want the value echoed.' ) ); 891 891 if ( $deprecated_echo ) 892 892 echo get_trackback_url(); 893 893 else … … 907 907 if ( !empty( $deprecated ) ) 908 908 _deprecated_argument( __FUNCTION__, '2.5' ); 909 909 910 if ( false !== stripos( $_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') )910 if ( false !== stripos( $_SERVER['HTTP_USER_AGENT'], 'W3C_Validator' ) ) 911 911 return; 912 912 913 913 echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" … … 919 919 echo ' dc:identifier="'; 920 920 the_permalink(); 921 921 echo '"'."\n"; 922 echo ' dc:title="'.str_replace( '--', '--', wptexturize(strip_tags(get_the_title()))).'"'."\n";922 echo ' dc:title="'.str_replace( '--', '--', wptexturize( strip_tags( get_the_title() ) ) ).'"'."\n"; 923 923 echo ' trackback:ping="'.get_trackback_url().'"'." />\n"; 924 924 echo '</rdf:RDF>'; 925 925 } … … 934 934 */ 935 935 function comments_open( $post_id = null ) { 936 936 937 $_post = get_post( $post_id);937 $_post = get_post( $post_id ); 938 938 939 939 $open = ( 'open' == $_post->comment_status ); 940 940 … … 959 959 */ 960 960 function pings_open( $post_id = null ) { 961 961 962 $_post = get_post( $post_id);962 $_post = get_post( $post_id ); 963 963 964 964 $open = ( 'open' == $_post->ping_status ); 965 965 return apply_filters( 'pings_open', $open, $post_id ); … … 1017 1017 function comments_template( $file = '/comments.php', $separate_comments = false ) { 1018 1018 global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage; 1019 1019 1020 if ( !( is_single() || is_page() || $withcomments) || empty($post) )1020 if ( !( is_single() || is_page() || $withcomments ) || empty( $post ) ) 1021 1021 return; 1022 1022 1023 if ( empty( $file) )1023 if ( empty( $file ) ) 1024 1024 $file = '/comments.php'; 1025 1025 1026 $req = get_option( 'require_name_email');1026 $req = get_option( 'require_name_email' ); 1027 1027 1028 1028 /** 1029 1029 * Comment author information fetched from the comment cookies. … … 1045 1045 /** 1046 1046 * The url of the current comment author escaped for use in attributes. 1047 1047 */ 1048 $comment_author_url = esc_url( $commenter['comment_author_url']);1048 $comment_author_url = esc_url( $commenter['comment_author_url'] ); 1049 1049 1050 1050 /** @todo Use API instead of SELECTs. */ 1051 1051 if ( $user_ID) { 1052 $comments = $wpdb->get_results($wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND (comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, $user_ID));1052 $comments = $wpdb->get_results($wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND (comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, $user_ID ) ); 1053 1053 } else if ( empty($comment_author) ) { 1054 $comments = get_comments( array( 'post_id' => $post->ID, 'status' => 'approve', 'order' => 'ASC') );1054 $comments = get_comments( array( 'post_id' => $post->ID, 'status' => 'approve', 'order' => 'ASC' ) ); 1055 1055 } else { 1056 $comments = $wpdb->get_results($wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND ( comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, wp_specialchars_decode($comment_author,ENT_QUOTES), $comment_author_email));1056 $comments = $wpdb->get_results($wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND ( comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, wp_specialchars_decode( $comment_author,ENT_QUOTES ), $comment_author_email ) ); 1057 1057 } 1058 1058 1059 1059 // keep $comments for legacy's sake … … 1067 1067 */ 1068 1068 $wp_query->comments = apply_filters( 'comments_array', $comments, $post->ID ); 1069 1069 $comments = &$wp_query->comments; 1070 $wp_query->comment_count = count( $wp_query->comments);1071 update_comment_cache( $wp_query->comments);1070 $wp_query->comment_count = count( $wp_query->comments ); 1071 update_comment_cache( $wp_query->comments ); 1072 1072 1073 1073 if ( $separate_comments ) { 1074 $wp_query->comments_by_type = separate_comments( $comments);1074 $wp_query->comments_by_type = separate_comments( $comments ); 1075 1075 $comments_by_type = &$wp_query->comments_by_type; 1076 1076 } 1077 1077 1078 1078 $overridden_cpage = false; 1079 if ( '' == get_query_var( 'cpage') && get_option('page_comments') ) {1080 set_query_var( 'cpage', 'newest' == get_option( 'default_comments_page') ? get_comment_pages_count() : 1 );1079 if ( '' == get_query_var( 'cpage' ) && get_option( 'page_comments' ) ) { 1080 set_query_var( 'cpage', 'newest' == get_option( 'default_comments_page' ) ? get_comment_pages_count() : 1 ); 1081 1081 $overridden_cpage = true; 1082 1082 } 1083 1083 1084 if ( !defined( 'COMMENTS_TEMPLATE') )1085 define( 'COMMENTS_TEMPLATE', true);1084 if ( !defined( 'COMMENTS_TEMPLATE' ) ) 1085 define( 'COMMENTS_TEMPLATE', true ); 1086 1086 1087 1087 $theme_template = STYLESHEETPATH . $file; 1088 1088 /** … … 1122 1122 function comments_popup_script( $width = 400, $height = 400, $file = '' ) { 1123 1123 global $wpcommentspopupfile, $wpcommentsjavascript; 1124 1124 1125 if ( empty ($file)) {1125 if ( empty ( $file ) ) { 1126 1126 $wpcommentspopupfile = ''; // Use the index. 1127 1127 } else { 1128 1128 $wpcommentspopupfile = $file; … … 1164 1164 $number = get_comments_number( $id ); 1165 1165 1166 1166 if ( 0 == $number && !comments_open() && !pings_open() ) { 1167 echo '<span' . ( (!empty($css_class)) ? ' class="' . esc_attr( $css_class ) . '"' : '') . '>' . $none . '</span>';1167 echo '<span' . ( ( !empty( $css_class ) ) ? ' class="' . esc_attr( $css_class ) . '"' : '' ) . '>' . $none . '</span>'; 1168 1168 return; 1169 1169 } 1170 1170 1171 1171 if ( post_password_required() ) { 1172 echo __( 'Enter your password to view comments.');1172 echo __( 'Enter your password to view comments.' ); 1173 1173 return; 1174 1174 } 1175 1175 … … 1178 1178 if ( empty( $wpcommentspopupfile ) ) 1179 1179 $home = home_url(); 1180 1180 else 1181 $home = get_option( 'siteurl');1181 $home = get_option( 'siteurl' ); 1182 1182 echo $home . '/' . $wpcommentspopupfile . '?comments_popup=' . $id; 1183 1183 echo '" onclick="wpopen(this.href); return false"'; 1184 1184 } else { // if comments_popup_script() is not in the template, display simple comment link … … 1192 1192 if ( !empty( $css_class ) ) { 1193 1193 echo ' class="'.$css_class.'" '; 1194 1194 } 1195 $title = the_title_attribute( array( 'echo' => 0 ) );1195 $title = the_title_attribute( array( 'echo' => 0 ) ); 1196 1196 1197 1197 $attributes = ''; 1198 1198 /** … … 1204 1204 */ 1205 1205 echo apply_filters( 'comments_popup_link_attributes', $attributes ); 1206 1206 1207 echo ' title="' . esc_attr( sprintf( __( 'Comment on %s'), $title ) ) . '">';1207 echo ' title="' . esc_attr( sprintf( __( 'Comment on %s' ), $title ) ) . '">'; 1208 1208 comments_number( $zero, $one, $more ); 1209 1209 echo '</a>'; 1210 1210 } … … 1234 1234 * @param int|WP_Post $post Optional. Post ID or WP_Post object the comment is going to be displayed on. Default current post. 1235 1235 * @return mixed Link to show comment form, if successful. False, if comments are closed. 1236 1236 */ 1237 function get_comment_reply_link( $args = array(), $comment = null, $post = null) {1237 function get_comment_reply_link( $args = array(), $comment = null, $post = null ) { 1238 1238 1239 1239 $defaults = array( 1240 1240 'add_below' => 'comment', 1241 1241 'respond_id' => 'respond', 1242 'reply_text' => __( 'Reply'),1243 'login_text' => __( 'Log in to Reply'),1242 'reply_text' => __( 'Reply' ), 1243 'login_text' => __( 'Log in to Reply' ), 1244 1244 'depth' => 0, 1245 1245 'before' => '', 1246 1246 'after' => '' 1247 1247 ); 1248 1248 1249 $args = wp_parse_args( $args, $defaults);1249 $args = wp_parse_args( $args, $defaults ); 1250 1250 1251 1251 if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] ) 1252 1252 return; 1253 1253 1254 extract( $args, EXTR_SKIP);1254 extract( $args, EXTR_SKIP ); 1255 1255 1256 $comment = get_comment( $comment);1257 if ( empty( $post) )1256 $comment = get_comment( $comment ); 1257 if ( empty( $post ) ) 1258 1258 $post = $comment->comment_post_ID; 1259 $post = get_post( $post);1259 $post = get_post( $post ); 1260 1260 1261 if ( !comments_open( $post->ID) )1261 if ( !comments_open( $post->ID ) ) 1262 1262 return false; 1263 1263 1264 1264 $link = ''; 1265 1265 1266 if ( get_option( 'comment_registration') && ! is_user_logged_in() )1266 if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) 1267 1267 $link = '<a rel="nofollow" class="comment-reply-login" href="' . esc_url( wp_login_url( get_permalink() ) ) . '">' . $login_text . '</a>'; 1268 1268 else 1269 1269 $link = "<a class='comment-reply-link' href='" . esc_url( add_query_arg( 'replytocom', $comment->comment_ID ) ) . "#" . $respond_id . "' onclick='return addComment.moveForm(\"$add_below-$comment->comment_ID\", \"$comment->comment_ID\", \"$respond_id\", \"$post->ID\")'>$reply_text</a>"; … … 1293 1293 * @param int|WP_Post $post Optional. Post ID or WP_Post object the comment is going to be displayed on. Default current post. 1294 1294 * @return mixed Link to show comment form, if successful. False, if comments are closed. 1295 1295 */ 1296 function comment_reply_link( $args = array(), $comment = null, $post = null) {1297 echo get_comment_reply_link( $args, $comment, $post);1296 function comment_reply_link( $args = array(), $comment = null, $post = null ) { 1297 echo get_comment_reply_link( $args, $comment, $post ); 1298 1298 } 1299 1299 1300 1300 /** … … 1318 1318 * @param int|WP_Post $post Optional. Post ID or WP_Post object the comment is going to be displayed on. Default current post. 1319 1319 * @return string|bool|null Link to show comment form, if successful. False, if comments are closed. 1320 1320 */ 1321 function get_post_reply_link( $args = array(), $post = null) {1321 function get_post_reply_link( $args = array(), $post = null ) { 1322 1322 $defaults = array( 1323 1323 'add_below' => 'post', 1324 1324 'respond_id' => 'respond', 1325 'reply_text' => __( 'Leave a Comment'),1326 'login_text' => __( 'Log in to leave a Comment'),1325 'reply_text' => __( 'Leave a Comment' ), 1326 'login_text' => __( 'Log in to leave a Comment' ), 1327 1327 'before' => '', 1328 1328 'after' => '', 1329 1329 ); 1330 1330 1331 $args = wp_parse_args( $args, $defaults);1332 extract( $args, EXTR_SKIP);1333 $post = get_post( $post);1331 $args = wp_parse_args( $args, $defaults ); 1332 extract( $args, EXTR_SKIP ); 1333 $post = get_post( $post ); 1334 1334 1335 if ( !comments_open( $post->ID) )1335 if ( !comments_open( $post->ID ) ) 1336 1336 return false; 1337 1337 1338 if ( get_option( 'comment_registration') && ! is_user_logged_in() )1338 if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) 1339 1339 $link = '<a rel="nofollow" href="' . wp_login_url( get_permalink() ) . '">' . $login_text . '</a>'; 1340 1340 else 1341 $link = "<a rel='nofollow' class='comment-reply-link' href='" . get_permalink( $post->ID) . "#$respond_id' onclick='return addComment.moveForm(\"$add_below-$post->ID\", \"0\", \"$respond_id\", \"$post->ID\")'>$reply_text</a>";1341 $link = "<a rel='nofollow' class='comment-reply-link' href='" . get_permalink( $post->ID ) . "#$respond_id' onclick='return addComment.moveForm(\"$add_below-$post->ID\", \"0\", \"$respond_id\", \"$post->ID\")'>$reply_text</a>"; 1342 1342 1343 1343 $formatted_link = $before . $link . $after; 1344 1344 /** … … 1361 1361 * @param int|WP_Post $post Optional. Post ID or WP_Post object the comment is going to be displayed on. Default current post. 1362 1362 * @return string|bool|null Link to show comment form, if successful. False, if comments are closed. 1363 1363 */ 1364 function post_reply_link( $args = array(), $post = null) {1365 echo get_post_reply_link( $args, $post);1364 function post_reply_link( $args = array(), $post = null ) { 1365 echo get_post_reply_link( $args, $post ); 1366 1366 } 1367 1367 1368 1368 /** … … 1373 1373 * @param string $text Optional. Text to display for cancel reply link. Default empty. 1374 1374 */ 1375 1375 function get_cancel_comment_reply_link( $text = '' ) { 1376 if ( empty( $text) )1377 $text = __( 'Click here to cancel reply.');1376 if ( empty( $text ) ) 1377 $text = __( 'Click here to cancel reply.' ); 1378 1378 1379 $style = isset( $_GET['replytocom']) ? '' : ' style="display:none;"';1380 $link = esc_html( remove_query_arg( 'replytocom') ) . '#respond';1379 $style = isset( $_GET['replytocom'] ) ? '' : ' style="display:none;"'; 1380 $link = esc_html( remove_query_arg( 'replytocom' ) ) . '#respond'; 1381 1381 1382 1382 $formatted_link = '<a rel="nofollow" id="cancel-comment-reply-link" href="' . $link . '"' . $style . '>' . $text . '</a>'; 1383 1383 /** … … 1400 1400 * @param string $text Optional. Text to display for cancel reply link. Default empty. 1401 1401 */ 1402 1402 function cancel_comment_reply_link( $text = '' ) { 1403 echo get_cancel_comment_reply_link( $text);1403 echo get_cancel_comment_reply_link( $text ); 1404 1404 } 1405 1405 1406 1406 /** … … 1415 1415 if ( empty( $id ) ) 1416 1416 $id = get_the_ID(); 1417 1417 1418 $replytoid = isset( $_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;1418 $replytoid = isset( $_GET['replytocom'] ) ? (int) $_GET['replytocom'] : 0; 1419 1419 $result = "<input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' />\n"; 1420 1420 $result .= "<input type='hidden' name='comment_parent' id='comment_parent' value='$replytoid' />\n"; 1421 1421 … … 1460 1460 if ( false === $noreplytext ) $noreplytext = __( 'Leave a Reply' ); 1461 1461 if ( false === $replytext ) $replytext = __( 'Leave a Reply to %s' ); 1462 1462 1463 $replytoid = isset( $_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;1463 $replytoid = isset( $_GET['replytocom'] ) ? (int) $_GET['replytocom'] : 0; 1464 1464 1465 1465 if ( 0 == $replytoid ) 1466 1466 echo $noreplytext; 1467 1467 else { 1468 $comment = get_comment( $replytoid);1468 $comment = get_comment( $replytoid ); 1469 1469 $author = ( $linktoparent ) ? '<a href="#comment-' . get_comment_ID() . '">' . get_comment_author() . '</a>' : get_comment_author(); 1470 1470 printf( $replytext, $author ); 1471 1471 } … … 1497 1497 * @since 2.7.0 1498 1498 * @var array 1499 1499 */ 1500 var $db_fields = array ( 'parent' => 'comment_parent', 'id' => 'comment_ID');1500 var $db_fields = array ( 'parent' => 'comment_parent', 'id' => 'comment_ID' ); 1501 1501 1502 1502 /** 1503 1503 * Start the list before the elements are added. … … 1596 1596 1597 1597 // If we're at the max depth, and the current element still has children, loop over those and display them at this level 1598 1598 // This is to prevent them being orphaned to the end of the list. 1599 if ( $max_depth <= $depth + 1 && isset( $children_elements[$id] ) ) {1599 if ( $max_depth <= $depth + 1 && isset( $children_elements[$id] ) ) { 1600 1600 foreach ( $children_elements[ $id ] as $child ) 1601 1601 $this->display_element( $child, $children_elements, $max_depth, $depth, $args, $output ); 1602 1602 … … 1845 1845 // Figure out what comments we'll be looping through ($_comments) 1846 1846 if ( null !== $comments ) { 1847 1847 $comments = (array) $comments; 1848 if ( empty( $comments) )1848 if ( empty( $comments ) ) 1849 1849 return; 1850 1850 if ( 'all' != $r['type'] ) { 1851 $comments_by_type = separate_comments( $comments);1852 if ( empty( $comments_by_type[$r['type']]) )1851 $comments_by_type = separate_comments( $comments ); 1852 if ( empty( $comments_by_type[$r['type']] ) ) 1853 1853 return; 1854 1854 $_comments = $comments_by_type[$r['type']]; 1855 1855 } else { 1856 1856 $_comments = $comments; 1857 1857 } 1858 1858 } else { 1859 if ( empty( $wp_query->comments) )1859 if ( empty( $wp_query->comments ) ) 1860 1860 return; 1861 1861 if ( 'all' != $r['type'] ) { 1862 if ( empty( $wp_query->comments_by_type) )1863 $wp_query->comments_by_type = separate_comments( $wp_query->comments);1864 if ( empty( $wp_query->comments_by_type[$r['type']]) )1862 if ( empty( $wp_query->comments_by_type ) ) 1863 $wp_query->comments_by_type = separate_comments( $wp_query->comments ); 1864 if ( empty( $wp_query->comments_by_type[$r['type']] ) ) 1865 1865 return; 1866 1866 $_comments = $wp_query->comments_by_type[$r['type']]; 1867 1867 } else { … … 1869 1869 } 1870 1870 } 1871 1871 1872 if ( '' === $r['per_page'] && get_option( 'page_comments') )1873 $r['per_page'] = get_query_var( 'comments_per_page');1872 if ( '' === $r['per_page'] && get_option( 'page_comments' ) ) 1873 $r['per_page'] = get_query_var( 'comments_per_page' ); 1874 1874 1875 if ( empty( $r['per_page']) ) {1875 if ( empty( $r['per_page'] ) ) { 1876 1876 $r['per_page'] = 0; 1877 1877 $r['page'] = 0; 1878 1878 } 1879 1879 1880 1880 if ( '' === $r['max_depth'] ) { 1881 if ( get_option( 'thread_comments') )1882 $r['max_depth'] = get_option( 'thread_comments_depth');1881 if ( get_option( 'thread_comments' ) ) 1882 $r['max_depth'] = get_option( 'thread_comments_depth' ); 1883 1883 else 1884 1884 $r['max_depth'] = -1; 1885 1885 } 1886 1886 1887 1887 if ( '' === $r['page'] ) { 1888 if ( empty( $overridden_cpage) ) {1889 $r['page'] = get_query_var( 'cpage');1888 if ( empty( $overridden_cpage ) ) { 1889 $r['page'] = get_query_var( 'cpage' ); 1890 1890 } else { 1891 1891 $threaded = ( -1 != $r['max_depth'] ); 1892 $r['page'] = ( 'newest' == get_option( 'default_comments_page') ) ? get_comment_pages_count($_comments, $r['per_page'], $threaded) : 1;1892 $r['page'] = ( 'newest' == get_option( 'default_comments_page' ) ) ? get_comment_pages_count( $_comments, $r['per_page'], $threaded ) : 1; 1893 1893 set_query_var( 'cpage', $r['page'] ); 1894 1894 } 1895 1895 } 1896 1896 // Validation check 1897 $r['page'] = intval( $r['page']);1897 $r['page'] = intval( $r['page'] ); 1898 1898 if ( 0 == $r['page'] && 0 != $r['per_page'] ) 1899 1899 $r['page'] = 1; 1900 1900 1901 1901 if ( null === $r['reverse_top_level'] ) 1902 $r['reverse_top_level'] = ( 'desc' == get_option( 'comment_order') );1902 $r['reverse_top_level'] = ( 'desc' == get_option( 'comment_order' ) ); 1903 1903 1904 1904 extract( $r, EXTR_SKIP ); 1905 1905 1906 if ( empty( $walker) )1906 if ( empty( $walker ) ) 1907 1907 $walker = new Walker_Comment; 1908 1908 1909 $output = $walker->paged_walk( $_comments, $max_depth, $page, $per_page, $r);1909 $output = $walker->paged_walk( $_comments, $max_depth, $page, $per_page, $r ); 1910 1910 $wp_query->max_num_comment_pages = $walker->max_pages; 1911 1911 1912 1912 $in_comment_loop = false; … … 1983 1983 '<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>', 1984 1984 ); 1985 1985 1986 $required_text = sprintf( ' ' . __( 'Required fields are marked %s'), '<span class="required">*</span>' );1986 $required_text = sprintf( ' ' . __( 'Required fields are marked %s' ), '<span class="required">*</span>' ); 1987 1987 1988 1988 /** 1989 1989 * Filter the default comment form fields.