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"`字串。

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
檢視更多 >