WordPress.org

Make WordPress Core

Ticket #17763: 17763.patch

File 17763.patch, 8.6 KB (added by kevdotbadger, 6 years ago)
  • wp-includes/comment-template.php

    From 60b397ba7a9d7f106bfa7edeb58bdd126f133570 Mon Sep 17 00:00:00 2001
    From: kevdotbadger <kevdotbadger@kevins-mbp-2.lan>
    Date: Wed, 24 Dec 2014 00:36:57 +0000
    Subject: [PATCH 1/2] apply patch
    
    ---
     wp-includes/comment-template.php | 91 ++++++++++++++++++++++++++--------------
     1 file changed, 59 insertions(+), 32 deletions(-)
    
    diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php
    index 4e75e7b..3a38542 100644
    a b function get_comments_number( $post_id = 0 ) { 
    755755 * @param string $one        Optional. Text for one comment. Default false.
    756756 * @param string $more       Optional. Text for more than one comment. Default false.
    757757 * @param string $deprecated Not used.
    758  */
    759 function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {
     758 * @param bool   $echo       Whether to echo or just return the string. Default true.
     759*/
     760function comments_number( $zero = false, $one = false, $more = false, $deprecated = '', $echo = true ) {
    760761        if ( ! empty( $deprecated ) ) {
    761762                _deprecated_argument( __FUNCTION__, '1.3' );
    762763        }
    763         echo get_comments_number_text( $zero, $one, $more );
     764
     765        if ( $echo ) {
     766                echo get_comments_number_text( $zero, $one, $more );
     767        } else {
     768                return get_comments_number_text( $zero, $one, $more );
     769        }
    764770}
    765771
    766772/**
    function comments_popup_script( $width = 400, $height = 400, $file = '' ) { 
    12511257}
    12521258
    12531259/**
    1254  * Displays the link to the comments popup window for the current post ID.
     1260 * Retrieves the link to the comments popup window for the current post ID.
    12551261 *
    12561262 * Is not meant to be displayed on single posts and pages. Should be used
    12571263 * on the lists of posts
    function comments_popup_script( $width = 400, $height = 400, $file = '' ) { 
    12591265 * @global string $wpcommentspopupfile  The URL to use for the popup window.
    12601266 * @global int    $wpcommentsjavascript Whether to use JavaScript. Set when function is called.
    12611267 *
    1262  * @since 0.71
     1268 * @since 4.1.0
    12631269 *
    1264  * @param string $zero      Optional. String to display when no comments. Default false.
    1265  * @param string $one       Optional. String to display when only one comment is available.
    1266  *                          Default false.
    1267  * @param string $more      Optional. String to display when there are more than one comment.
    1268  *                          Default false.
    1269  * @param string $css_class Optional. CSS class to use for comments. Default empty.
    1270  * @param string $none      Optional. String to display when comments have been turned off.
    1271  *                          Default false.
    1272  * @return null Returns null on single posts and pages.
     1270 * @param bool|string $zero      Optional. String to display when no comments. Default false.
     1271 * @param bool|string $one       Optional. String to display when only one comment is available.
     1272 *                               Default false.
     1273 * @param bool|string $more      Optional. String to display when there are more than one comment.
     1274 *                               Default false.
     1275 * @param string $css_class      Optional. CSS class to use for comments. Default empty.
     1276 * @param bool|string $none      Optional. String to display when comments have been turned off.
     1277 *                               Default false.
     1278 * @return string
    12731279 */
    1274 function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) {
     1280function get_comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) {
    12751281        global $wpcommentspopupfile, $wpcommentsjavascript;
    12761282
    12771283        $id = get_the_ID();
    function comments_popup_link( $zero = false, $one = false, $more = false, $css_c 
    12831289
    12841290        $number = get_comments_number( $id );
    12851291
    1286         if ( 0 == $number && !comments_open() && !pings_open() ) {
    1287                 echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr( $css_class ) . '"' : '') . '>' . $none . '</span>';
    1288                 return;
     1292        if ( 0 == $number && ! comments_open() && ! pings_open() ) {
     1293                return '<span' . ( ( ! empty( $css_class ) ) ? ' class="' . esc_attr( $css_class ) . '"' : '') . '>' . $none . '</span>';
    12891294        }
    12901295
    12911296        if ( post_password_required() ) {
    function comments_popup_link( $zero = false, $one = false, $more = false, $css_c 
    12931298                return;
    12941299        }
    12951300
    1296         echo '<a href="';
     1301        $output = '';
     1302
     1303        $output .= '<a href="';
    12971304        if ( $wpcommentsjavascript ) {
    12981305                if ( empty( $wpcommentspopupfile ) )
    12991306                        $home = home_url();
    13001307                else
    13011308                        $home = get_option('siteurl');
    1302                 echo $home . '/' . $wpcommentspopupfile . '?comments_popup=' . $id;
    1303                 echo '" onclick="wpopen(this.href); return false"';
     1309                $output .= $home . '/' . $wpcommentspopupfile . '?comments_popup=' . $id;
     1310                $output .= '" onclick="wpopen(this.href); return false"';
    13041311        } else { // if comments_popup_script() is not in the template, display simple comment link
    1305                 if ( 0 == $number )
    1306                         echo get_permalink() . '#respond';
    1307                 else
    1308                         comments_link();
    1309                 echo '"';
     1312                if ( 0 == $number ) {
     1313                        $output .= get_permalink() . '#respond';
     1314                } else {
     1315                        $output .= get_comments_link();
     1316                        $output .= '"';
     1317                }
    13101318        }
    13111319
    1312         if ( !empty( $css_class ) ) {
    1313                 echo ' class="'.$css_class.'" ';
     1320        if ( ! empty( $css_class ) ) {
     1321                $output .= ' class="'.$css_class.'" ';
    13141322        }
    13151323        $title = the_title_attribute( array('echo' => 0 ) );
    13161324
    function comments_popup_link( $zero = false, $one = false, $more = false, $css_c 
    13221330         *
    13231331         * @param string $attributes The comments popup link attributes. Default empty.
    13241332         */
    1325         echo apply_filters( 'comments_popup_link_attributes', $attributes );
     1333        $output .= apply_filters( 'comments_popup_link_attributes', $attributes );
     1334
     1335        $output .= ' title="' . esc_attr( sprintf( __('Comment on %s'), $title ) ) . '">';
     1336        $output .= get_comments_number_text( $zero, $one, $more, '', false );
     1337        $output .= '</a>';
     1338        return $output;
     1339}
    13261340
    1327         echo ' title="' . esc_attr( sprintf( __('Comment on %s'), $title ) ) . '">';
    1328         comments_number( $zero, $one, $more );
    1329         echo '</a>';
     1341/**
     1342 * Displays the link to the comments popup window for the current post ID.
     1343 *
     1344 * Is not meant to be displayed on single posts and pages. Should be used on the
     1345 * lists of posts.
     1346 *
     1347 * @since 0.71
     1348 *
     1349 * @param bool|string $zero        The string to display when no comments.
     1350 * @param bool|string $one         The string to display when only one comment is available.
     1351 * @param bool|string $more        The string to display when there are more than one comment.
     1352 * @param string      $css_class   The CSS class to use for comments.
     1353 * @param bool|string $none        The string to display when comments have been turned off.
     1354 */
     1355function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) {
     1356        echo get_comments_popup_link($zero, $one, $more, $css_class, $none);
    13301357}
    13311358
    13321359/**
  • wp-includes/comment-template.php

    -- 
    1.9.3 (Apple Git-50)
    
    
    From ec0d43c761320a424bb662b98b770259d75c044f Mon Sep 17 00:00:00 2001
    From: kevdotbadger <kevdotbadger@kevins-mbp-2.lan>
    Date: Wed, 24 Dec 2014 00:44:33 +0000
    Subject: [PATCH 2/2] clean up indentation, added toscho's feedback.
    
    ---
     wp-includes/comment-template.php | 8 +++-----
     1 file changed, 3 insertions(+), 5 deletions(-)
    
    diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php
    index 3a38542..bd5f243 100644
    a b function comments_popup_script( $width = 400, $height = 400, $file = '' ) { 
    12651265 * @global string $wpcommentspopupfile  The URL to use for the popup window.
    12661266 * @global int    $wpcommentsjavascript Whether to use JavaScript. Set when function is called.
    12671267 *
    1268  * @since 4.1.0
     1268 * @since 4.2.0
    12691269 *
    12701270 * @param bool|string $zero      Optional. String to display when no comments. Default false.
    12711271 * @param bool|string $one       Optional. String to display when only one comment is available.
    function get_comments_popup_link( $zero = false, $one = false, $more = false, $c 
    12901290        $number = get_comments_number( $id );
    12911291
    12921292        if ( 0 == $number && ! comments_open() && ! pings_open() ) {
    1293                 return '<span' . ( ( ! empty( $css_class ) ) ? ' class="' . esc_attr( $css_class ) . '"' : '') . '>' . $none . '</span>';
     1293                return '<span' . ( ( ! empty( $css_class ) ) ? ' class="' . esc_attr( $css_class ) . '"' : '') . '>' . $none . '</span>';
    12941294        }
    12951295
    12961296        if ( post_password_required() ) {
    function get_comments_popup_link( $zero = false, $one = false, $more = false, $c 
    12981298                return;
    12991299        }
    13001300
    1301         $output = '';
    1302 
    1303         $output .= '<a href="';
     1301        $output = '<a href="';
    13041302        if ( $wpcommentsjavascript ) {
    13051303                if ( empty( $wpcommentspopupfile ) )
    13061304                        $home = home_url();