Automattic\WooCommerce\Internal\Utilities
URL::get_all_parent_urls
Returns all possible parent URLs for the current URL.
Method of the class: URL{}
No Hooks.
Returns
String[].
Usage
$URL = new URL(); $URL->get_all_parent_urls(): array;
URL::get_all_parent_urls() URL::get all parent urls code WC 10.5.0
public function get_all_parent_urls(): array {
$max_parent = count( $this->path_parts );
$parents = array();
/*
* If we are looking at a relative path that begins with at least one traversal (example: "../../foo")
* then we should only return one parent URL (otherwise, we'd potentially have to return an infinite
* number of parent URLs since we can't know how far the tree extends).
*/
if ( $max_parent > 0 && ! $this->is_absolute && '..' === $this->path_parts[0] ) {
$max_parent = 1;
}
for ( $level = 1; $level <= $max_parent; $level++ ) {
$parents[] = $this->get_parent_url( $level );
}
return $parents;
}