Changeset 47887 for trunk/src/wp-includes/class-walker-comment.php
- Timestamp:
- 06/02/2020 08:10:02 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-walker-comment.php
r47808 r47887 180 180 $output .= ob_get_clean(); 181 181 return; 182 } 183 184 if ( 'comment' === $comment->comment_type ) { 185 add_filter( 'comment_text', array( $this, 'comment_text' ), 40, 2 ); 182 186 } 183 187 … … 195 199 $output .= ob_get_clean(); 196 200 } 201 202 if ( 'comment' === $comment->comment_type ) { 203 remove_filter( 'comment_text', array( $this, 'comment_text' ), 40, 2 ); 204 } 197 205 } 198 206 … … 246 254 247 255 /** 256 * Remove links from the pending comment's text if the commenter has not consent to the comment cookie. 257 * 258 * @since 5.4.2 259 * 260 * @param string $comment_text Text of the current comment. 261 * @param WP_Comment|null $comment The comment object. 262 * @return string Text of the current comment. 263 */ 264 function comment_text( $comment_text, $comment ) { 265 $commenter = wp_get_current_commenter(); 266 $show_pending_links = ! empty( $commenter['comment_author'] ); 267 268 if ( '0' == $comment->comment_approved && ! $show_pending_links ) { 269 return wp_kses( $comment_text, array() ); 270 } 271 272 return $comment_text; 273 } 274 275 /** 248 276 * Outputs a single comment. 249 277 * … … 265 293 } 266 294 267 $commenter = wp_get_current_commenter(); 295 $commenter = wp_get_current_commenter(); 296 $show_pending_links = isset( $commenter['comment_author'] ) && $commenter['comment_author']; 268 297 if ( $commenter['comment_author_email'] ) { 269 298 $moderation_note = __( 'Your comment is awaiting moderation.' ); … … 280 309 <?php 281 310 if ( 0 != $args['avatar_size'] ) { 282 echo get_avatar( $comment, $args['avatar_size'] );} 311 echo get_avatar( $comment, $args['avatar_size'] ); 312 } 283 313 ?> 284 314 <?php 285 printf( 286 /* translators: %s: Comment author link. */ 287 __( '%s <span class="says">says:</span>' ), 288 sprintf( '<cite class="fn">%s</cite>', get_comment_author_link( $comment ) ) 289 ); 315 $comment_author = get_comment_author_link( $comment ); 316 if ( '0' == $comment->comment_approved && ! $show_pending_links ) { 317 $comment_author = get_comment_author( $comment ); 318 } 319 printf( 320 /* translators: %s: Comment author link. */ 321 __( '%s <span class="says">says:</span>' ), 322 sprintf( '<cite class="fn">%s</cite>', $comment_author ) 323 ); 290 324 ?> 291 325 </div> … … 355 389 $tag = ( 'div' === $args['style'] ) ? 'div' : 'li'; 356 390 357 $commenter = wp_get_current_commenter(); 391 $commenter = wp_get_current_commenter(); 392 $show_pending_links = ! empty( $commenter['comment_author'] ); 358 393 if ( $commenter['comment_author_email'] ) { 359 394 $moderation_note = __( 'Your comment is awaiting moderation.' ); … … 373 408 ?> 374 409 <?php 375 printf( 376 /* translators: %s: Comment author link. */ 377 __( '%s <span class="says">says:</span>' ), 378 sprintf( '<b class="fn">%s</b>', get_comment_author_link( $comment ) ) 379 ); 410 $comment_author = get_comment_author_link( $comment ); 411 if ( '0' == $comment->comment_approved && ! $show_pending_links ) { 412 $comment_author = get_comment_author( $comment ); 413 } 414 printf( 415 /* translators: %s: Comment author link. */ 416 __( '%s <span class="says">says:</span>' ), 417 sprintf( '<b class="fn">%s</b>', $comment_author ) 418 ); 380 419 ?> 381 420 </div><!-- .comment-author --> … … 403 442 404 443 <?php 405 comment_reply_link( 406 array_merge( 407 $args, 408 array( 409 'add_below' => 'div-comment', 410 'depth' => $depth, 411 'max_depth' => $args['max_depth'], 412 'before' => '<div class="reply">', 413 'after' => '</div>', 444 if ( '1' == $comment->comment_approved || $show_pending_links ) { 445 comment_reply_link( 446 array_merge( 447 $args, 448 array( 449 'add_below' => 'div-comment', 450 'depth' => $depth, 451 'max_depth' => $args['max_depth'], 452 'before' => '<div class="reply">', 453 'after' => '</div>', 454 ) 414 455 ) 415 ) 416 );456 ); 457 } 417 458 ?> 418 459 </article><!-- .comment-body -->
Note: See TracChangeset
for help on using the changeset viewer.