branch | wordpress |
changeset 132 | 4d4862461b8d |
parent 109 | 03b0d1493584 |
131:a4642baaf829 | 132:4d4862461b8d |
---|---|
530 if ( ! isset($post->comment_count) ) |
530 if ( ! isset($post->comment_count) ) |
531 $count = 0; |
531 $count = 0; |
532 else |
532 else |
533 $count = $post->comment_count; |
533 $count = $post->comment_count; |
534 |
534 |
535 return apply_filters('get_comments_number', $count); |
535 return apply_filters('get_comments_number', $count, $post_id); |
536 } |
536 } |
537 |
537 |
538 /** |
538 /** |
539 * Display the language string for the number of comments the current post has. |
539 * Display the language string for the number of comments the current post has. |
540 * |
540 * |
597 * @param bool $translate Whether to translate the time (for use in feeds) |
597 * @param bool $translate Whether to translate the time (for use in feeds) |
598 * @return string The formatted time |
598 * @return string The formatted time |
599 */ |
599 */ |
600 function get_comment_time( $d = '', $gmt = false, $translate = true ) { |
600 function get_comment_time( $d = '', $gmt = false, $translate = true ) { |
601 global $comment; |
601 global $comment; |
602 $comment_date = $gmt? $comment->comment_date_gmt : $comment->comment_date; |
602 $comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date; |
603 if ( '' == $d ) |
603 if ( '' == $d ) |
604 $date = mysql2date(get_option('time_format'), $comment_date, $translate); |
604 $date = mysql2date(get_option('time_format'), $comment_date, $translate); |
605 else |
605 else |
606 $date = mysql2date($d, $comment_date, $translate); |
606 $date = mysql2date($d, $comment_date, $translate); |
607 return apply_filters('get_comment_time', $date, $d, $gmt); |
607 return apply_filters('get_comment_time', $date, $d, $gmt, $translate); |
608 } |
608 } |
609 |
609 |
610 /** |
610 /** |
611 * Display the comment time of the current comment. |
611 * Display the comment time of the current comment. |
612 * |
612 * |
811 * @return null Returns null if no comments appear |
811 * @return null Returns null if no comments appear |
812 */ |
812 */ |
813 function comments_template( $file = '/comments.php', $separate_comments = false ) { |
813 function comments_template( $file = '/comments.php', $separate_comments = false ) { |
814 global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage; |
814 global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage; |
815 |
815 |
816 if ( ! (is_single() || is_page() || $withcomments) ) |
816 if ( !(is_single() || is_page() || $withcomments) || empty($post) ) |
817 return; |
817 return; |
818 |
818 |
819 if ( empty($file) ) |
819 if ( empty($file) ) |
820 $file = '/comments.php'; |
820 $file = '/comments.php'; |
821 |
821 |
833 */ |
833 */ |
834 $comment_author = $commenter['comment_author']; // Escaped by sanitize_comment_cookies() |
834 $comment_author = $commenter['comment_author']; // Escaped by sanitize_comment_cookies() |
835 |
835 |
836 /** |
836 /** |
837 * The email address of the current comment author escaped for use in attributes. |
837 * The email address of the current comment author escaped for use in attributes. |
838 */ |
838 */ |
839 $comment_author_email = $commenter['comment_author_email']; // Escaped by sanitize_comment_cookies() |
839 $comment_author_email = $commenter['comment_author_email']; // Escaped by sanitize_comment_cookies() |
840 |
840 |
841 /** |
841 /** |
842 * The url of the current comment author escaped for use in attributes. |
842 * The url of the current comment author escaped for use in attributes. |
843 */ |
843 */ |
844 $comment_author_url = esc_url($commenter['comment_author_url']); |
844 $comment_author_url = esc_url($commenter['comment_author_url']); |
845 |
845 |
846 /** @todo Use API instead of SELECTs. */ |
846 /** @todo Use API instead of SELECTs. */ |
847 if ( $user_ID) { |
847 if ( $user_ID) { |
848 $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)); |
848 $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)); |
968 } |
968 } |
969 |
969 |
970 if ( !empty( $css_class ) ) { |
970 if ( !empty( $css_class ) ) { |
971 echo ' class="'.$css_class.'" '; |
971 echo ' class="'.$css_class.'" '; |
972 } |
972 } |
973 $title = esc_attr( get_the_title() ); |
973 $title = the_title_attribute( 'echo=0' ); |
974 |
974 |
975 echo apply_filters( 'comments_popup_link_attributes', '' ); |
975 echo apply_filters( 'comments_popup_link_attributes', '' ); |
976 |
976 |
977 echo ' title="' . esc_attr( sprintf( __('Comment on %s'), $title ) ) . '">'; |
977 echo ' title="' . esc_attr( sprintf( __('Comment on %s'), $title ) ) . '">'; |
978 comments_number( $zero, $one, $more, $number ); |
978 comments_number( $zero, $one, $more, $number ); |
1253 $tag = 'li'; |
1253 $tag = 'li'; |
1254 $add_below = 'div-comment'; |
1254 $add_below = 'div-comment'; |
1255 } |
1255 } |
1256 ?> |
1256 ?> |
1257 <<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>"> |
1257 <<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>"> |
1258 <?php if ( 'ul' == $args['style'] ) : ?> |
1258 <?php if ( 'div' != $args['style'] ) : ?> |
1259 <div id="div-comment-<?php comment_ID() ?>" class="comment-body"> |
1259 <div id="div-comment-<?php comment_ID() ?>" class="comment-body"> |
1260 <?php endif; ?> |
1260 <?php endif; ?> |
1261 <div class="comment-author vcard"> |
1261 <div class="comment-author vcard"> |
1262 <?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, $args['avatar_size'] ); ?> |
1262 <?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, $args['avatar_size'] ); ?> |
1263 <?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?> |
1263 <?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?> |
1272 <?php comment_text() ?> |
1272 <?php comment_text() ?> |
1273 |
1273 |
1274 <div class="reply"> |
1274 <div class="reply"> |
1275 <?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?> |
1275 <?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?> |
1276 </div> |
1276 </div> |
1277 <?php if ( 'ul' == $args['style'] ) : ?> |
1277 <?php if ( 'div' != $args['style'] ) : ?> |
1278 </div> |
1278 </div> |
1279 <?php endif; ?> |
1279 <?php endif; ?> |
1280 <?php |
1280 <?php |
1281 } |
1281 } |
1282 |
1282 |