wp_rel_ugc

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

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

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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_rel_ugc( $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 ugc' );
},
$text
);
return wp_slash( $text );
}
function wp_rel_ugc( $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 ugc' ); }, $text ); return wp_slash( $text ); }
function wp_rel_ugc( $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 ugc' );
		},
		$text
	);
	return wp_slash( $text );
}

常见问题

FAQs
查看更多 >