Skip to content

Commit

Permalink
Merge pull request #444 from IanDelMar/noopener-noreferrer
Browse files Browse the repository at this point in the history
Add rel="noopener noreferrer" to target="_blank"
  • Loading branch information
pattonwebz committed Jul 20, 2020
2 parents 2cb4731 + d14a4cc commit 08ce767
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions class-wp-bootstrap-navwalker.php
Expand Up @@ -207,8 +207,12 @@ public function start_el( &$output, $item, $depth = 0, $args = null, $id = 0 ) {
}

$atts['target'] = ! empty( $item->target ) ? $item->target : '';
$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : '';
// If the item has children, add atts to the <a>.
if ( '_blank' === $item->target && empty( $item->xfn ) ) {
$atts['rel'] = 'noopener noreferrer';
} else {
$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : '';
}
// If the item has_children add atts to <a>.
if ( isset( $args->has_children ) && $args->has_children && 0 === $depth && $args->depth > 1 ) {
$atts['href'] = '#';
$atts['data-toggle'] = 'dropdown';
Expand Down

0 comments on commit 08ce767

Please sign in to comment.