wp_targeted_link_rel()
Deprecated from version 6.7.0. It is no longer supported and can be removed in future releases. It is recommended to replace this function with the same one.
Adds rel noreferrer and noopener to all HTML A elements that have a target.
1 time — 0.000249 sec (fast) | 50000 times — 0.22 sec (very fast) | PHP 7.2.16, WP 5.2
No Hooks.
Return
String
. Converted content.
Usage
wp_targeted_link_rel( $text );
- $text(string) (required)
- Content that may contain HTML A elements.
Examples
#1 Demo
$text = 'Foo <a href="http://google.com" target="_blank">google</a> bar'; echo wp_targeted_link_rel( $text ); // Foo <a href="http://google.com" target="_blank" rel="noopener">google</a> bar
Since WP 5.1.0, we can add rel attributes to any bit of HTML code.
Example used in wp-includes/widgets/class-wp-widget-text.php:
$text = wp_targeted_link_rel( $text );
Changelog
Since 5.1.0 | Introduced. |
Since 5.6.0 | Removed 'noreferrer' relationship. |
Deprecated since | 6.7.0 |