mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-09 07:04:34 +00:00
General: Remove noreferrer from wp_targeted_link_rel() and other uses.
When `noopener noreferrer` was originally added in #37941 and related tickets, the `noreferrer` bit was specifically included due to Firefox not supporting `noopener` at the time. Since `noopener` has been supported by all major browsers for a while, it should now be safe to remove the `noreferrer` attribute from core. Props Mista-Flo, audrasjb, joostdevalk, jonoaldersonwp, peterwilsoncc, elgameel. Fixes #49558. git-svn-id: https://develop.svn.wordpress.org/trunk@49215 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -3153,9 +3153,10 @@ function wp_rel_ugc( $text ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds rel noreferrer and noopener to all HTML A elements that have a target.
|
||||
* Adds `rel="noopener"` to all HTML A elements that have a target.
|
||||
*
|
||||
* @since 5.1.0
|
||||
* @since 5.6.0 Removed 'noreferrer' relationship.
|
||||
*
|
||||
* @param string $text Content that may contain HTML A elements.
|
||||
* @return string Converted content.
|
||||
@@ -3188,15 +3189,15 @@ function wp_targeted_link_rel( $text ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to add rel="noreferrer noopener" string to HTML A element.
|
||||
* Callback to add `rel="noopener"` string to HTML A element.
|
||||
*
|
||||
* Will not duplicate existing noreferrer and noopener values
|
||||
* to prevent from invalidating the HTML.
|
||||
* Will not duplicate an existing 'noopener' value to avoid invalidating the HTML.
|
||||
*
|
||||
* @since 5.1.0
|
||||
* @since 5.6.0 Removed 'noreferrer' relationship.
|
||||
*
|
||||
* @param array $matches Single Match
|
||||
* @return string HTML A Element with rel noreferrer noopener in addition to any existing values
|
||||
* @param array $matches Single match.
|
||||
* @return string HTML A Element with `rel="noopener"` in addition to any existing values.
|
||||
*/
|
||||
function wp_targeted_link_rel_callback( $matches ) {
|
||||
$link_html = $matches[1];
|
||||
@@ -3219,7 +3220,7 @@ function wp_targeted_link_rel_callback( $matches ) {
|
||||
* @param string $rel The rel values.
|
||||
* @param string $link_html The matched content of the link tag including all HTML attributes.
|
||||
*/
|
||||
$rel = apply_filters( 'wp_targeted_link_rel', 'noopener noreferrer', $link_html );
|
||||
$rel = apply_filters( 'wp_targeted_link_rel', 'noopener', $link_html );
|
||||
|
||||
// Return early if no rel values to be added or if no actual target attribute.
|
||||
if ( ! $rel || ! isset( $atts['target'] ) ) {
|
||||
|
||||
Reference in New Issue
Block a user