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 ) { |
755 | 755 | * @param string $one Optional. Text for one comment. Default false. |
756 | 756 | * @param string $more Optional. Text for more than one comment. Default false. |
757 | 757 | * @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 | */ |
| 760 | function comments_number( $zero = false, $one = false, $more = false, $deprecated = '', $echo = true ) { |
760 | 761 | if ( ! empty( $deprecated ) ) { |
761 | 762 | _deprecated_argument( __FUNCTION__, '1.3' ); |
762 | 763 | } |
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 | } |
764 | 770 | } |
765 | 771 | |
766 | 772 | /** |
… |
… |
function comments_popup_script( $width = 400, $height = 400, $file = '' ) { |
1251 | 1257 | } |
1252 | 1258 | |
1253 | 1259 | /** |
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. |
1255 | 1261 | * |
1256 | 1262 | * Is not meant to be displayed on single posts and pages. Should be used |
1257 | 1263 | * on the lists of posts |
… |
… |
function comments_popup_script( $width = 400, $height = 400, $file = '' ) { |
1259 | 1265 | * @global string $wpcommentspopupfile The URL to use for the popup window. |
1260 | 1266 | * @global int $wpcommentsjavascript Whether to use JavaScript. Set when function is called. |
1261 | 1267 | * |
1262 | | * @since 0.71 |
| 1268 | * @since 4.1.0 |
1263 | 1269 | * |
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 |
1273 | 1279 | */ |
1274 | | function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) { |
| 1280 | function get_comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) { |
1275 | 1281 | global $wpcommentspopupfile, $wpcommentsjavascript; |
1276 | 1282 | |
1277 | 1283 | $id = get_the_ID(); |
… |
… |
function comments_popup_link( $zero = false, $one = false, $more = false, $css_c |
1283 | 1289 | |
1284 | 1290 | $number = get_comments_number( $id ); |
1285 | 1291 | |
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>'; |
1289 | 1294 | } |
1290 | 1295 | |
1291 | 1296 | if ( post_password_required() ) { |
… |
… |
function comments_popup_link( $zero = false, $one = false, $more = false, $css_c |
1293 | 1298 | return; |
1294 | 1299 | } |
1295 | 1300 | |
1296 | | echo '<a href="'; |
| 1301 | $output = ''; |
| 1302 | |
| 1303 | $output .= '<a href="'; |
1297 | 1304 | if ( $wpcommentsjavascript ) { |
1298 | 1305 | if ( empty( $wpcommentspopupfile ) ) |
1299 | 1306 | $home = home_url(); |
1300 | 1307 | else |
1301 | 1308 | $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"'; |
1304 | 1311 | } 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 | } |
1310 | 1318 | } |
1311 | 1319 | |
1312 | | if ( !empty( $css_class ) ) { |
1313 | | echo ' class="'.$css_class.'" '; |
| 1320 | if ( ! empty( $css_class ) ) { |
| 1321 | $output .= ' class="'.$css_class.'" '; |
1314 | 1322 | } |
1315 | 1323 | $title = the_title_attribute( array('echo' => 0 ) ); |
1316 | 1324 | |
… |
… |
function comments_popup_link( $zero = false, $one = false, $more = false, $css_c |
1322 | 1330 | * |
1323 | 1331 | * @param string $attributes The comments popup link attributes. Default empty. |
1324 | 1332 | */ |
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 | } |
1326 | 1340 | |
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 | */ |
| 1355 | function 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); |
1330 | 1357 | } |
1331 | 1358 | |
1332 | 1359 | /** |
--
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 = '' ) { |
1265 | 1265 | * @global string $wpcommentspopupfile The URL to use for the popup window. |
1266 | 1266 | * @global int $wpcommentsjavascript Whether to use JavaScript. Set when function is called. |
1267 | 1267 | * |
1268 | | * @since 4.1.0 |
| 1268 | * @since 4.2.0 |
1269 | 1269 | * |
1270 | 1270 | * @param bool|string $zero Optional. String to display when no comments. Default false. |
1271 | 1271 | * @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 |
1290 | 1290 | $number = get_comments_number( $id ); |
1291 | 1291 | |
1292 | 1292 | 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>'; |
1294 | 1294 | } |
1295 | 1295 | |
1296 | 1296 | if ( post_password_required() ) { |
… |
… |
function get_comments_popup_link( $zero = false, $one = false, $more = false, $c |
1298 | 1298 | return; |
1299 | 1299 | } |
1300 | 1300 | |
1301 | | $output = ''; |
1302 | | |
1303 | | $output .= '<a href="'; |
| 1301 | $output = '<a href="'; |
1304 | 1302 | if ( $wpcommentsjavascript ) { |
1305 | 1303 | if ( empty( $wpcommentspopupfile ) ) |
1306 | 1304 | $home = home_url(); |