Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions src/wp-admin/includes/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2205,13 +2205,7 @@ function wp_admin_page_exists(): bool {
return true;
}

foreach ( (array) $_wp_submenu_nopriv as $nopriv_submenus ) {
if ( isset( $nopriv_submenus[ $plugin_page ] ) ) {
return true;
}
}

return false;
return array_any( (array) $_wp_submenu_nopriv, fn( $nopriv_submenus ) => isset( $nopriv_submenus[ $plugin_page ] ) );
}

/**
Expand Down
7 changes: 1 addition & 6 deletions src/wp-includes/abilities-api/class-wp-ability.php
Original file line number Diff line number Diff line change
Expand Up @@ -638,12 +638,7 @@ private static function is_valid_capability_list( $capabilities ): bool {
return false;
}

foreach ( $capabilities as $capability ) {
if ( ! is_string( $capability ) || '' === trim( $capability ) ) {
return false;
}
}
return true;
return array_all( $capabilities, fn( $capability ) => is_string( $capability ) && '' !== trim( $capability ) );
}

/**
Expand Down
19 changes: 5 additions & 14 deletions src/wp-includes/abilities/class-wp-abilities-content.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,10 @@ private function parse_list_input( array $input, string $key ): array {
* @return bool True if the requested statuses may be queried.
*/
private function can_query_statuses( array $where, WP_Post_Type $post_type_object ): bool {
foreach ( $this->get_requested_statuses( $where ) as $status ) {
if ( ! $this->can_query_status( $status, $post_type_object ) ) {
return false;
}
}

return true;
return array_all(
$this->get_requested_statuses( $where ),
fn( $status ) => $this->can_query_status( $status, $post_type_object )
);
}

/**
Expand Down Expand Up @@ -718,13 +715,7 @@ private function get_query_total( WP_Query $query, array $query_args, int $page
* @return bool True when post meta and term caches should be primed.
*/
private function should_prime_post_caches( array $fields ): bool {
foreach ( self::CACHE_PRIMING_FIELDS as $field ) {
if ( $this->is_field_requested( $field, $fields ) ) {
return true;
}
}

return false;
return array_any( self::CACHE_PRIMING_FIELDS, fn( $field ) => $this->is_field_requested( $field, $fields ) );
}

/**
Expand Down
11 changes: 4 additions & 7 deletions src/wp-includes/class-wp-rewrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -1559,13 +1559,10 @@ public function random_rewrite_rules(): array {
$random_base_posts[] = get_page_by_path( $random_slug, OBJECT, 'post' );
}

$random_base_is_taken = false;
foreach ( $random_base_posts as $random_base_post ) {
if ( $random_base_post instanceof WP_Post && is_post_publicly_viewable( $random_base_post ) ) {
$random_base_is_taken = true;
break;
}
}
$random_base_is_taken = array_any(
$random_base_posts,
fn( $random_base_post ) => $random_base_post instanceof WP_Post && is_post_publicly_viewable( $random_base_post )
);

if ( ! $random_base_is_taken ) {
$rules[ $random_base . '/?$' ] = $this->index . '?random=1';
Expand Down
8 changes: 1 addition & 7 deletions src/wp-includes/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -7018,12 +7018,6 @@ function wp_is_cross_origin_isolated_request(): bool {
return true;
}

foreach ( headers_list() as $header ) {
if ( 0 === stripos( $header, 'Document-Isolation-Policy:' ) ) {
return true;
}
}

return false;
return array_any( headers_list(), fn( $header ) => 0 === stripos( $header, 'Document-Isolation-Policy:' ) );
}

11 changes: 4 additions & 7 deletions src/wp-includes/secrets/class-wp-secrets-config-key-provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,10 @@ private function get_site_key() {
* @phpstan-assert-if-true non-empty-string $logged_in_salt
*/
private function are_usable_salt_values( $logged_in_key, $logged_in_salt ): bool {
foreach ( array( $logged_in_key, $logged_in_salt ) as $value ) {
if ( ! is_string( $value ) || '' === $value || self::KNOWN_PLACEHOLDER === $value ) {
return false;
}
}

return true;
return array_all(
array( $logged_in_key, $logged_in_salt ),
fn( $value ) => is_string( $value ) && '' !== $value && self::KNOWN_PLACEHOLDER !== $value
);
}

/**
Expand Down
Loading