Skip to content

Commit

Permalink
Merge pull request #4 from level-level/feature/adds-noopener
Browse files Browse the repository at this point in the history
Adds rel noopener to external links
  • Loading branch information
kevinpoot authored Oct 6, 2021
2 parents e326068 + 36957aa commit 3a1a9e0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions wp_bem_menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) . '"' : '';
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) . '"' : '';

// Add 'noopener' to external links without a set xfn
if ( empty( $item->xfn ) && ! empty( $item->target ) ) {
$attributes .= " rel='noopener'";
}

$attributes = apply_filters( 'bem_menu_link_attributes', $attributes, $item );

// Create link markup
Expand Down

0 comments on commit 3a1a9e0

Please sign in to comment.