Improvements to wp_make_link_relative().

* Support relative URL input.
* When the URL being made relative has another URL as a parameter, don't make the second URL relative.

Props voldemortensen.
Fixes #30373.
Built from https://develop.svn.wordpress.org/trunk@30383


git-svn-id: http://core.svn.wordpress.org/trunk@30380 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2014-11-19 01:53:24 +00:00
parent e34a587ea6
commit d95b5196cc

View File

@ -3239,7 +3239,7 @@ function tag_escape($tag_name) {
* @return string Absolute path.
*/
function wp_make_link_relative( $link ) {
return preg_replace( '|https?://[^/]+(/.*)|i', '$1', $link );
return preg_replace( '|^(https?:)?//[^/]+(/.*)|i', '$2', $link );
}
/**