wp_targeted_link_rel( string $text )
Adds rel noreferrer and noopener to all HTML A elements that have a target.
Description Description
Parameters Parameters
- $text
-
(string) (Required) Content that may contain HTML A elements.
Return Return
(string) Converted content.
Source Source
File: wp-includes/formatting.php
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 ) { if ( ! is_serialized( $text ) ) { $text = preg_replace_callback( '|<a\s([^>]*target\s*=[^>]*)>|i', 'wp_targeted_link_rel_callback', $text ); } } return $text; }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
5.1.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
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
: