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
This commit is contained in:
Gary Pendergast 2019-04-08 23:06:52 +00:00
parent 4487551344
commit a932e9921b
2 changed files with 9 additions and 5 deletions

View File

@ -172,7 +172,11 @@ class Walker_Nav_Menu extends Walker {
$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 : '';
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' : '';

View File

@ -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.