diff --git src/wp-includes/widgets/class-wp-widget-media-image.php src/wp-includes/widgets/class-wp-widget-media-image.php
index 2b9bff221b..a0359bcbfd 100644
|
|
|
class WP_Widget_Media_Image extends WP_Widget_Media {
|
| 261 | 261 | $link .= sprintf( ' rel="%s"', esc_attr( $instance['link_rel'] ) ); |
| 262 | 262 | } |
| 263 | 263 | if ( ! empty( $instance['link_target_blank'] ) ) { |
| | 264 | if ( empty( $instance['link_rel'] ) ) { |
| | 265 | $link .= ' rel="noopener noreferrer"'; |
| | 266 | } |
| 264 | 267 | $link .= ' target="_blank"'; |
| 265 | 268 | } |
| 266 | 269 | $link .= '>'; |
diff --git tests/phpunit/tests/widgets/media-image-widget.php tests/phpunit/tests/widgets/media-image-widget.php
index e138f3e796..78d55fc09d 100644
|
|
|
class Test_WP_Widget_Media_Image extends WP_UnitTestCase {
|
| 509 | 509 | |
| 510 | 510 | $this->assertContains( '<a href="https://example.org"', $output ); |
| 511 | 511 | $this->assertContains( 'target="_blank"', $output ); |
| | 512 | $this->assertContains( 'rel="noopener noreferrer"', $output ); |
| 512 | 513 | |
| 513 | 514 | // Populate caption in attachment. |
| 514 | 515 | wp_update_post( |