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-comments-post.php

    r50109 r50375  
    2323nocache_headers();
    2424
    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 ( $comment && 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 {
     25$comment = wp_handle_comment_submission( wp_unslash( $_POST ) );
     26if ( is_wp_error( $comment ) ) {
     27    $data = (int) $comment->get_error_data();
     28    if ( ! empty( $data ) ) {
    3129        wp_die(
    32             '<p>' . __( 'Invalid comment ID.' ) . '</p>',
    33             __( 'Comment Notification Opt-in Failure' ),
     30            '<p>' . $comment->get_error_message() . '</p>',
     31            __( 'Comment Submission Failure' ),
    3432            array(
    35                 'response'  => 404,
     33                'response'  => $data,
    3634                'back_link' => true,
    3735            )
    3836        );
     37    } else {
     38        exit;
    3939    }
    40 } else {
    41     $comment = wp_handle_comment_submission( wp_unslash( $_POST ) );
    42     if ( is_wp_error( $comment ) ) {
    43         $data = (int) $comment->get_error_data();
    44         if ( ! empty( $data ) ) {
    45             wp_die(
    46                 '<p>' . $comment->get_error_message() . '</p>',
    47                 __( 'Comment Submission Failure' ),
    48                 array(
    49                     'response'  => $data,
    50                     'back_link' => true,
    51                 )
    52             );
    53         } else {
    54             exit;
    55         }
    56     }
     40}
    5741
    58     $user            = wp_get_current_user();
    59     $cookies_consent = ( isset( $_POST['wp-comment-cookies-consent'] ) );
     42$user            = wp_get_current_user();
     43$cookies_consent = ( isset( $_POST['wp-comment-cookies-consent'] ) );
    6044
    61     /**
    62      * Perform other actions when comment cookies are set.
    63      *
    64      * @since 3.4.0
    65      * @since 4.9.6 The `$cookies_consent` parameter was added.
    66      *
    67      * @param WP_Comment $comment         Comment object.
    68      * @param WP_User    $user            Comment author's user object. The user may not exist.
    69      * @param bool       $cookies_consent Comment author's consent to store cookies.
    70      */
    71     do_action( 'set_comment_cookies', $comment, $user, $cookies_consent );
    72 }
     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 bool       $cookies_consent Comment author's consent to store cookies.
     54 */
     55do_action( 'set_comment_cookies', $comment, $user, $cookies_consent );
    7356
    7457$location = empty( $_POST['redirect_to'] ) ? get_comment_link( $comment ) : $_POST['redirect_to'] . '#comment-' . $comment->comment_ID;
Note: See TracChangeset for help on using the changeset viewer.