diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index 2482c0250e..0eba945fa5 100644 --- a/wp-includes/comment-template.php +++ b/wp-includes/comment-template.php @@ -1330,7 +1330,6 @@ function wp_comment_form_unfiltered_html_nonce() { * Will not try to get the comments if the post has none. * * @since 1.5.0 - * @since 5.5.0 Removed the need to use the $user_ID global. * * @global WP_Query $wp_query WordPress Query object. * @global WP_Post $post Global post object. @@ -1396,9 +1395,14 @@ function comments_template( $file = '/comments.php', $separate_comments = false $comment_args['hierarchical'] = false; } - $include_unapproved = wp_get_include_unapproved_comments_argument(); - if ( $include_unapproved ) { - $comment_args['include_unapproved'] = $include_unapproved; + if ( is_user_logged_in() ) { + $comment_args['include_unapproved'] = array( get_current_user_id() ); + } else { + $unapproved_email = wp_get_unapproved_comment_author_email(); + + if ( $unapproved_email ) { + $comment_args['include_unapproved'] = array( $unapproved_email ); + } } $per_page = 0; @@ -2097,7 +2101,7 @@ function wp_list_comments( $args = array(), $comments = null ) { ); if ( is_user_logged_in() ) { - $comment_args['include_unapproved'] = get_current_user_id(); + $comment_args['include_unapproved'] = array( get_current_user_id() ); } else { $unapproved_email = wp_get_unapproved_comment_author_email(); diff --git a/wp-includes/comment.php b/wp-includes/comment.php index b4771df838..15899cba77 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -1054,13 +1054,14 @@ function get_comment_pages_count( $comments = null, $per_page = null, $threaded * @param int $comment_ID Comment ID. * @param array $args { * Array of optional arguments. - * @type string $type Limit paginated comments to those matching a given type. Accepts 'comment', - * 'trackback', 'pingback', 'pings' (trackbacks and pingbacks), or 'all'. - * Default is 'all'. - * @type int $per_page Per-page count to use when calculating pagination. Defaults to the value of the - * 'comments_per_page' option. - * @type int|string $max_depth If greater than 1, comment page will be determined for the top-level parent of - * `$comment_ID`. Defaults to the value of the 'thread_comments_depth' option. + * @type string $type Limit paginated comments to those matching a given type. + * Accepts 'comment', 'trackback', 'pingback', 'pings' + * (trackbacks and pingbacks), or 'all'. Default 'all'. + * @type int $per_page Per-page count to use when calculating pagination. + * Defaults to the value of the 'comments_per_page' option. + * @type int|string $max_depth If greater than 1, comment page will be determined + * for the top-level parent `$comment_ID`. + * Defaults to the value of the 'thread_comments_depth' option. * } * * @return int|null Comment page number or null on error. */ @@ -1132,9 +1133,14 @@ function get_page_of_comment( $comment_ID, $args = array() ) { ), ); - $include_unapproved = wp_get_include_unapproved_comments_argument(); - if ( $include_unapproved ) { - $comment_args['include_unapproved'] = $include_unapproved; + if ( is_user_logged_in() ) { + $comment_args['include_unapproved'] = array( get_current_user_id() ); + } else { + $unapproved_email = wp_get_unapproved_comment_author_email(); + + if ( $unapproved_email ) { + $comment_args['include_unapproved'] = array( $unapproved_email ); + } } /** @@ -1147,13 +1153,13 @@ function get_page_of_comment( $comment_ID, $args = array() ) { * @param array $comment_args { * Array of WP_Comment_Query arguments. * - * @type string $type Limit paginated comments to those matching a given type. Accepts 'comment', - * 'trackback', 'pingback', 'pings' (trackbacks and pingbacks), or 'all'. - * Default is 'all'. + * @type string $type Limit paginated comments to those matching a given type. + * Accepts 'comment', 'trackback', 'pingback', 'pings' + * (trackbacks and pingbacks), or 'all'. Default 'all'. * @type int $post_id ID of the post. * @type string $fields Comment fields to return. - * @type bool $count Whether to return a comment count (true) or array of - * comment objects (false) + * @type bool $count Whether to return a comment count (true) or array + * of comment objects (false). * @type string $status Comment status. * @type int $parent Parent ID of comment to retrieve children of. * @type array $date_query Date query clauses to limit comments by. See WP_Date_Query. @@ -1161,7 +1167,8 @@ function get_page_of_comment( $comment_ID, $args = array() ) { * will be included in paginated comments. * } */ - $comment_args = apply_filters( 'get_page_of_comment_query_args', $comment_args ); + $comment_args = apply_filters( 'get_page_of_comment_query_args', $comment_args ); + $comment_query = new WP_Comment_Query(); $older_comment_count = $comment_query->query( $comment_args ); @@ -1926,33 +1933,6 @@ function wp_get_unapproved_comment_author_email() { return $commenter_email; } -/** - * Get include unapproved comments query argument. - * - * Used to include unapproved comments of currrent commenters to - * keep them informed their comments were successfully saved. - * - * @since 5.5.0 - * - * @return array The unapproved comments query argument. - */ -function wp_get_include_unapproved_comments_argument() { - $user_id = get_current_user_id(); - $include_unapproved = array(); - - if ( $user_id ) { - $include_unapproved = array( $user_id ); - } else { - $unapproved_email = wp_get_unapproved_comment_author_email(); - - if ( $unapproved_email ) { - $include_unapproved = array( $unapproved_email ); - } - } - - return $include_unapproved; -} - /** * Inserts a comment into the database. * diff --git a/wp-includes/version.php b/wp-includes/version.php index ec38e6d628..735fabfb63 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-alpha-48139'; +$wp_version = '5.5-alpha-48140'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.