wp_rel_nofollow( string $text ): string

In this article

Adds rel="nofollow" string to all HTML A elements in content.

Parameters

$textstringrequired
Content that may contain HTML A elements.

Return

string Converted content.

Source

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 );
}

Changelog

VersionDescription
1.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.