Ticket #17763: 17763.5.diff
File 17763.5.diff, 6.1 KB (added by , 10 years ago) |
---|
-
src/wp-includes/comment-template.php
711 711 * @param string $one Optional. Text for one comment. Default false. 712 712 * @param string $more Optional. Text for more than one comment. Default false. 713 713 * @param string $deprecated Not used. 714 */ 715 function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) { 714 * @param bool $echo Whether to echo or just return the string. Default true. 715 */ 716 function comments_number( $zero = false, $one = false, $more = false, $deprecated = '', $echo = true ) { 716 717 if ( ! empty( $deprecated ) ) { 717 718 _deprecated_argument( __FUNCTION__, '1.3' ); 718 719 } 719 echo get_comments_number_text( $zero, $one, $more ); 720 721 if ( $echo ) { 722 echo get_comments_number_text( $zero, $one, $more ); 723 } else { 724 return get_comments_number_text( $zero, $one, $more ); 725 } 720 726 } 721 727 722 728 /** … … 1204 1204 } 1205 1205 1206 1206 /** 1207 * Displays the link to the comments popup window for the current post ID.1207 * Retrieves the link to the comments popup window for the current post ID. 1208 1208 * 1209 1209 * Is not meant to be displayed on single posts and pages. Should be used 1210 1210 * on the lists of posts … … 1212 1212 * @global string $wpcommentspopupfile The URL to use for the popup window. 1213 1213 * @global int $wpcommentsjavascript Whether to use JavaScript. Set when function is called. 1214 1214 * 1215 * @since 0.711215 * @since 4.1.0 1216 1216 * 1217 * @param string $zero Optional. String to display when no comments. Default false.1218 * @param string $one Optional. String to display when only one comment is available.1219 * Default false.1220 * @param string $more Optional. String to display when there are more than one comment.1221 * Default false.1222 * @param string $css_class Optional. CSS class to use for comments. Default empty.1223 * @param string $none Optional. String to display when comments have been turned off.1224 * Default false.1225 * @return null Returns null on single posts and pages.1217 * @param bool|string $zero Optional. String to display when no comments. Default false. 1218 * @param bool|string $one Optional. String to display when only one comment is available. 1219 * Default false. 1220 * @param bool|string $more Optional. String to display when there are more than one comment. 1221 * Default false. 1222 * @param string $css_class Optional. CSS class to use for comments. Default empty. 1223 * @param bool|string $none Optional. String to display when comments have been turned off. 1224 * Default false. 1225 * @return string 1226 1226 */ 1227 function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) {1227 function get_comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) { 1228 1228 global $wpcommentspopupfile, $wpcommentsjavascript; 1229 1229 1230 1230 $id = get_the_ID(); … … 1236 1236 1237 1237 $number = get_comments_number( $id ); 1238 1238 1239 if ( 0 == $number && !comments_open() && !pings_open() ) { 1240 echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr( $css_class ) . '"' : '') . '>' . $none . '</span>'; 1241 return; 1239 if ( 0 == $number && ! comments_open() && ! pings_open() ) { 1240 return '<span' . ( ( ! empty( $css_class ) ) ? ' class="' . esc_attr( $css_class ) . '"' : '') . '>' . $none . '</span>'; 1242 1241 } 1243 1242 1244 1243 if ( post_password_required() ) { … … 1246 1245 return; 1247 1246 } 1248 1247 1249 echo '<a href="'; 1248 $output = ''; 1249 1250 $output .= '<a href="'; 1250 1251 if ( $wpcommentsjavascript ) { 1251 1252 if ( empty( $wpcommentspopupfile ) ) 1252 1253 $home = home_url(); 1253 1254 else 1254 1255 $home = get_option('siteurl'); 1255 echo$home . '/' . $wpcommentspopupfile . '?comments_popup=' . $id;1256 echo'" onclick="wpopen(this.href); return false"';1256 $output .= $home . '/' . $wpcommentspopupfile . '?comments_popup=' . $id; 1257 $output .= '" onclick="wpopen(this.href); return false"'; 1257 1258 } else { // if comments_popup_script() is not in the template, display simple comment link 1258 if ( 0 == $number ) 1259 echo get_permalink() . '#respond'; 1260 else 1261 comments_link(); 1262 echo '"'; 1259 if ( 0 == $number ) { 1260 $output .= get_permalink() . '#respond'; 1261 } else { 1262 $output .= get_comments_link(); 1263 $output .= '"'; 1264 } 1263 1265 } 1264 1266 1265 if ( ! empty( $css_class ) ) {1266 echo' class="'.$css_class.'" ';1267 if ( ! empty( $css_class ) ) { 1268 $output .= ' class="'.$css_class.'" '; 1267 1269 } 1268 1270 $title = the_title_attribute( array('echo' => 0 ) ); 1269 1271 … … 1275 1277 * 1276 1278 * @param string $attributes The comments popup link attributes. Default empty. 1277 1279 */ 1278 echoapply_filters( 'comments_popup_link_attributes', $attributes );1280 $output .= apply_filters( 'comments_popup_link_attributes', $attributes ); 1279 1281 1280 echo ' title="' . esc_attr( sprintf( __('Comment on %s'), $title ) ) . '">'; 1281 comments_number( $zero, $one, $more ); 1282 echo '</a>'; 1282 $output .= ' title="' . esc_attr( sprintf( __('Comment on %s'), $title ) ) . '">'; 1283 $output .= get_comments_number_text( $zero, $one, $more, '', false ); 1284 $output .= '</a>'; 1285 return $output; 1283 1286 } 1284 1287 1285 1288 /** 1289 * Displays the link to the comments popup window for the current post ID. 1290 * 1291 * Is not meant to be displayed on single posts and pages. Should be used on the 1292 * lists of posts. 1293 * 1294 * @since 0.71 1295 * 1296 * @param bool|string $zero The string to display when no comments. 1297 * @param bool|string $one The string to display when only one comment is available. 1298 * @param bool|string $more The string to display when there are more than one comment. 1299 * @param string $css_class The CSS class to use for comments. 1300 * @param bool|string $none The string to display when comments have been turned off. 1301 */ 1302 function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) { 1303 echo get_comments_popup_link($zero, $one, $more, $css_class, $none); 1304 } 1305 1306 /** 1286 1307 * Retrieve HTML content for reply to comment link. 1287 1308 * 1288 1309 * @since 2.7.0