WordPress开发者和主题制作者的搜索引擎



wp_targeted_link_rel ›

Sincen/a
已弃用n/a
wp_targeted_link_rel ( $text )
参数:
  • (string) $text Content that may contain HTML A elements.
    Required: Yes
返回:
  • (string) Converted content.
定义在:
文档:

Adds rel noreferrer and noopener to all HTML A elements that have a target.



源码

function wp_targeted_link_rel( $text ) {
	// Don't run (more expensive) regex if no links with targets.
	if ( stripos( $text, 'target' ) !== false && stripos( $text, '<a ' ) !== false ) {
		$text = preg_replace_callback( '|<a\s([^>]*target\s*=[^>]*)>|i', 'wp_targeted_link_rel_callback', $text );
	}

	return $text;
}