links_add_base_url()
最后更新于:2021-11-27 12:56:24
links_add_base_url( string$content, string$base, array$attrs=array(‘src’, ‘href’))Add 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 value: array(‘src’, ‘href’)
响应
(string) The processed content.
源文件
文件: gc-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 );
}