Changeset 47887
- Timestamp:
- 06/02/2020 08:10:02 PM (5 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-comments-post.php
r47198 r47887 57 57 $location = empty( $_POST['redirect_to'] ) ? get_comment_link( $comment ) : $_POST['redirect_to'] . '#comment-' . $comment->comment_ID; 58 58 59 // Add specific query arguments to display the awaiting moderation message.60 if ( 'unapproved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_author_email ) ) {59 // If user didn't consent to cookies, add specific query arguments to display the awaiting moderation message. 60 if ( ! $cookies_consent && 'unapproved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_author_email ) ) { 61 61 $location = add_query_arg( 62 62 array( -
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 --> -
trunk/src/wp-includes/class-wp-comment-query.php
r47808 r47887 554 554 if ( is_numeric( $unapproved_identifier ) ) { 555 555 $approved_clauses[] = $wpdb->prepare( "( user_id = %d AND comment_approved = '0' )", $unapproved_identifier ); 556 556 } else { 557 557 // Otherwise we match against email addresses. 558 } else { 559 $approved_clauses[] = $wpdb->prepare( "( comment_author_email = %s AND comment_approved = '0' )", $unapproved_identifier ); 558 if ( ! empty( $_GET['unapproved'] ) && ! empty( $_GET['moderation-hash'] ) ) { 559 // Only include requested comment. 560 $approved_clauses[] = $wpdb->prepare( "( comment_author_email = %s AND comment_approved = '0' AND comment_ID = %d )", $unapproved_identifier, (int) $_GET['unapproved'] ); 561 } else { 562 // Include all of the author's unapproved comments. 563 $approved_clauses[] = $wpdb->prepare( "( comment_author_email = %s AND comment_approved = '0' )", $unapproved_identifier ); 564 } 560 565 } 561 566 } -
trunk/src/wp-includes/class-wp.php
r47855 r47887 405 405 if ( is_user_logged_in() ) { 406 406 $headers = array_merge( $headers, wp_get_nocache_headers() ); 407 } elseif ( ! empty( $_GET['unapproved'] ) && ! empty( $_GET['moderation-hash'] ) ) { 408 // Unmoderated comments are only visible for one minute via the moderation hash. 409 $headers['Expires'] = gmdate( 'D, d M Y H:i:s', time() + MINUTE_IN_SECONDS ); 410 $headers['Cache-Control'] = 'max-age=60, must-revalidate'; 407 411 } 408 412 if ( ! empty( $this->query_vars['error'] ) ) { -
trunk/src/wp-includes/comment.php
r47808 r47887 1853 1853 1854 1854 if ( $comment && hash_equals( $_GET['moderation-hash'], wp_hash( $comment->comment_date_gmt ) ) ) { 1855 $commenter_email = $comment->comment_author_email; 1855 // The comment will only be viewable by the comment author for 1 minute. 1856 $comment_preview_expires = strtotime( $comment->comment_date_gmt . '+1 minute' ); 1857 1858 if ( time() < $comment_preview_expires ) { 1859 $commenter_email = $comment->comment_author_email; 1860 } 1856 1861 } 1857 1862 }
Note: See TracChangeset
for help on using the changeset viewer.