Ticket #33717: 33717.11.diff
| File 33717.11.diff, 17.5 KB (added by , 7 years ago) |
|---|
-
src/wp-admin/css/dashboard.css
diff --git src/wp-admin/css/dashboard.css src/wp-admin/css/dashboard.css index eac01008e8..78e75f53e0 100644
body #dashboard-widgets .postbox form .submit { 816 816 position: relative; 817 817 } 818 818 819 #activity-widget #the-comment-list .comment-item .attention { 820 display: none; 821 color: #d54e21; 822 font-size: 90%; 823 } 824 819 825 #activity-widget #the-comment-list .avatar { 820 826 position: absolute; 821 827 top: 12px; … … body #dashboard-widgets .postbox form .submit { 852 858 width: 4px; 853 859 } 854 860 861 #activity-widget #the-comment-list .unapproved .attention { 862 display: block; 863 } 864 855 865 #activity-widget #the-comment-list .spam-undo-inside .avatar, 856 866 #activity-widget #the-comment-list .trash-undo-inside .avatar { 857 867 position: relative; -
src/wp-admin/css/list-tables.css
diff --git src/wp-admin/css/list-tables.css src/wp-admin/css/list-tables.css index 4e4f75aba5..1aa0b063c6 100644
224 224 background-color: #f5f5f5; 225 225 } 226 226 227 #the-comment-list .comment .attention { 228 display: none; 229 color: #d54e21; 230 font-size: 90%; 231 } 232 227 233 #the-comment-list .unapproved th, 228 234 #the-comment-list .unapproved td { 229 235 background-color: #fef7f1; … … 237 243 margin-left: 4px; 238 244 } 239 245 246 #the-comment-list .comment.unapproved .attention { 247 display: block; 248 } 249 240 250 #the-comment-list .approve a { 241 251 color: #006505; 242 252 } -
src/wp-admin/includes/class-wp-comments-list-table.php
diff --git src/wp-admin/includes/class-wp-comments-list-table.php src/wp-admin/includes/class-wp-comments-list-table.php index 1020aab127..3e95dc9dad 100644
class WP_Comments_List_Table extends WP_List_Table { 797 797 } 798 798 } 799 799 800 if ( 0 === (int) $comment->comment_approved && true === (bool) get_comment_meta( $comment->comment_ID, '_wp_comment_author_notification_optin', true ) ) { 801 /* translators: %s is the comment author name. */ 802 echo '<p class="attention"><span class="dashicons dashicons-info"></span> ' . sprintf( esc_html__( '%s has opted in to receive a notification on comment\'s approval.' ), get_comment_author( $comment ) ) . '</p>'; 803 } 804 800 805 comment_text( $comment ); 801 806 802 807 if ( $this->user_can ) { -
src/wp-admin/includes/dashboard.php
diff --git src/wp-admin/includes/dashboard.php src/wp-admin/includes/dashboard.php index 569f078243..78e31caf62 100644
function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) { 787 787 } 788 788 ?> 789 789 </p> 790 791 790 <?php 791 if ( 0 === (int) $comment->comment_approved && true === (bool) get_comment_meta( $comment->comment_ID, '_wp_comment_author_notification_optin', true ) ) : 792 ?> 793 <?php /* translators: %s is the comment author name. */ ?> 794 <p class="attention"> 795 <span class="dashicons dashicons-info"></span> 796 <?php printf( esc_html__( '%s has opted in to receive a notification on comment\'s approval.' ), get_comment_author( $comment ) ); ?> 797 </p> 798 <?php 799 endif; 800 792 801 else : 793 802 switch ( $comment->comment_type ) { 794 803 case 'pingback': -
src/wp-comments-post.php
diff --git src/wp-comments-post.php src/wp-comments-post.php index fe03cb7296..8342c3b6f6 100644
require( dirname( __FILE__ ) . '/wp-load.php' ); 22 22 23 23 nocache_headers(); 24 24 25 $comment = wp_handle_comment_submission( wp_unslash( $_POST ) ); 26 if ( is_wp_error( $comment ) ) { 27 $data = intval( $comment->get_error_data() ); 28 if ( ! empty( $data ) ) { 25 if ( isset( $_POST['wp-comment-approved-notification-optin'], $_POST['comment_ID'], $_POST['moderation-hash'] ) ) { 26 $comment = get_comment( $_POST['comment_ID'] ); 27 28 if ( ! is_null( $comment->comment_ID ) && hash_equals( $_POST['moderation-hash'], wp_hash( $comment->comment_date_gmt ) ) ) { 29 update_comment_meta( $comment->comment_ID, '_wp_comment_author_notification_optin', true ); 30 } else { 29 31 wp_die( 30 '<p>' . $comment->get_error_message() . '</p>',31 __( 'Comment Submission Failure' ),32 '<p>' . __( 'Sorry we haven\'t found your comment.' ) . '</p>', 33 __( 'Comment Notification opt-in failure' ), 32 34 array( 33 'response' => $data,34 35 'back_link' => true, 35 36 ) 36 37 ); 37 } else {38 exit;39 38 } 40 } 39 } else { 40 $comment = wp_handle_comment_submission( wp_unslash( $_POST ) ); 41 if ( is_wp_error( $comment ) ) { 42 $data = intval( $comment->get_error_data() ); 43 if ( ! empty( $data ) ) { 44 wp_die( 45 '<p>' . $comment->get_error_message() . '</p>', 46 __( 'Comment Submission Failure' ), 47 array( 48 'response' => $data, 49 'back_link' => true, 50 ) 51 ); 52 } else { 53 exit; 54 } 55 } 41 56 42 $user = wp_get_current_user();43 $cookies_consent = ( isset( $_POST['wp-comment-cookies-consent'] ) );57 $user = wp_get_current_user(); 58 $cookies_consent = ( isset( $_POST['wp-comment-cookies-consent'] ) ); 44 59 45 /** 46 * Perform other actions when comment cookies are set. 47 * 48 * @since 3.4.0 49 * @since 4.9.6 The `$cookies_consent` parameter was added. 50 * 51 * @param WP_Comment $comment Comment object. 52 * @param WP_User $user Comment author's user object. The user may not exist. 53 * @param boolean $cookies_consent Comment author's consent to store cookies. 54 */ 55 do_action( 'set_comment_cookies', $comment, $user, $cookies_consent ); 60 /** 61 * Perform other actions when comment cookies are set. 62 * 63 * @since 3.4.0 64 * @since 4.9.6 The `$cookies_consent` parameter was added. 65 * 66 * @param WP_Comment $comment Comment object. 67 * @param WP_User $user Comment author's user object. The user may not exist. 68 * @param boolean $cookies_consent Comment author's consent to store cookies. 69 */ 70 do_action( 'set_comment_cookies', $comment, $user, $cookies_consent ); 71 } 56 72 57 73 $location = empty( $_POST['redirect_to'] ) ? get_comment_link( $comment ) : $_POST['redirect_to'] . '#comment-' . $comment->comment_ID; 58 74 -
src/wp-content/themes/twentynineteen/classes/class-twentynineteen-walker-comment.php
diff --git src/wp-content/themes/twentynineteen/classes/class-twentynineteen-walker-comment.php src/wp-content/themes/twentynineteen/classes/class-twentynineteen-walker-comment.php index 829bb515b7..a0091e7950 100644
class TwentyNineteen_Walker_Comment extends Walker_Comment { 104 104 </footer><!-- .comment-meta --> 105 105 106 106 <div class="comment-content"> 107 <?php comment_text(); ?> 107 <?php 108 comment_text(); 109 110 // Output the comment approval notification form if needed. 111 parent::comment_approval_notification_form( $comment ); 112 ?> 108 113 </div><!-- .comment-content --> 109 114 110 115 </article><!-- .comment-body --> -
src/wp-content/themes/twentytwenty/classes/class-twentytwenty-walker-comment.php
diff --git src/wp-content/themes/twentytwenty/classes/class-twentytwenty-walker-comment.php src/wp-content/themes/twentytwenty/classes/class-twentytwenty-walker-comment.php index 727817c75e..c9c7ef351e 100644
if ( ! class_exists( 'TwentyTwenty_Walker_Comment' ) ) { 91 91 ?> 92 92 <p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'twentytwenty' ); ?></p> 93 93 <?php 94 95 // Output the comment approval notification form if needed. 96 parent::comment_approval_notification_form( $comment ); 94 97 } 95 98 96 99 ?> -
src/wp-includes/class-walker-comment.php
diff --git src/wp-includes/class-walker-comment.php src/wp-includes/class-walker-comment.php index 7325fd0a6a..bcf9deca38 100644
class Walker_Comment extends Walker { 244 244 <?php 245 245 } 246 246 247 /** 248 * Outputs the awaiting moderation text. 249 * 250 * @since 5.4.0 251 * 252 * @param WP_Comment $comment Comment to display. 253 */ 254 protected function awaiting_moderation_text( $comment ) { 255 if ( 0 !== (int) $comment->comment_approved ) { 256 return; 257 } 258 259 $commenter = wp_get_current_commenter(); 260 if ( $commenter['comment_author_email'] ) { 261 $moderation_note = __( 'Your comment is awaiting moderation.' ); 262 } else { 263 $moderation_note = __( 'Your comment is awaiting moderation. This is a preview, your comment will be visible after it has been approved.' ); 264 } 265 266 printf( '<em class="comment-awaiting-moderation">%s</em>', esc_html( $moderation_note ) ); 267 268 if ( true === (bool) get_comment_meta( $comment->comment_ID, '_wp_comment_author_notification_optin', true ) ) : 269 ?> 270 <em class="comment-awaiting-moderation"><?php echo esc_html( $moderation_note ); ?></em> 271 <br/> 272 <em class="wp-comment-approved-notification-optedin"><?php esc_html_e( 'You will receive an email when your comment has been approved.' ); ?></em> 273 <?php else : ?> 274 <form action="<?php echo esc_url( site_url( '/wp-comments-post.php' ) ); ?>" method="post"> 275 <p><em class="comment-awaiting-moderation"><?php echo esc_html( $moderation_note ); ?></em></p> 276 <p> 277 <label for="wp-comment-approved-notification-optin"> 278 <input type="checkbox" id="wp-comment-approved-notification-optin" name="wp-comment-approved-notification-optin"> 279 <?php esc_html_e( 'I want to be notified by email when my comment will be approved.' ); ?> 280 </label> 281 </p> 282 <input type="hidden" name="comment_ID" value="<?php echo absint( $comment->comment_ID ); ?>"> 283 <input type="submit" class="button" value="<?php echo esc_html_x( 'Save', 'comment approved notification form' ); ?>"> 284 </form> 285 <?php 286 endif; 287 } 288 289 /** 290 * Outputs the comment's approval notification form. 291 * 292 * @since 5.4.0 293 * 294 * @param WP_Comment $comment Comment to display. 295 */ 296 protected function comment_approval_notification_form( $comment ) { 297 if ( 0 !== (int) $comment->comment_approved ) { 298 return; 299 } 300 301 if ( true === (bool) get_comment_meta( $comment->comment_ID, '_wp_comment_author_notification_optin', true ) ) : 302 ?> 303 <p class="wp-comment-approved-notification-optedin"><?php esc_html_e( 'You will receive an email when your comment has been approved.' ); ?></p> 304 <?php else : ?> 305 <form action="<?php echo esc_url( site_url( '/wp-comments-post.php' ) ); ?>" method="post"> 306 <p> 307 <label for="wp-comment-approved-notification-optin"> 308 <input type="checkbox" id="wp-comment-approved-notification-optin" name="wp-comment-approved-notification-optin"> 309 <?php esc_html_e( 'I want to be notified by email when my comment will be approved.' ); ?> 310 </label> 311 </p> 312 <input type="hidden" name="comment_ID" value="<?php echo absint( $comment->comment_ID ); ?>"> 313 <input type="hidden" name="moderation-hash" value="<?php echo wp_hash( $comment->comment_date_gmt ); ?>"> 314 <input type="submit" class="button" value="<?php echo esc_html_x( 'Save', 'comment approved notification form' ); ?>"> 315 </form> 316 <?php 317 endif; 318 } 319 247 320 /** 248 321 * Outputs a single comment. 249 322 * … … class Walker_Comment extends Walker { 263 336 $tag = 'li'; 264 337 $add_below = 'div-comment'; 265 338 } 266 267 $commenter = wp_get_current_commenter();268 if ( $commenter['comment_author_email'] ) {269 $moderation_note = __( 'Your comment is awaiting moderation.' );270 } else {271 $moderation_note = __( 'Your comment is awaiting moderation. This is a preview, your comment will be visible after it has been approved.' );272 }273 274 339 ?> 275 340 <<?php echo $tag; ?> <?php comment_class( $this->has_children ? 'parent' : '', $comment ); ?> id="comment-<?php comment_ID(); ?>"> 276 341 <?php if ( 'div' != $args['style'] ) : ?> … … class Walker_Comment extends Walker { 289 354 ); 290 355 ?> 291 356 </div> 292 <?php if ( '0' == $comment->comment_approved ) : ?> 293 <em class="comment-awaiting-moderation"><?php echo $moderation_note; ?></em> 357 <?php $this->awaiting_moderation_text( $comment ); ?> 294 358 <br /> 295 <?php endif; ?>296 359 297 360 <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment, $args ) ); ?>"> 298 361 <?php … … class Walker_Comment extends Walker { 317 380 ) 318 381 ) 319 382 ); 383 384 // Output the comment approval notification form if needed. 385 $this->comment_approval_notification_form( $comment ); 320 386 ?> 321 387 322 388 <?php … … class Walker_Comment extends Walker { 353 419 */ 354 420 protected function html5_comment( $comment, $depth, $args ) { 355 421 $tag = ( 'div' === $args['style'] ) ? 'div' : 'li'; 356 357 $commenter = wp_get_current_commenter();358 if ( $commenter['comment_author_email'] ) {359 $moderation_note = __( 'Your comment is awaiting moderation.' );360 } else {361 $moderation_note = __( 'Your comment is awaiting moderation. This is a preview, your comment will be visible after it has been approved.' );362 }363 364 422 ?> 365 423 <<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class( $this->has_children ? 'parent' : '', $comment ); ?>> 366 424 <article id="div-comment-<?php comment_ID(); ?>" class="comment-body"> … … class Walker_Comment extends Walker { 392 450 <?php edit_comment_link( __( 'Edit' ), '<span class="edit-link">', '</span>' ); ?> 393 451 </div><!-- .comment-metadata --> 394 452 395 <?php if ( '0' == $comment->comment_approved ) : ?> 396 <em class="comment-awaiting-moderation"><?php echo $moderation_note; ?></em> 397 <?php endif; ?> 453 <?php $this->awaiting_moderation_text( $comment ); ?> 398 454 </footer><!-- .comment-meta --> 399 455 400 456 <div class="comment-content"> 401 <?php comment_text(); ?> 457 <?php 458 comment_text(); 459 460 // Output the comment approval notification form if needed. 461 $this->comment_approval_notification_form( $comment ); 462 ?> 402 463 </div><!-- .comment-content --> 403 464 404 465 <?php -
src/wp-includes/comment.php
diff --git src/wp-includes/comment.php src/wp-includes/comment.php index dfe5173236..e4ab5fd430 100644
function wp_new_comment_notify_postauthor( $comment_ID ) { 2234 2234 return wp_notify_postauthor( $comment_ID ); 2235 2235 } 2236 2236 2237 /** 2238 * Notify a comment author when their comment gets approved. 2239 * 2240 * This notification is only sent once when the comment status 2241 * changes from unapproved to approved. 2242 * 2243 * @since 5.4.0 2244 * 2245 * @param int|WP_Comment $comment_id Comment ID or WP_Comment object. 2246 * @return bool Whether the email was sent successfully. 2247 */ 2248 function wp_new_comment_notify_comment_author( $comment_id ) { 2249 $comment = get_comment( $comment_id ); 2250 2251 if ( ! $comment ) { 2252 return false; 2253 } 2254 2255 $post = get_post( $comment->comment_post_ID ); 2256 $comment_author = get_user_by( 'email', $comment->comment_author_email ); 2257 2258 if ( ! $post ) { 2259 return false; 2260 } 2261 2262 // The comment was left by the post author. 2263 if ( $comment->user_id === $post->post_author || $comment_author === get_userdata( $post->post_author ) ) { 2264 return false; 2265 } 2266 2267 // Make sure the comment author can notified by email. 2268 if ( empty( $comment->comment_author_email ) ) { 2269 return false; 2270 } 2271 2272 if ( true !== (bool) get_comment_meta( $comment->comment_ID, '_wp_comment_author_notification_optin', true ) ) { 2273 return false; 2274 } 2275 2276 /** 2277 * The blogname option is escaped with esc_html when 2278 * saved into the database, we need to reverse this for 2279 * the plain text area of the email. 2280 */ 2281 $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); 2282 2283 /* translators: 1: blog name, 2: post title */ 2284 $subject = sprintf( __( '[%1$s] Your comment on "%2$s" has been approved' ), $blogname, $post->post_title ); 2285 2286 if ( ! empty( $comment->comment_author ) ) { 2287 /* translators: 1: comment author's name */ 2288 $notify_message = sprintf( __( 'Howdy %s,' ), $comment->comment_author ) . "\r\n\r\n"; 2289 } else { 2290 $notify_message = __( 'Howdy,' ) . "\r\n\r\n"; 2291 } 2292 2293 /* translators: 1: post title */ 2294 $notify_message .= sprintf( __( 'Your comment on the post "%s" has been approved.' ), $post->post_title ) . "\r\n\r\n"; 2295 /* translators: 1: comment permalink */ 2296 $notify_message .= sprintf( __( 'View comment: %s' ), get_comment_link( $comment ) ) . "\r\n"; 2297 2298 /** 2299 * Filter the comment approval notification email text. 2300 * 2301 * @since 5.4.0 2302 * 2303 * @param string $notify_message The comment notification email text. 2304 * @param WP_Comment $comment Comment object. 2305 */ 2306 $notify_message = apply_filters( 'comment_approval_notification_text', $notify_message, $comment ); 2307 2308 /** 2309 * Filter the comment approval notification email subject. 2310 * 2311 * @since 5.4.0 2312 * 2313 * @param string $subject The comment notification email subject. 2314 * @param WP_Comment $comment Comment object. 2315 */ 2316 $subject = apply_filters( 'comment_approval_notification_subject', $subject, $comment ); 2317 2318 $sent = wp_mail( $comment->comment_author_email, wp_specialchars_decode( $subject ), $notify_message ); 2319 2320 // Delete the opt-in now the notification has been sent. 2321 delete_comment_meta( $comment->comment_ID, '_wp_comment_author_notification_optin' ); 2322 2323 return $sent; 2324 } 2325 2237 2326 /** 2238 2327 * Sets the status of a comment. 2239 2328 * -
src/wp-includes/default-filters.php
diff --git src/wp-includes/default-filters.php src/wp-includes/default-filters.php index 26cdfeba20..fc113e1bfd 100644
add_action( 'comment_post', 'wp_new_comment_notify_postauthor' ); 440 440 add_action( 'after_password_reset', 'wp_password_change_notification' ); 441 441 add_action( 'register_new_user', 'wp_send_new_user_notifications' ); 442 442 add_action( 'edit_user_created_user', 'wp_send_new_user_notifications', 10, 2 ); 443 add_action( 'comment_unapproved_to_approved', 'wp_new_comment_notify_comment_author' ); 443 444 444 445 // REST API actions. 445 446 add_action( 'init', 'rest_api_init' );
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)