Tribe__Rewrite::get_clean_url( string $url, bool $force = false )
Returns the “clean” version of a URL.
Contents
The URL is first parsed then resolved to a canonical URL. As an example the URL /events/list/?post_type=tribe_events is "dirty" in that the post_type query variable is redundant. The clean version of the URL is /events/list/, where the query variable is removed.
Parameters
- $url
-
(string) (Required) The URL to clean.
- $force
-
(bool) (Optional) Whether to try and use the cache or force a new URL cleaning run.
Default value: false
Return
(string) The cleaned URL, or the input URL if it could not be resolved to a clean one.
Source
File: src/Tribe/Rewrite.php
public function get_clean_url( $url, $force = false ) {
if ( ! $force ) {
$this->warmup_cache(
'clean_url',
WEEK_IN_SECONDS,
Listener::TRIGGER_GENERATE_REWRITE_RULES
);
if ( isset( $this->clean_url_cache[ $url ] ) ) {
return $this->clean_url_cache[ $url ];
}
}
$parsed_vars = $this->parse_request( $url );
if ( empty( $parsed_vars ) ) {
return home_url();
}
$clean = $this->get_canonical_url( add_query_arg( $parsed_vars, home_url() ) );
$this->clean_url_cache[ $url ] = $clean;
return $clean;
}
Changelog
| Version | Description |
|---|---|
| 4.9.11 | Introduced. |