diff --git a/src/wp-includes/class-wp-user.php b/src/wp-includes/class-wp-user.php index 63c3f8d04bf6a..9ae005069bd03 100644 --- a/src/wp-includes/class-wp-user.php +++ b/src/wp-includes/class-wp-user.php @@ -827,13 +827,7 @@ public function has_cap( $cap, ...$args ) { unset( $capabilities['do_not_allow'] ); // Must have ALL requested caps. - foreach ( (array) $caps as $cap ) { - if ( empty( $capabilities[ $cap ] ) ) { - return false; - } - } - - return true; + return array_all( (array) $caps, fn( $cap ) => ! empty( $capabilities[ $cap ] ) ); } /** diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 355d9f8a1ec37..8a86368e6bdda 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -5317,14 +5317,7 @@ function wp_is_numeric_array( $data ): bool { if ( ! is_array( $data ) ) { return false; } - - foreach ( $data as $key => $value ) { - if ( is_string( $key ) ) { - return false; - } - } - - return true; + return array_all( $data, fn( $value, $key ) => ! is_string( $key ) ); } /** diff --git a/src/wp-includes/rest-api.php b/src/wp-includes/rest-api.php index a4c22e8f1cca1..1a74059942c54 100644 --- a/src/wp-includes/rest-api.php +++ b/src/wp-includes/rest-api.php @@ -2090,14 +2090,10 @@ function rest_are_values_equal( $value1, $value2 ) { if ( count( $value1 ) !== count( $value2 ) ) { return false; } - - foreach ( $value1 as $index => $value ) { - if ( ! array_key_exists( $index, $value2 ) || ! rest_are_values_equal( $value, $value2[ $index ] ) ) { - return false; - } - } - - return true; + return array_all( + $value1, + fn( $value, $index ) => array_key_exists( $index, $value2 ) && rest_are_values_equal( $value, $value2[ $index ] ) + ); } if ( is_int( $value1 ) && is_float( $value2 )