Comments: Remove `wp_get_include_unapproved_comments_argument()` for now.
The function seems too specific and low-level for an abstraction, is only used in two places, and does not provide a significant benefit in terms of reducing code duplication. Follow-up to [48133]. See #8973. Built from https://develop.svn.wordpress.org/trunk@48140 git-svn-id: http://core.svn.wordpress.org/trunk@47909 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5e7dfff3a0
commit
803a05946b
|
@ -1330,7 +1330,6 @@ function wp_comment_form_unfiltered_html_nonce() {
|
||||||
* Will not try to get the comments if the post has none.
|
* Will not try to get the comments if the post has none.
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @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_Query $wp_query WordPress Query object.
|
||||||
* @global WP_Post $post Global post 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;
|
$comment_args['hierarchical'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$include_unapproved = wp_get_include_unapproved_comments_argument();
|
if ( is_user_logged_in() ) {
|
||||||
if ( $include_unapproved ) {
|
$comment_args['include_unapproved'] = array( get_current_user_id() );
|
||||||
$comment_args['include_unapproved'] = $include_unapproved;
|
} else {
|
||||||
|
$unapproved_email = wp_get_unapproved_comment_author_email();
|
||||||
|
|
||||||
|
if ( $unapproved_email ) {
|
||||||
|
$comment_args['include_unapproved'] = array( $unapproved_email );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$per_page = 0;
|
$per_page = 0;
|
||||||
|
@ -2097,7 +2101,7 @@ function wp_list_comments( $args = array(), $comments = null ) {
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( is_user_logged_in() ) {
|
if ( is_user_logged_in() ) {
|
||||||
$comment_args['include_unapproved'] = get_current_user_id();
|
$comment_args['include_unapproved'] = array( get_current_user_id() );
|
||||||
} else {
|
} else {
|
||||||
$unapproved_email = wp_get_unapproved_comment_author_email();
|
$unapproved_email = wp_get_unapproved_comment_author_email();
|
||||||
|
|
||||||
|
|
|
@ -1054,13 +1054,14 @@ function get_comment_pages_count( $comments = null, $per_page = null, $threaded
|
||||||
* @param int $comment_ID Comment ID.
|
* @param int $comment_ID Comment ID.
|
||||||
* @param array $args {
|
* @param array $args {
|
||||||
* Array of optional arguments.
|
* Array of optional arguments.
|
||||||
* @type string $type Limit paginated comments to those matching a given type. Accepts 'comment',
|
* @type string $type Limit paginated comments to those matching a given type.
|
||||||
* 'trackback', 'pingback', 'pings' (trackbacks and pingbacks), or 'all'.
|
* Accepts 'comment', 'trackback', 'pingback', 'pings'
|
||||||
* Default is 'all'.
|
* (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
|
* @type int $per_page Per-page count to use when calculating pagination.
|
||||||
* 'comments_per_page' option.
|
* 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
|
* @type int|string $max_depth If greater than 1, comment page will be determined
|
||||||
* `$comment_ID`. Defaults to the value of the 'thread_comments_depth' option.
|
* 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.
|
* @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 ( is_user_logged_in() ) {
|
||||||
if ( $include_unapproved ) {
|
$comment_args['include_unapproved'] = array( get_current_user_id() );
|
||||||
$comment_args['include_unapproved'] = $include_unapproved;
|
} 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 {
|
* @param array $comment_args {
|
||||||
* Array of WP_Comment_Query arguments.
|
* Array of WP_Comment_Query arguments.
|
||||||
*
|
*
|
||||||
* @type string $type Limit paginated comments to those matching a given type. Accepts 'comment',
|
* @type string $type Limit paginated comments to those matching a given type.
|
||||||
* 'trackback', 'pingback', 'pings' (trackbacks and pingbacks), or 'all'.
|
* Accepts 'comment', 'trackback', 'pingback', 'pings'
|
||||||
* Default is 'all'.
|
* (trackbacks and pingbacks), or 'all'. Default 'all'.
|
||||||
* @type int $post_id ID of the post.
|
* @type int $post_id ID of the post.
|
||||||
* @type string $fields Comment fields to return.
|
* @type string $fields Comment fields to return.
|
||||||
* @type bool $count Whether to return a comment count (true) or array of
|
* @type bool $count Whether to return a comment count (true) or array
|
||||||
* comment objects (false)
|
* of comment objects (false).
|
||||||
* @type string $status Comment status.
|
* @type string $status Comment status.
|
||||||
* @type int $parent Parent ID of comment to retrieve children of.
|
* @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.
|
* @type array $date_query Date query clauses to limit comments by. See WP_Date_Query.
|
||||||
|
@ -1162,6 +1168,7 @@ function get_page_of_comment( $comment_ID, $args = array() ) {
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
$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();
|
$comment_query = new WP_Comment_Query();
|
||||||
$older_comment_count = $comment_query->query( $comment_args );
|
$older_comment_count = $comment_query->query( $comment_args );
|
||||||
|
|
||||||
|
@ -1926,33 +1933,6 @@ function wp_get_unapproved_comment_author_email() {
|
||||||
return $commenter_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.
|
* Inserts a comment into the database.
|
||||||
*
|
*
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @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.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue