WordPress开发者和主题制作者的搜索引擎



wp_make_link_relative ›

Since2.1.0
已弃用n/a
wp_make_link_relative ( $link )
参数:
  • (string) $link Full URL path.
    Required: Yes
返回:
  • (string) Absolute path.
定义在:
文档:
Change Log:
  • 4.1.0

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.



源码

function wp_make_link_relative( $link ) {
	return preg_replace( '|^(https?:)?//[^/]+(/?.*)|i', '$2', $link );
}