Skip to content

Commit 4a41e8d

Browse files
committed
fix(Utils): REST NS function check
1 parent 1c46f8a commit 4a41e8d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Request.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public static function should_load_rest_ns( string $space, ?string $route = null
2626

2727
$route = \trailingslashit( \ltrim( $route, '/' ) );
2828
$space = \trailingslashit( $space );
29+
$known = \array_map( 'trailingslashit', $known );
2930

3031
/**
3132
* Known namespaces that we know are safe to not load if the request is not for them.
@@ -38,11 +39,11 @@ public static function should_load_rest_ns( string $space, ?string $route = null
3839
*
3940
* @since 1.16.0
4041
*/
41-
$known = \apply_filters( 'xwp_known_rest_namespaces', $known, $space, $route );
42-
43-
if ( ! \array_reduce( $known, static fn( $c, $r ) => $c || \str_starts_with( $route, $r ), false ) ) {
44-
return true;
45-
}
42+
foreach ( \apply_filters( 'xwp_known_rest_namespaces', $known, $space, $route ) as $k ) {
43+
if ( \str_starts_with( $route, $k ) ) {
44+
return true;
45+
}
46+
}
4647

4748
$load = \str_starts_with( $route, $space );
4849

0 commit comments

Comments
 (0)