esc_html__( 'Primary', 'pressbook' ), 'menu-2' => esc_html__( 'Top Menu', 'pressbook' ), 'social' => esc_html__( 'Social Links Menu', 'pressbook' ), ) ) ); } /** * Filter the HTML output of a nav menu item to add the dropdown button that reveal the sub-menu. * * @param string $item_output Nav menu item HTML. * @param object $item Nav menu item. * @param int $depth The depth of the menu. * @param array $args Array of menu args, such as theme location. * @return string Modified nav menu item HTML. */ public function add_dropdown_icons( $item_output, $item, $depth, $args ) { // Only add the sub-menu button to the main navigation. if ( 'menu-1' === $args->theme_location ) { // Skip if the item has no sub-menu. if ( in_array( 'menu-item-has-children', $item->classes, true ) ) { $item_output .= ''; } } return $item_output; } /** * Output HTML for the primary menu. */ public static function primary_menu() { if ( PrimaryNavbar::get_primary_navbar_search() ) { $search = ( '' ); } else { $search = ''; } wp_nav_menu( array( 'theme_location' => 'menu-1', 'menu_id' => 'primary-menu', 'items_wrap' => '', ) ); } /** * Get top menus class. * * @return string */ public static function top_menus_class() { $left_menu_active = has_nav_menu( 'social' ); $right_menu_active = has_nav_menu( 'menu-2' ); $top_menus_class = 'top-menus'; if ( $left_menu_active && $right_menu_active ) { $top_menus_class .= ' top-menus-left-right'; } elseif ( $left_menu_active ) { $top_menus_class .= ' top-menus-left'; } elseif ( $right_menu_active ) { $top_menus_class .= ' top-menus-right'; } return apply_filters( 'pressbook_top_menus_class', $top_menus_class ); } }