Make WordPress Core


Ignore:
Timestamp:
02/17/2021 01:06:43 PM (5 years ago)
Author:
johnbillion
Message:

Comments: Revert the introduction of the opt-in comment approval notification feature.

This reverts the following commits: [50113], [50112], [50109].

See #33717

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment.php

    r50271 r50375  
    23522352
    23532353/**
    2354  * Notifies the comment author when their comment gets approved.
    2355  *
    2356  * This notification is only sent once when the comment status
    2357  * changes from unapproved to approved.
    2358  *
    2359  * @since 5.7.0
    2360  *
    2361  * @param int|WP_Comment $comment_id Comment ID or WP_Comment object.
    2362  * @return bool Whether the email was sent.
    2363  */
    2364 function wp_new_comment_notify_comment_author( $comment_id ) {
    2365         $comment = get_comment( $comment_id );
    2366 
    2367         if ( ! $comment ) {
    2368                 return false;
    2369         }
    2370 
    2371         $post = get_post( $comment->comment_post_ID );
    2372 
    2373         if ( ! $post ) {
    2374                 return false;
    2375         }
    2376 
    2377         // Make sure the comment author can be notified by email.
    2378         if ( empty( $comment->comment_author_email ) ) {
    2379                 return false;
    2380         }
    2381 
    2382         if ( ! get_comment_meta( $comment->comment_ID, '_wp_comment_author_notification_optin', true ) ) {
    2383                 return false;
    2384         }
    2385 
    2386         /**
    2387          * The blogname option is escaped with esc_html when
    2388          * saved into the database, we need to reverse this for
    2389          * the plain text area of the email.
    2390          */
    2391         $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    2392 
    2393         $subject = sprintf(
    2394                 /* translators: 1: Blog name, 2: Post title. */
    2395                 __( '[%1$s] Your comment on "%2$s" has been approved' ),
    2396                 $blogname,
    2397                 $post->post_title
    2398         );
    2399 
    2400         if ( ! empty( $comment->comment_author ) ) {
    2401                 $notify_message = sprintf(
    2402                         /* translators: %s: Comment author's name. */
    2403                         __( 'Howdy %s,' ),
    2404                         $comment->comment_author
    2405                 ) . "\r\n\r\n";
    2406         } else {
    2407                 $notify_message = __( 'Howdy,' ) . "\r\n\r\n";
    2408         }
    2409 
    2410         $notify_message .= sprintf(
    2411                 /* translators: %s: Post title. */
    2412                 __( 'Your comment on "%s" has been approved.' ),
    2413                 $post->post_title
    2414         ) . "\r\n\r\n";
    2415 
    2416         $notify_message .= sprintf(
    2417                 /* translators: %s: Comment permalink. */
    2418                 __( 'View comment: %s' ),
    2419                 get_comment_link( $comment )
    2420         ) . "\r\n";
    2421 
    2422         $email = array(
    2423                 'to'      => $comment->comment_author_email,
    2424                 'subject' => $subject,
    2425                 'message' => $notify_message,
    2426                 'headers' => '',
    2427         );
    2428 
    2429         /**
    2430          * Filters the contents of the email sent to notify a comment author that their comment was approved.
    2431          *
    2432          * Content should be formatted for transmission via wp_mail().
    2433          *
    2434          * @since 5.7.0
    2435          *
    2436          * @param array      $email   {
    2437          *     Used to build wp_mail().
    2438          *
    2439          *     @type string $to      The email address of the comment author.
    2440          *     @type string $subject The subject of the email.
    2441          *     @type string $message The content of the email.
    2442          *     @type string $headers Headers.
    2443          * }
    2444          * @param WP_Comment $comment Comment object.
    2445          */
    2446         $email = apply_filters( 'comment_approval_notification', $email, $comment );
    2447 
    2448         $sent = wp_mail(
    2449                 $email['to'],
    2450                 wp_specialchars_decode( $email['subject'] ),
    2451                 $email['message'],
    2452                 $email['headers']
    2453         );
    2454 
    2455         // Delete the opt-in now the notification has been sent.
    2456         delete_comment_meta( $comment->comment_ID, '_wp_comment_author_notification_optin' );
    2457 
    2458         return $sent;
    2459 }
    2460 
    2461 /**
    24622354 * Sets the status of a comment.
    24632355 *
Note: See TracChangeset for help on using the changeset viewer.