diff --git a/wp_bem_menu.php b/wp_bem_menu.php index 6d2dd583..17ca09bc 100644 --- a/wp_bem_menu.php +++ b/wp_bem_menu.php @@ -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