Changeset 47888
- Timestamp:
- 06/02/2020 08:24:59 PM (5 years ago)
- Location:
- branches/5.4
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.4/src/wp-comments-post.php
r47198 r47888 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( -
branches/5.4/src/wp-includes/class-walker-comment.php
r46391 r47888 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 --> -
branches/5.4/src/wp-includes/class-wp-comment-query.php
r47219 r47888 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 } -
branches/5.4/src/wp-includes/class-wp.php
r47122 r47888 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'] ) ) { -
branches/5.4/src/wp-includes/comment.php
r47397 r47888 1838 1838 1839 1839 if ( $comment && hash_equals( $_GET['moderation-hash'], wp_hash( $comment->comment_date_gmt ) ) ) { 1840 $commenter_email = $comment->comment_author_email; 1840 // The comment will only be viewable by the comment author for 1 minute. 1841 $comment_preview_expires = strtotime( $comment->comment_date_gmt . '+1 minute' ); 1842 1843 if ( time() < $comment_preview_expires ) { 1844 $commenter_email = $comment->comment_author_email; 1845 } 1841 1846 } 1842 1847 } -
branches/5.4/tests/qunit/fixtures/wp-api-generated.js
r47822 r47888 79 79 "args": { 80 80 "url": { 81 "required": true, 82 "description": "The URL of the resource for which to fetch oEmbed data.", 83 "type": "string" 81 "required": true 84 82 }, 85 83 "format": { … … 4398 4396 "namespace": "wp/v2", 4399 4397 "methods": [ 4400 "GET", 4401 "POST" 4398 "GET" 4402 4399 ], 4403 4400 "endpoints": [ 4404 4401 { 4405 4402 "methods": [ 4406 "GET", 4407 "POST" 4403 "GET" 4408 4404 ], 4409 4405 "args": { … … 4440 4436 "namespace": "wp/v2", 4441 4437 "methods": [ 4442 "GET", 4443 "POST" 4438 "GET" 4444 4439 ], 4445 4440 "endpoints": [ 4446 4441 { 4447 4442 "methods": [ 4448 "GET", 4449 "POST" 4443 "GET" 4450 4444 ], 4451 4445 "args": { … … 4482 4476 "namespace": "wp/v2", 4483 4477 "methods": [ 4484 "GET", 4485 "POST" 4478 "GET" 4486 4479 ], 4487 4480 "endpoints": [ 4488 4481 { 4489 4482 "methods": [ 4490 "GET", 4491 "POST" 4483 "GET" 4492 4484 ], 4493 4485 "args": { … … 4524 4516 "namespace": "wp/v2", 4525 4517 "methods": [ 4526 "GET", 4527 "POST" 4518 "GET" 4528 4519 ], 4529 4520 "endpoints": [ 4530 4521 { 4531 4522 "methods": [ 4532 "GET", 4533 "POST" 4523 "GET" 4534 4524 ], 4535 4525 "args": { … … 4566 4556 "namespace": "wp/v2", 4567 4557 "methods": [ 4568 "GET", 4569 "POST" 4558 "GET" 4570 4559 ], 4571 4560 "endpoints": [ 4572 4561 { 4573 4562 "methods": [ 4574 "GET", 4575 "POST" 4563 "GET" 4576 4564 ], 4577 4565 "args": { … … 4608 4596 "namespace": "wp/v2", 4609 4597 "methods": [ 4610 "GET", 4611 "POST" 4598 "GET" 4612 4599 ], 4613 4600 "endpoints": [ 4614 4601 { 4615 4602 "methods": [ 4616 "GET", 4617 "POST" 4603 "GET" 4618 4604 ], 4619 4605 "args": { … … 4650 4636 "namespace": "wp/v2", 4651 4637 "methods": [ 4652 "GET", 4653 "POST" 4638 "GET" 4654 4639 ], 4655 4640 "endpoints": [ 4656 4641 { 4657 4642 "methods": [ 4658 "GET", 4659 "POST" 4643 "GET" 4660 4644 ], 4661 4645 "args": { … … 4692 4676 "namespace": "wp/v2", 4693 4677 "methods": [ 4694 "GET", 4695 "POST" 4678 "GET" 4696 4679 ], 4697 4680 "endpoints": [ 4698 4681 { 4699 4682 "methods": [ 4700 "GET", 4701 "POST" 4683 "GET" 4702 4684 ], 4703 4685 "args": { … … 4734 4716 "namespace": "wp/v2", 4735 4717 "methods": [ 4736 "GET", 4737 "POST" 4718 "GET" 4738 4719 ], 4739 4720 "endpoints": [ 4740 4721 { 4741 4722 "methods": [ 4742 "GET", 4743 "POST" 4723 "GET" 4744 4724 ], 4745 4725 "args": { … … 4776 4756 "namespace": "wp/v2", 4777 4757 "methods": [ 4778 "GET", 4779 "POST" 4758 "GET" 4780 4759 ], 4781 4760 "endpoints": [ 4782 4761 { 4783 4762 "methods": [ 4784 "GET", 4785 "POST" 4763 "GET" 4786 4764 ], 4787 4765 "args": { … … 4818 4796 "namespace": "wp/v2", 4819 4797 "methods": [ 4820 "GET", 4821 "POST" 4798 "GET" 4822 4799 ], 4823 4800 "endpoints": [ 4824 4801 { 4825 4802 "methods": [ 4826 "GET", 4827 "POST" 4803 "GET" 4828 4804 ], 4829 4805 "args": { … … 5064 5040 "args": { 5065 5041 "url": { 5066 "required": true, 5067 "description": "The URL of the resource for which to fetch oEmbed data.", 5068 "type": "string" 5042 "required": true 5069 5043 }, 5070 5044 "format": {
Note: See TracChangeset
for help on using the changeset viewer.