函数原型
links_add_base_url( string $content, string $base, array $attrs = array(‘src’, ‘href’) ): string
函数描述
Adds a base URL to relative links in passed content.
是否弃用
未弃用
函数参数
-
$content
string
Required - String to search for links in.
-
$base
string
Required - The base URL to prefix to links.
-
$attrs
array
Optional - The attributes which should be processed.
Default:
array('src', 'href')
函数返回值
string The processed content.
函数位置
File: wp-includes/formatting.php.
函数源码
function links_add_base_url( $content, $base, $attrs = array( 'src', 'href' ) ) {
global $_links_add_base;
$_links_add_base = $base;
$attrs = implode( '|', (array) $attrs );
return preg_replace_callback( "!($attrs)=(['\"])(.+?)\\2!i", '_links_add_base', $content );
}
源码链接
变更日志
| Version | Description |
|---|---|
| 2.7.0 | Introduced. |

