wp_make_link_relative

Definition:
function wp_make_link_relative( $link ) {}

Convert full URL paths to absolute paths.
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

  • string $link: Full URL path.

Return values

returns:Absolute path.

Source code

function wp_make_link_relative( $link ) {

	return preg_replace( '|https?://[^/]+(/.*)|i', '$1', $link );

}

3895

No comments yet... Be the first to leave a reply!

Leave a comment