Make WordPress Core


Ignore:
Timestamp:
10/19/2020 11:37:53 PM (3 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r49193 r49215  
    31543154
    31553155/**
    3156  * Adds rel noreferrer and noopener to all HTML A elements that have a target.
     3156 * Adds `rel="noopener"` to all HTML A elements that have a target.
    31573157 *
    31583158 * @since 5.1.0
     3159 * @since 5.6.0 Removed 'noreferrer' relationship.
    31593160 *
    31603161 * @param string $text Content that may contain HTML A elements.
     
    31893190
    31903191/**
    3191  * Callback to add rel="noreferrer noopener" string to HTML A element.
    3192  *
    3193  * Will not duplicate existing noreferrer and noopener values
    3194  * to prevent from invalidating the HTML.
     3192 * Callback to add `rel="noopener"` string to HTML A element.
     3193 *
     3194 * Will not duplicate an existing 'noopener' value to avoid invalidating the HTML.
    31953195 *
    31963196 * @since 5.1.0
    3197  *
    3198  * @param array $matches Single Match
    3199  * @return string HTML A Element with rel noreferrer noopener in addition to any existing values
     3197 * @since 5.6.0 Removed 'noreferrer' relationship.
     3198 *
     3199 * @param array $matches Single match.
     3200 * @return string HTML A Element with `rel="noopener"` in addition to any existing values.
    32003201 */
    32013202function wp_targeted_link_rel_callback( $matches ) {
     
    32203221     * @param string $link_html The matched content of the link tag including all HTML attributes.
    32213222     */
    3222     $rel = apply_filters( 'wp_targeted_link_rel', 'noopener noreferrer', $link_html );
     3223    $rel = apply_filters( 'wp_targeted_link_rel', 'noopener', $link_html );
    32233224
    32243225    // Return early if no rel values to be added or if no actual target attribute.
Note: See TracChangeset for help on using the changeset viewer.