diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index f5002a45de1e8..bfa0afd2feafe 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -3033,12 +3033,10 @@ function wp_ext2type( $ext ) { $ext = strtolower( $ext ); $ext2type = wp_get_ext_types(); - foreach ( $ext2type as $type => $exts ) { - if ( in_array( $ext, $exts, true ) ) { - return $type; - } - } - return null; + return array_find_key( + $ext2type, + fn( $exts ) => in_array( $ext, $exts, true ) + ); } /** diff --git a/src/wp-includes/interactivity-api/class-wp-interactivity-api.php b/src/wp-includes/interactivity-api/class-wp-interactivity-api.php index 62bfc29cfc03f..cdf13b13119e8 100644 --- a/src/wp-includes/interactivity-api/class-wp-interactivity-api.php +++ b/src/wp-includes/interactivity-api/class-wp-interactivity-api.php @@ -1387,15 +1387,12 @@ private function merge_style_property( string $style_attribute_value, string $st */ private function data_wp_text_processor( WP_Interactivity_API_Directives_Processor $p, string $mode ) { if ( 'enter' === $mode ) { - $entries = $this->get_directive_entries( $p, 'text' ); - $valid_entry = null; + $entries = $this->get_directive_entries( $p, 'text' ); // Get the first valid `data-wp-text` entry without suffix or unique ID. - foreach ( $entries as $entry ) { - if ( null === $entry['suffix'] && null === $entry['unique_id'] && ! empty( $entry['value'] ) ) { - $valid_entry = $entry; - break; - } - } + $valid_entry = array_find( + $entries, + fn( $entry ) => null === $entry['suffix'] && null === $entry['unique_id'] && ! empty( $entry['value'] ) + ); if ( null === $valid_entry ) { return; }