wp_rel_ugc()WP 5.3.0

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

No Hooks.

Return

String. Converted content.

Usage

wp_rel_ugc( $text );
$text(string) (required)
Content that may contain HTML A elements.

Changelog

Since 5.3.0 Introduced.

wp_rel_ugc() code WP 6.5.2

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