WordPress.org

Make WordPress Core

Ticket #43280: 43280.diff

File 43280.diff, 634 bytes (added by audrasjb, 2 years ago)

Adds default rel noopener attribute when using target blank in media widget and Link rel field is empty

  • 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 8a95135..3e8adc2 100644
    a b class WP_Widget_Media_Image extends WP_Widget_Media { 
    257257                                $link .= sprintf( ' rel="%s"', esc_attr( $instance['link_rel'] ) );
    258258                        }
    259259                        if ( ! empty( $instance['link_target_blank'] ) ) {
     260                                if ( empty( $instance['link_rel'] ) ) {
     261                                        $link .= ' rel="noopener"';
     262                                }       
    260263                                $link .= ' target="_blank"';
    261264                        }
    262265                        $link .= '>';