On this page
wp_make_link_relative( string $link ): string
Converts full URL paths to absolute paths.
Description
Removes the http or https protocols and the domain. Keeps the path ‘/’ at the beginning, so it isn’t a true relative link, but from the web root base.
Parameters
$linkstring Required-
Full URL path.
Return
string Absolute path.
Source
File: wp-includes/formatting.php. View all references
function wp_make_link_relative( $link ) {
return preg_replace( '|^(https?:)?//[^/]+(/?.*)|i', '$2', $link );
}
Related
Used By
| Used By | Description |
|---|---|
| _wp_theme_json_webfonts_handler() wp-includes/script-loader.php | Runs the theme.json webfonts handler. |
| _wp_normalize_relative_css_links() wp-includes/script-loader.php | Makes URLs relative to the WordPress installation. |
Changelog
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_make_link_relative