Ticket #17763: 17763.diff
File 17763.diff, 5.4 KB (added by , 14 years ago) |
---|
-
wp-includes/comment-template.php
569 569 * @param string $one Text for one comment 570 570 * @param string $more Text for more than one comment 571 571 * @param string $deprecated Not used. 572 * @param bool $echo Whether to echo or just return the string 572 573 */ 573 function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {574 function comments_number( $zero = false, $one = false, $more = false, $deprecated = '', $echo = true ) { 574 575 if ( !empty( $deprecated ) ) 575 576 _deprecated_argument( __FUNCTION__, '1.3' ); 576 577 … … 583 584 else // must be one 584 585 $output = ( false === $one ) ? __('1 Comment') : $one; 585 586 586 echo apply_filters('comments_number', $output, $number); 587 if ( $echo ) 588 echo apply_filters('comments_number', $output, $number); 589 else 590 return apply_filters('comments_number', $output, $number); 587 591 } 588 592 589 593 /** … … 949 953 } 950 954 951 955 /** 952 * Displays the link to the comments popup window for the current post ID.956 * Retrives the link to the comments popup window for the current post ID. 953 957 * 954 958 * Is not meant to be displayed on single posts and pages. Should be used on the 955 959 * lists of posts 956 960 * 957 * @since 0.71961 * @since 3.3.0 958 962 * @uses $wpcommentspopupfile 959 963 * @uses $wpcommentsjavascript 960 964 * @uses $post 961 965 * 962 * @param string $zero The string to display when no comments963 * @param string $one The string to display when only one comment is available964 * @param string $more The string to display when there are more than one comment966 * @param bool|string $zero The string to display when no comments 967 * @param bool|string $one The string to display when only one comment is available 968 * @param bool|string $more The string to display when there are more than one comment 965 969 * @param string $css_class The CSS class to use for comments 966 * @param string $none The string to display when comments have been turned off967 * @return null Returns null on single posts and pages.970 * @param bool|string $none The string to display when comments have been turned off 971 * @return string 968 972 */ 969 function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) {973 function get_comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) { 970 974 global $wpcommentspopupfile, $wpcommentsjavascript; 971 975 972 976 $id = get_the_ID(); … … 978 982 979 983 $number = get_comments_number( $id ); 980 984 981 if ( 0 == $number && !comments_open() && !pings_open() ) { 982 echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr( $css_class ) . '"' : '') . '>' . $none . '</span>'; 983 return; 984 } 985 if ( 0 == $number && !comments_open() && !pings_open() ) 986 return '<span' . ((!empty($css_class)) ? ' class="' . esc_attr( $css_class ) . '"' : '') . '>' . $none . '</span>'; 985 987 986 if ( post_password_required() ) { 987 echo __('Enter your password to view comments.'); 988 return; 989 } 988 if ( post_password_required() ) 989 return __('Enter your password to view comments.'); 990 990 991 echo '<a href="'; 991 $output = ''; 992 993 $output .= '<a href="'; 992 994 if ( $wpcommentsjavascript ) { 993 995 if ( empty( $wpcommentspopupfile ) ) 994 996 $home = home_url(); 995 997 else 996 998 $home = get_option('siteurl'); 997 echo$home . '/' . $wpcommentspopupfile . '?comments_popup=' . $id;998 echo'" onclick="wpopen(this.href); return false"';999 $output .= $home . '/' . $wpcommentspopupfile . '?comments_popup=' . $id; 1000 $output .= '" onclick="wpopen(this.href); return false"'; 999 1001 } else { // if comments_popup_script() is not in the template, display simple comment link 1000 1002 if ( 0 == $number ) 1001 echoget_permalink() . '#respond';1003 $output .= get_permalink() . '#respond'; 1002 1004 else 1003 comments_link();1004 echo'"';1005 $output .= get_comments_link(); 1006 $output .= '"'; 1005 1007 } 1006 1008 1007 if ( !empty( $css_class ) ) {1008 echo' class="'.$css_class.'" ';1009 } 1009 if ( !empty( $css_class ) ) 1010 $output .= ' class="'.$css_class.'" '; 1011 1010 1012 $title = the_title_attribute( array('echo' => 0 ) ); 1011 1013 1012 echoapply_filters( 'comments_popup_link_attributes', '' );1014 $output .= apply_filters( 'comments_popup_link_attributes', '' ); 1013 1015 1014 echo ' title="' . esc_attr( sprintf( __('Comment on %s'), $title ) ) . '">'; 1015 comments_number( $zero, $one, $more ); 1016 echo '</a>'; 1016 $output .= ' title="' . esc_attr( sprintf( __('Comment on %s'), $title ) ) . '">'; 1017 $output .= comments_number( $zero, $one, $more, '', false ); 1018 $output .= '</a>'; 1019 1020 return $output; 1017 1021 } 1018 1022 1019 1023 /** 1024 * Displays the link to the comments popup window for the current post ID. 1025 * 1026 * Is not meant to be displayed on single posts and pages. Should be used on the 1027 * lists of posts 1028 * 1029 * @since 0.71 1030 * 1031 * @param bool|string $zero The string to display when no comments 1032 * @param bool|string $one The string to display when only one comment is available 1033 * @param bool|string $more The string to display when there are more than one comment 1034 * @param string $css_class The CSS class to use for comments 1035 * @param bool|string $none The string to display when comments have been turned off 1036 */ 1037 function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) { 1038 echo get_comments_popup_link($zero, $one, $more, $css_class, $none); 1039 } 1040 1041 /** 1020 1042 * Retrieve HTML content for reply to comment link. 1021 1043 * 1022 1044 * The default arguments that can be override are 'add_below', 'respond_id',