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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: