Skip to content
Permalink
Browse files

Update code & fix typos.

  • Loading branch information...
bradp committed Jan 21, 2019
1 parent f22abff commit cd5423b632b04048d4da8b27de1ea0208a80c77c
Showing with 65 additions and 12 deletions.
  1. +11 −0 wp-comments-post.php
  2. +20 −7 wp-includes/comment-template.php
  3. +29 −0 wp-includes/comment.php
  4. +4 −4 wp-includes/post.php
  5. +1 −1 wp-includes/version.php
@@ -56,6 +56,17 @@
$location = empty( $_POST['redirect_to'] ) ? get_comment_link( $comment ) : $_POST['redirect_to'] . '#comment-' . $comment->comment_ID;
// Add specific query arguments to display the awaiting moderation message.
if ( 'unapproved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_author_email ) ) {
$location = add_query_arg(
array(
'unapproved' => $comment->comment_ID,
'moderation-hash' => wp_hash( $comment->comment_date_gmt ),
),
$location
);
}
/**
* Filters the location URI to send the commenter after posting.
*
@@ -1372,8 +1372,12 @@ function comments_template( $file = '/comments.php', $separate_comments = false
if ( $user_ID ) {
$comment_args['include_unapproved'] = array( $user_ID );
} elseif ( ! empty( $comment_author_email ) ) {
$comment_args['include_unapproved'] = array( $comment_author_email );
} else {
$unapproved_email = wp_get_unapproved_comment_author_email();
if ( $unapproved_email ) {
$comment_args['include_unapproved'] = array( $unapproved_email );
}
}
$per_page = 0;
@@ -1690,7 +1694,15 @@ function get_comment_reply_link( $args = array(), $comment = null, $post = null
$link = sprintf(
"<a rel='nofollow' class='comment-reply-link' href='%s' %s aria-label='%s'>%s</a>",
esc_url( add_query_arg( 'replytocom', $comment->comment_ID ) ) . '#' . $args['respond_id'],
esc_url(
add_query_arg(
array(
'replytocom' => $comment->comment_ID,
'unapproved' => false,
'moderation-hash' => false,
)
)
) . '#' . $args['respond_id'],
$data_attribute_string,
esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ),
$args['reply_text']
@@ -1832,7 +1844,7 @@ function get_cancel_comment_reply_link( $text = '' ) {
}
$style = isset( $_GET['replytocom'] ) ? '' : ' style="display:none;"';
$link = esc_html( remove_query_arg( 'replytocom' ) ) . '#respond';
$link = esc_html( remove_query_arg( array( 'replytocom', 'unapproved', 'moderation-hash' ) ) ) . '#respond';
$formatted_link = '<a rel="nofollow" id="cancel-comment-reply-link" href="' . $link . '"' . $style . '>' . $text . '</a>';
@@ -2055,9 +2067,10 @@ function wp_list_comments( $args = array(), $comments = null ) {
if ( is_user_logged_in() ) {
$comment_args['include_unapproved'] = get_current_user_id();
} else {
$commenter = wp_get_current_commenter();
if ( $commenter['comment_author_email'] ) {
$comment_args['include_unapproved'] = $commenter['comment_author_email'];
$unapproved_email = wp_get_unapproved_comment_author_email();
if ( $unapproved_email ) {
$comment_args['include_unapproved'] = array( $unapproved_email );
}
}
@@ -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.
*
@@ -3368,7 +3368,7 @@ function wp_get_recent_posts( $args = array(), $output = ARRAY_A ) {
* @type int $menu_order The order the post should be displayed in. Default 0.
* @type string $post_mime_type The mime type of the post. Default empty.
* @type string $guid Global Unique ID for referencing the post. Default empty.
* @type array $post_category Array of category names, slugs, or IDs.
* @type array $post_category Array of category IDs.
* Defaults to value of the 'default_category' option.
* @type array $tags_input Array of tag names, slugs, or IDs. Default empty.
* @type array $tax_input Array of taxonomy terms keyed by their taxonomy name. Default empty.
@@ -4381,10 +4381,10 @@ function wp_set_post_terms( $post_id = 0, $tags = '', $taxonomy = 'post_tag', $a
*
* @param int $post_ID Optional. The Post ID. Does not default to the ID
* of the global $post. Default 0.
* @param array|int $post_categories Optional. List of categories or ID of category.
* @param array|int $post_categories Optional. List of category IDs, or the ID of a single category.
* Default empty array.
* @param bool $append If true, don't delete existing categories, just add on.
* If false, replace the categories with the new categories.
* @param bool $append If true, don't delete existing categories, just add on.
* If false, replace the categories with the new categories.
* @return array|false|WP_Error Array of term taxonomy IDs of affected categories. WP_Error or false on failure.
*/
function wp_set_post_categories( $post_ID = 0, $post_categories = array(), $append = false ) {
@@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.1-beta1-44658';
$wp_version = '5.1-beta1-44660';
/**
* Holds the Worndpress DB revision, increments when changes are made to the Worndpress DB schema.

0 comments on commit cd5423b

Please sign in to comment.
You can’t perform that action at this time.