You appear to be a bot. Output may be restricted
Description
Adds a Sub Nav Toggle to the Expanded Menu and Mobile Menu.
Usage
$stdClass = twentytwenty_add_sub_toggles_to_main_menu( $args, $item, $depth );
Parameters
- $args
- ( stdClass ) required – An object of wp_nav_menu() arguments.
- $item
- ( WP_Post ) required – Menu item data object.
- $depth
- ( int ) required – Depth of menu item. Used for padding.
Returns
stdClass An object of wp_nav_menu() arguments.
Source
File name: twentytwenty/inc/template-tags.php
Lines:
1 to 35 of 35
function twentytwenty_add_sub_toggles_to_main_menu( $args, $item, $depth ) { // Add sub menu toggles to the Expanded Menu with toggles. if ( isset( $args->show_toggles ) && $args->show_toggles ) { // Wrap the menu item link contents in a div, used for positioning. $args->before = '<div class="ancestor-wrapper">'; $args->after = ''; // Add a toggle to items with children. if ( in_array( 'menu-item-has-children', $item->classes, true ) ) { $toggle_target_string = '.menu-modal .menu-item-' . $item->ID . ' > .sub-menu'; $toggle_duration = twentytwenty_toggle_duration(); // Add the sub menu toggle. $args->after .= '<button class="toggle sub-menu-toggle fill-children-current-color" data-toggle-target="' . $toggle_target_string . '" data-toggle-type="slidetoggle" data-toggle-duration="' . absint( $toggle_duration ) . '" aria-expanded="false"><span class="screen-reader-text">' . __( 'Show sub menu', 'twentytwenty' ) . '</span>' . twentytwenty_get_theme_svg( 'chevron-down' ) . '</button>'; } // Close the wrapper. $args->after .= '</div><!-- .ancestor-wrapper -->'; // Add sub menu icons to the primary menu without toggles. } elseif ( 'primary' === $args->theme_location ) { if ( in_array( 'menu-item-has-children', $item->classes, true ) ) { $args->after = '<span class="icon"></span>'; } else { $args->after = ''; } } return $args; }