Make WordPress Core

Ticket #43280: 43280.5.diff

File 43280.5.diff, 1.1 KB (added by audrasjb, 5 years ago)

Use wp_targeted_link_rel() to add rel attributes

  • src/wp-includes/widgets/class-wp-widget-media-image.php

    diff --git a/src/wp-includes/widgets/class-wp-widget-media-image.php b/src/wp-includes/widgets/class-wp-widget-media-image.php
    index 2b9bff2..ef631b2 100644
    a b class WP_Widget_Media_Image extends WP_Widget_Media { 
    266266                        $link .= '>';
    267267                        $link .= $image;
    268268                        $link .= '</a>';
    269                         $image = $link;
     269                        $image = wp_targeted_link_rel( $link );
    270270                }
    271271
    272272                if ( $caption ) {
  • tests/phpunit/tests/widgets/media-image-widget.php

    diff --git a/tests/phpunit/tests/widgets/media-image-widget.php b/tests/phpunit/tests/widgets/media-image-widget.php
    index e138f3e..78d55fc 100644
    a b class Test_WP_Widget_Media_Image extends WP_UnitTestCase { 
    509509
    510510                $this->assertContains( '<a href="https://example.org"', $output );
    511511                $this->assertContains( 'target="_blank"', $output );
     512                $this->assertContains( 'rel="noopener noreferrer"', $output );
    512513
    513514                // Populate caption in attachment.
    514515                wp_update_post(