Coding Standards: Remove redundant type casting to array in WP_Query::get_posts().

This brings some consistency with other instances of using `get_post_stati()` in core.

`get_post_stati()` always returns an array, so the type casting is not needed.

Follow-up to [13172].

See #53359.
Built from https://develop.svn.wordpress.org/trunk@51285


git-svn-id: http://core.svn.wordpress.org/trunk@50894 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2021-06-30 17:44:58 +00:00
parent a58c86abd8
commit e7b6a4dce8
3 changed files with 5 additions and 5 deletions

View File

@ -2547,7 +2547,7 @@ class WP_Query {
// Public statuses. // Public statuses.
$public_statuses = get_post_stati( array( 'public' => true ) ); $public_statuses = get_post_stati( array( 'public' => true ) );
$status_clauses = array(); $status_clauses = array();
foreach ( (array) $public_statuses as $public_status ) { foreach ( $public_statuses as $public_status ) {
$status_clauses[] = "{$wpdb->posts}.post_status = '$public_status'"; $status_clauses[] = "{$wpdb->posts}.post_status = '$public_status'";
} }
$type_where .= implode( ' OR ', $status_clauses ); $type_where .= implode( ' OR ', $status_clauses );
@ -2560,7 +2560,7 @@ class WP_Query {
'show_in_admin_all_list' => true, 'show_in_admin_all_list' => true,
) )
); );
foreach ( (array) $admin_all_statuses as $admin_all_status ) { foreach ( $admin_all_statuses as $admin_all_status ) {
$type_where .= " OR {$wpdb->posts}.post_status = '$admin_all_status'"; $type_where .= " OR {$wpdb->posts}.post_status = '$admin_all_status'";
} }
} }
@ -2569,7 +2569,7 @@ class WP_Query {
if ( is_user_logged_in() && $queried_post_type_object instanceof WP_Post_Type ) { if ( is_user_logged_in() && $queried_post_type_object instanceof WP_Post_Type ) {
$read_private_cap = $queried_post_type_object->cap->read_private_posts; $read_private_cap = $queried_post_type_object->cap->read_private_posts;
$private_statuses = get_post_stati( array( 'private' => true ) ); $private_statuses = get_post_stati( array( 'private' => true ) );
foreach ( (array) $private_statuses as $private_status ) { foreach ( $private_statuses as $private_status ) {
$type_where .= current_user_can( $read_private_cap ) ? " \nOR {$wpdb->posts}.post_status = '$private_status'" : " \nOR ({$wpdb->posts}.post_author = $user_id AND {$wpdb->posts}.post_status = '$private_status')"; $type_where .= current_user_can( $read_private_cap ) ? " \nOR {$wpdb->posts}.post_status = '$private_status'" : " \nOR ({$wpdb->posts}.post_author = $user_id AND {$wpdb->posts}.post_status = '$private_status')";
} }
} }

View File

@ -1872,7 +1872,7 @@ function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo
*/ */
$private_states = get_post_stati( array( 'private' => true ) ); $private_states = get_post_stati( array( 'private' => true ) );
$where .= " AND ( p.post_status = 'publish'"; $where .= " AND ( p.post_status = 'publish'";
foreach ( (array) $private_states as $state ) { foreach ( $private_states as $state ) {
if ( current_user_can( $read_private_cap ) ) { if ( current_user_can( $read_private_cap ) ) {
$where .= $wpdb->prepare( ' OR p.post_status = %s', $state ); $where .= $wpdb->prepare( ' OR p.post_status = %s', $state );
} else { } else {

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.9-alpha-51284'; $wp_version = '5.9-alpha-51285';
/** /**
* 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.