wp_rel_nofollow

函数
wp_rel_nofollow ( $text )
参数
  • (string) $text Content that may contain HTML A elements.
    Required:
返回值
  • (string) Converted content.
定义位置
相关方法
wp_rel_nofollow_callbackwp_kses_no_nullwp_rel_callbackwp_rel_ugcwp_preload_dialogs
引入
1.5.0
弃用
-

wp_rel_nofollow: 这个函数用于向一个链接添加rel=”nofollow”属性。它接受几个参数,包括链接的属性。

为内容中的所有HTML A元素添加`rel="nofollow"`字符串。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_rel_nofollow( $text ) {
// This is a pre-save filter, so text is already escaped.
$text = stripslashes( $text );
$text = preg_replace_callback(
'|<a (.+?)>|i',
static function( $matches ) {
return wp_rel_callback( $matches, 'nofollow' );
},
$text
);
return wp_slash( $text );
}
function wp_rel_nofollow( $text ) { // This is a pre-save filter, so text is already escaped. $text = stripslashes( $text ); $text = preg_replace_callback( '|<a (.+?)>|i', static function( $matches ) { return wp_rel_callback( $matches, 'nofollow' ); }, $text ); return wp_slash( $text ); }
function wp_rel_nofollow( $text ) {
	// This is a pre-save filter, so text is already escaped.
	$text = stripslashes( $text );
	$text = preg_replace_callback(
		'|<a (.+?)>|i',
		static function( $matches ) {
			return wp_rel_callback( $matches, 'nofollow' );
		},
		$text
	);
	return wp_slash( $text );
}

常见问题

FAQs
查看更多 >