Checks whether the given block metadata collection path is valid against the list of collection roots.
Parameters
$path
stringrequired- Normalized block metadata collection path, without trailing slash.
$collection_roots
string[]required- List of normalized collection root paths, without trailing slashes.
Source
private static function is_valid_collection_path( $path, $collection_roots ) {
foreach ( $collection_roots as $allowed_root ) {
// If the path matches any root exactly, it is invalid.
if ( $allowed_root === $path ) {
return false;
}
// If the path is a parent path of any of the roots, it is invalid.
if ( str_starts_with( $allowed_root, $path ) ) {
return false;
}
}
return true;
}
Changelog
Version | Description |
---|---|
6.7.2 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.