Make WordPress Core

Ticket #46421: 46421.diff

File 46421.diff, 1.4 KB (added by audrasjb, 5 years ago)

Add rel noopener/noreferrer to both Widgets Text and Custom HTML

  • src/wp-includes/widgets/class-wp-widget-custom-html.php

    diff --git a/src/wp-includes/widgets/class-wp-widget-custom-html.php b/src/wp-includes/widgets/class-wp-widget-custom-html.php
    index 5d2b28a..a0f878f 100644
    a b class WP_Widget_Custom_HTML extends WP_Widget { 
    143143                /** This filter is documented in wp-includes/widgets/class-wp-widget-text.php */
    144144                $content = apply_filters( 'widget_text', $instance['content'], $simulated_text_widget_instance, $this );
    145145
     146                // Adds rel noreferrer and noopener to all HTML A elements that have a target.
     147                $content = wp_targeted_link_rel( $content );
     148
    146149                /**
    147150                 * Filters the content of the Custom HTML widget.
    148151                 *
  • src/wp-includes/widgets/class-wp-widget-text.php

    diff --git a/src/wp-includes/widgets/class-wp-widget-text.php b/src/wp-includes/widgets/class-wp-widget-text.php
    index 8db1735..7ca5c73 100644
    a b class WP_Widget_Text extends WP_Widget { 
    328328
    329329                $text = preg_replace_callback( '#<(video|iframe|object|embed)\s[^>]*>#i', array( $this, 'inject_video_max_width_style' ), $text );
    330330
     331                // Adds rel noreferrer and noopener to all HTML A elements that have a target.
     332                $text = wp_targeted_link_rel( $text );
     333
    331334                ?>
    332335                        <div class="textwidget"><?php echo $text; ?></div>
    333336                <?php