Changeset 50109 for trunk/src/wp-comments-post.php
- Timestamp:
- 01/31/2021 12:48:24 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-comments-post.php
r49108 r50109 23 23 nocache_headers(); 24 24 25 $comment = wp_handle_comment_submission( wp_unslash( $_POST ) ); 26 if ( is_wp_error( $comment ) ) { 27 $data = (int) $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 ( $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 { 29 31 wp_die( 30 '<p>' . $comment->get_error_message() . '</p>',31 __( 'Comment Submission Failure' ),32 '<p>' . __( 'Invalid comment ID.' ) . '</p>', 33 __( 'Comment Notification Opt-in Failure' ), 32 34 array( 33 'response' => $data,35 'response' => 404, 34 36 'back_link' => true, 35 37 ) 36 38 ); 37 } else {38 exit;39 39 } 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 } 57 58 $user = wp_get_current_user(); 59 $cookies_consent = ( isset( $_POST['wp-comment-cookies-consent'] ) ); 60 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 ); 40 72 } 41 42 $user = wp_get_current_user();43 $cookies_consent = ( isset( $_POST['wp-comment-cookies-consent'] ) );44 45 /**46 * Perform other actions when comment cookies are set.47 *48 * @since 3.4.049 * @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 */55 do_action( 'set_comment_cookies', $comment, $user, $cookies_consent );56 73 57 74 $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.