function twenty_twenty_one_add_sub_menu_toggle( $output,
$item,
$depth,
$args ) { if ( 0 ===
$depth &&
in_array( 'menu-item-has-children',
$item->classes, true
) ) { // Add toggle button.
$output .= '<button class="sub-menu-toggle" aria-expanded="false" onClick="twentytwentyoneExpandSubMenu(this)">';
$output .= '<span class="icon-plus">' .
twenty_twenty_one_get_icon_svg( 'ui', 'plus', 18
) . '</span>';
$output .= '<span class="icon-minus">' .
twenty_twenty_one_get_icon_svg( 'ui', 'minus', 18
) . '</span>';
/* translators: Hidden accessibility text. */
$output .= '<span class="screen-reader-text">' .
esc_html__( 'Open menu', 'twentytwentyone'
) . '</span>';
$output .= '</button>';
} return $output;
}add_filter( 'walker_nav_menu_start_el', 'twenty_twenty_one_add_sub_menu_toggle', 10, 4
);
/**
* Detects the social network from a URL and returns the SVG code for its icon.
*
* @since Twenty Twenty-One 1.0
*
* @param string $uri Social link.
* @param int $size The icon size in pixels.
* @return string
*/