Make WordPress Core


Ignore:
Timestamp:
09/30/2024 05:17:54 AM (7 months ago)
Author:
peterwilsoncc
Message:

General: Remove noopener from links opening in a new tab.

Removes the automatic addition of rel="noopener noreferrer" from links targeting a new tab or window, target='_blank'. Since this was introduced, supported browsers have changed their security policies and no longer allow the opened link to have JavaScript access to the previous tab.

Deprecates:

  • wp_targeted_link_rel()
  • wp_targeted_link_rel_callback()
  • wp_init_targeted_link_rel_filters(): converted to a noop function
  • wp_remove_targeted_link_rel_filters(): converted to a noop function

The deprecated functions are retained in formatting.php as in SHORTINIT mode the file is included while deprecated.php is not.

This also removes the noopener from links hard coded within the WordPress dashboard linking to documentation and other resources.

Props audrasjb, azaozz, dhruval04, dorzki, neo2k23, presskopp, sabernhardt, swissspidy, tobiasbg.
Fixes #53843.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-site-health.php

    r58913 r59120  
    747747            ),
    748748            'actions'     => sprintf(
    749                 '<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
     749                '<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
    750750                esc_url( wp_get_update_php_url() ),
    751751                __( 'Learn more about updating PHP' ),
     
    893893                    /* translators: Localized team handbook, if one exists. */
    894894                    esc_url( __( 'https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions' ) ),
    895                     'target="_blank" rel="noopener"',
     895                    'target="_blank"',
    896896                    sprintf(
    897897                        '<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span>',
     
    12191219            ),
    12201220            'actions'     => sprintf(
    1221                 '<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
     1221                '<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
    12221222                /* translators: Localized version of WordPress requirements if one exists. */
    12231223                esc_url( __( 'https://wordpress.org/about/requirements/' ) ),
     
    13361336
    13371337            $result['actions'] = sprintf(
    1338                 '<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
     1338                '<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
    13391339                /* translators: Localized Support reference. */
    13401340                esc_url( __( 'https://wordpress.org/support/forums/' ) ),
     
    13741374            ),
    13751375            'actions'     => sprintf(
    1376                 '<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
     1376                '<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
    13771377                /* translators: Documentation explaining debugging in WordPress. */
    13781378                esc_url( __( 'https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/' ) ),
     
    14561456            ),
    14571457            'actions'     => sprintf(
    1458                 '<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
     1458                '<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
    14591459                esc_url( $default_update_url ),
    14601460                __( 'Learn more about why you should use HTTPS' ),
     
    15401540                    if ( ! empty( $direct_update_url ) ) {
    15411541                        $result['actions'] = sprintf(
    1542                             '<p class="button-container"><a class="button button-primary" href="%1$s" target="_blank" rel="noopener">%2$s<span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
     1542                            '<p class="button-container"><a class="button button-primary" href="%1$s" target="_blank">%2$s<span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
    15431543                            esc_url( $direct_update_url ),
    15441544                            __( 'Update your site to use HTTPS' ),
     
    15591559                if ( $update_url !== $default_update_url ) {
    15601560                    $result['description'] .= sprintf(
    1561                         '<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
     1561                        '<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
    15621562                        esc_url( $update_url ),
    15631563                        __( 'Talk to your web host about supporting HTTPS for your website.' ),
     
    23652365        } else {
    23662366            $result['actions'] .= sprintf(
    2367                 '<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
     2367                '<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
    23682368                __( 'https://developer.wordpress.org/rest-api/frequently-asked-questions/#why-is-authentication-not-working' ),
    23692369                __( 'Learn how to configure the Authorization header.' ),
     
    23982398            'label'       => '',
    23992399            'actions'     => sprintf(
    2400                 '<p><a href="%1$s" target="_blank" rel="noopener noreferrer">%2$s<span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
     2400                '<p><a href="%1$s" target="_blank" rel="noreferrer">%2$s<span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
    24012401                __( 'https://developer.wordpress.org/advanced-administration/performance/optimization/#caching' ),
    24022402                __( 'Learn more about page cache' ),
     
    25242524            ),
    25252525            'actions'     => sprintf(
    2526                 '<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
     2526                '<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
    25272527                esc_url( $action_url ),
    25282528                __( 'Learn more about persistent object caching.' ),
     
    26722672        $result['actions'] = sprintf(
    26732673            /* translators: 1: HelpHub URL, 2: Link description. */
    2674             '<p><a target="_blank" rel="noopener" href="%1$s">%2$s</a></p>',
     2674            '<p><a target="_blank" href="%1$s">%2$s</a></p>',
    26752675            esc_url( __( 'https://developer.wordpress.org/advanced-administration/performance/optimization/#autoloaded-options' ) ),
    26762676            __( 'More info about optimizing autoloaded options' )
Note: See TracChangeset for help on using the changeset viewer.