函数原型
links_add_target( string $content, string $target = ‘_blank’, string[] $tags = array(‘a’) ): string
函数描述
Adds a Target attribute to all links in passed content.
是否弃用
未弃用
函数参数
-
$content
string
Required - String to search for links in.
-
$target
string
Optional - The Target to add to the links.
Default:
'_blank' -
$tags
string[]
Optional - An array of tags to apply to.
Default:
array('a')
函数返回值
string The processed content.
函数位置
File: wp-includes/formatting.php.
函数源码
function links_add_target( $content, $target = '_blank', $tags = array( 'a' ) ) {
global $_links_add_target;
$_links_add_target = $target;
$tags = implode( '|', (array) $tags );
return preg_replace_callback( "!<($tags)((\s[^>]*)?)>!i", '_links_add_target', $content );
}
源码链接
变更日志
| Version | Description |
|---|---|
| 2.7.0 | Introduced. |

