noptin_clean_url( string $url = '' )
Returns the hostname and path of a url.
Parameters Parameters
- $url
(string) (Optional) The url to parse.
Default value: ''
Return Return
(string)
Source Source
File: includes/functions.php
function noptin_clean_url( $url = '' ) { // If no url is passed, use the current url. if ( empty( $url ) ) { $url = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; } // Remove query variables $clean_url = strtok( $url, '?' ); // Remove the scheme and www parts. $clean_url = preg_replace('#^(http(s)?://)?(www\.)?(.+\.)#i', '$4', $clean_url ); // Take care of edge cases $clean_url = preg_replace('#^http(s)?://#i', '', $clean_url ); // remove forwad slash at the end of the url $clean_url = strtolower( untrailingslashit( $clean_url ) ); return apply_filters( 'noptin_clean_url', $clean_url, $url ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
1.2.4 | Introduced. |