mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-03-31 18:54:29 +00:00
Comments: Show the "awaiting moderation" message when comment cookies are disabled.
The "Your comment is awaiting moderation." message relied upon the comment author cookie being set. However, since it's now possible to opt-out of that cookie, submitting a comment won't show the comment preview when the comment is placed in moderation. To avoid this issue, we now include a hash in the redirect URL, allowing the site to identify that a preview of the moderated comment should be displayed. Props imath, tomdxw, birgire, lakenh, azaozz, pento. Fixes #43857. git-svn-id: https://develop.svn.wordpress.org/trunk@44659 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1768,6 +1768,35 @@ function wp_get_current_commenter() {
|
||||
return apply_filters( 'wp_get_current_commenter', compact( 'comment_author', 'comment_author_email', 'comment_author_url' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get unapproved comment author's email.
|
||||
*
|
||||
* Used to allow the commenter to see their pending comment.
|
||||
*
|
||||
* @since 5.1.0
|
||||
*
|
||||
* @return string The unapproved comment author's email (when supplied).
|
||||
*/
|
||||
function wp_get_unapproved_comment_author_email() {
|
||||
$commenter_email = '';
|
||||
|
||||
if ( ! empty( $_GET['unapproved'] ) && ! empty( $_GET['moderation-hash'] ) ) {
|
||||
$comment_id = (int) $_GET['unapproved'];
|
||||
$comment = get_comment( $comment_id );
|
||||
|
||||
if ( $comment && hash_equals( $_GET['moderation-hash'], wp_hash( $comment->comment_date_gmt ) ) ) {
|
||||
$commenter_email = $comment->comment_author_email;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $commenter_email ) {
|
||||
$commenter = wp_get_current_commenter();
|
||||
$commenter_email = $commenter['comment_author_email'];
|
||||
}
|
||||
|
||||
return $commenter_email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a comment into the database.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user