wp_make_link_relative()
wp_make_link_relative( string $link ) 将完整的URL路径转换为绝对路径。…
wp_make_link_relative( string $link )
将完整的URL路径转换为绝对路径。
Convert full URL paths to absolute paths.
将完整的URL路径转换为绝对路径。
Convert full URL paths to absolute paths.
目录锚点:#说明#参数#源码#笔记
说明(Description)
删除http或https协议和域。将路径“/”保留在开头,因此它不是真正的相对链接,而是来自web根目录。
参数(Parameters)
| 参数 | 类型 | 说明 |
|---|---|---|
| $link | (string) | 完整的URL路径。 |
源码(Source)
/**
* 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.
*
* @since 2.1.0
* @since 4.1.0 Support was added for relative URLs.
*
* @param string $link Full URL path.
* @return string Absolute path.
*/
function wp_make_link_relative( $link ) {
return preg_replace( '|^(https?:)?//[^/]+(/.*)|i', '$2', $link );
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 4.1.0 | wp-includes/formatting.php | 18 | 8 |
笔记(Notes)
基本示例
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。
还没有任何评论,赶紧来占个楼吧!