/**
* Helper function used to build the "rel" attribute for a URL when creating an anchor using make_clickable().
*
* @since 6.2.0
*
* @param string $url The URL.
* @return string The rel attribute for the anchor or an empty string if no rel attribute should be added.
*/
function _make_clickable_rel_attr( $url ) { $rel_parts = array
();
$scheme =
strtolower( wp_parse_url( $url, PHP_URL_SCHEME
) );
$nofollow_schemes =
array_intersect( wp_allowed_protocols(), array
( 'https', 'http'
) );
// Apply "nofollow" to external links with qualifying URL schemes (mailto:, tel:, etc... shouldn't be followed).
if ( !
wp_is_internal_link( $url ) &&
in_array( $scheme,
$nofollow_schemes, true
) ) { $rel_parts[] = 'nofollow';
} // Apply "ugc" when in comment context.
if ( 'comment_text' ===
current_filter() ) { $rel_parts[] = 'ugc';
}