From a932e9921b792ffa9b32b376db7b2ca866202c8a Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Mon, 8 Apr 2019 23:06:52 +0000 Subject: [PATCH] Menus: Add `rel="noopener"` to `target="_blank"` links by default in menus. This expands upon `rel="noopener"` being previously added to links in the content. Props audrasjb, welcher. Fixes #43290. Built from https://develop.svn.wordpress.org/trunk@45141 git-svn-id: http://core.svn.wordpress.org/trunk@44950 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-walker-nav-menu.php | 12 ++++++++---- wp-includes/version.php | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/wp-includes/class-walker-nav-menu.php b/wp-includes/class-walker-nav-menu.php index f46f14c177..171243b1b9 100644 --- a/wp-includes/class-walker-nav-menu.php +++ b/wp-includes/class-walker-nav-menu.php @@ -169,10 +169,14 @@ class Walker_Nav_Menu extends Walker { $output .= $indent . ''; - $atts = array(); - $atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : ''; - $atts['target'] = ! empty( $item->target ) ? $item->target : ''; - $atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : ''; + $atts = array(); + $atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : ''; + $atts['target'] = ! empty( $item->target ) ? $item->target : ''; + if ( '_blank' === $item->target && empty( $item->xfn ) ) { + $atts['rel'] = 'noopener noreferrer'; + } else { + $atts['rel'] = $item->xfn; + } $atts['href'] = ! empty( $item->url ) ? $item->url : ''; $atts['aria-current'] = $item->current ? 'page' : ''; diff --git a/wp-includes/version.php b/wp-includes/version.php index 956342dd54..4628cc9308 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.2-beta1-45140'; +$wp_version = '5.2-beta1-45141'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.