links_add_target() - WordPress 函数参考中文文档

返回介绍

links_add_target()

发布于 2017-09-11 字数1751 浏览 717 评论 0

links_add_target( string $content,  string $target = '_blank',  array $tags = array('a') )

Adds a Target attribute to all links in passed content.


描述

This function by default only applies to <a> tags, however this can be modified by the 3rd param.

_NOTE:_ Any current target attributed will be stripped and replaced.


参数

$content

(string)
(Required)
String to search for links in.

$target

(string)
(Optional)
The Target to add to the links.

Default value: ‘_blank’

$tags

(array)
(Optional)
An array of tags to apply to.

Default value: 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)([^>]*)>!i", '_links_add_target', $content );
}

更新日志

Version 描述
2.7.0 Introduced.

相关函数

Used By

  • wp-admin/includes/plugin-install.php:
    install_plugin_information()

User Contributed Notes

上一篇:links_add_base_url()

下一篇:links_popup_script()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!