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:
@@ -169,10 +169,14 @@ class Walker_Nav_Menu extends Walker {
|
||||
|
||||
$output .= $indent . '<li' . $id . $class_names . '>';
|
||||
|
||||
$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' : '';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user