WordPress.org

Make WordPress Core

Ticket #17763: 17763.diff

File 17763.diff, 5.4 KB (added by kawauso, 4 years ago)
  • wp-includes/comment-template.php

     
    569569 * @param string $one Text for one comment 
    570570 * @param string $more Text for more than one comment 
    571571 * @param string $deprecated Not used. 
     572 * @param bool $echo Whether to echo or just return the string 
    572573 */ 
    573 function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) { 
     574function comments_number( $zero = false, $one = false, $more = false, $deprecated = '', $echo = true ) { 
    574575        if ( !empty( $deprecated ) ) 
    575576                _deprecated_argument( __FUNCTION__, '1.3' ); 
    576577 
     
    583584        else // must be one 
    584585                $output = ( false === $one ) ? __('1 Comment') : $one; 
    585586 
    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); 
    587591} 
    588592 
    589593/** 
     
    949953} 
    950954 
    951955/** 
    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. 
    953957 * 
    954958 * Is not meant to be displayed on single posts and pages. Should be used on the 
    955959 * lists of posts 
    956960 * 
    957  * @since 0.71 
     961 * @since 3.3.0 
    958962 * @uses $wpcommentspopupfile 
    959963 * @uses $wpcommentsjavascript 
    960964 * @uses $post 
    961965 * 
    962  * @param string $zero The string to display when no comments 
    963  * @param string $one The string to display when only one comment is available 
    964  * @param string $more The string to display when there are more than one comment 
     966 * @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 
    965969 * @param string $css_class The CSS class to use for comments 
    966  * @param string $none The string to display when comments have been turned off 
    967  * @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 
    968972 */ 
    969 function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) { 
     973function get_comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) { 
    970974        global $wpcommentspopupfile, $wpcommentsjavascript; 
    971975 
    972976        $id = get_the_ID(); 
     
    978982 
    979983        $number = get_comments_number( $id ); 
    980984 
    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>'; 
    985987 
    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.'); 
    990990 
    991         echo '<a href="'; 
     991        $output = ''; 
     992 
     993        $output .= '<a href="'; 
    992994        if ( $wpcommentsjavascript ) { 
    993995                if ( empty( $wpcommentspopupfile ) ) 
    994996                        $home = home_url(); 
    995997                else 
    996998                        $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"'; 
    9991001        } else { // if comments_popup_script() is not in the template, display simple comment link 
    10001002                if ( 0 == $number ) 
    1001                         echo get_permalink() . '#respond'; 
     1003                        $output .= get_permalink() . '#respond'; 
    10021004                else 
    1003                         comments_link(); 
    1004                 echo '"'; 
     1005                        $output .= get_comments_link(); 
     1006                $output .= '"'; 
    10051007        } 
    10061008 
    1007         if ( !empty( $css_class ) ) { 
    1008                 echo ' class="'.$css_class.'" '; 
    1009         } 
     1009        if ( !empty( $css_class ) ) 
     1010                $output .= ' class="'.$css_class.'" '; 
     1011 
    10101012        $title = the_title_attribute( array('echo' => 0 ) ); 
    10111013 
    1012         echo apply_filters( 'comments_popup_link_attributes', '' ); 
     1014        $output .= apply_filters( 'comments_popup_link_attributes', '' ); 
    10131015 
    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; 
    10171021} 
    10181022 
    10191023/** 
     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 */ 
     1037function 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/** 
    10201042 * Retrieve HTML content for reply to comment link. 
    10211043 * 
    10221044 * The default arguments that can be override are 'add_below', 'respond_id',