'; shesha_navigation_position(); echo ''; } } } if ( ! function_exists( 'shesha_add_navigation_before_left_sidebar' ) ) { add_action( 'shesha_before_left_sidebar_content', 'shesha_add_navigation_before_left_sidebar', 5 ); function shesha_add_navigation_before_left_sidebar() { if ( 'nav-left-sidebar' == shesha_get_navigation_location() ) { echo '
'; shesha_navigation_position(); echo '
'; } } } if ( ! class_exists( 'Shesha_Page_Walker' ) && class_exists( 'Walker_Page' ) ) { /** * Add current-menu-item to the current item if no theme location is set * This means we don't have to duplicate CSS properties for current_page_item and current-menu-item * */ class Shesha_Page_Walker extends Walker_Page { function start_el( &$output, $page, $depth = 0, $args = array(), $current_page = 0 ) { $css_class = array( 'page_item', 'page-item-' . $page->ID ); $button = ''; if ( isset( $args['pages_with_children'][ $page->ID ] ) ) { $css_class[] = 'menu-item-has-children'; $button = ''; } if ( ! empty( $current_page ) ) { $_current_page = get_post( $current_page ); if ( $_current_page && in_array( $page->ID, $_current_page->ancestors ) ) { $css_class[] = 'current-menu-ancestor'; } if ( $page->ID == $current_page ) { $css_class[] = 'current-menu-item'; } elseif ( $_current_page && $page->ID == $_current_page->post_parent ) { $css_class[] = 'current-menu-parent'; } } elseif ( $page->ID == get_option('page_for_posts') ) { $css_class[] = 'current-menu-parent'; } $css_classes = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) ); $args['link_before'] = empty( $args['link_before'] ) ? '' : $args['link_before']; $args['link_after'] = empty( $args['link_after'] ) ? '' : $args['link_after']; $output .= sprintf( '
  • %s%s%s%s', $css_classes, get_permalink( $page->ID ), $args['link_before'], apply_filters( 'the_title', $page->post_title, $page->ID ), $args['link_after'], $button ); } } } if ( ! function_exists( 'shesha_dropdown_icon_to_menu_link' ) ) { add_filter( 'nav_menu_item_title', 'shesha_dropdown_icon_to_menu_link', 10, 4 ); /** * Add dropdown icon if menu item has children. * * * @param string $title The menu item title. * @param WP_Post $item All of our menu item data. * @param stdClass $args All of our menu item args. * @param int $dept Depth of menu item. * @return string The menu item. */ function shesha_dropdown_icon_to_menu_link( $title, $item, $args, $depth ) { $role = 'presentation'; $tabindex = ''; if ( 'click-arrow' === shesha_get_setting( 'nav_dropdown_type' ) ) { $role = 'button'; $tabindex = ' tabindex="0"'; } // Loop through our menu items and add our dropdown icons. if ( 'main-nav' === $args->container_class ) { foreach ( $item->classes as $value ) { if ( 'menu-item-has-children' === $value ) { $title = $title . ''; } } } // Return our title. return $title; } } if ( ! function_exists( 'shesha_navigation_search' ) ) { add_action( 'shesha_inside_navigation', 'shesha_navigation_search' ); /** * Add the search bar to the navigation. * */ function shesha_navigation_search() { $shesha_settings = wp_parse_args( get_option( 'shesha_settings', array() ), shesha_get_defaults() ); if ( 'enable' !== $shesha_settings['nav_search'] ) { return; } echo get_search_form(); } } if ( ! function_exists( 'shesha_menu_search_icon' ) ) { add_filter( 'wp_nav_menu_items', 'shesha_menu_search_icon', 10, 2 ); /** * Add search icon to primary menu if set * * * @param string $nav The HTML list content for the menu items. * @param stdClass $args An object containing wp_nav_menu() arguments. * @return string The search icon menu item. */ function shesha_menu_search_icon( $nav, $args ) { $shesha_settings = wp_parse_args( get_option( 'shesha_settings', array() ), shesha_get_defaults() ); // If the search icon isn't enabled, return the regular nav. if ( 'enable' !== $shesha_settings['nav_search'] ) { return $nav; } // If our primary menu is set, add the search icon. if ( $args->theme_location == 'primary' ) { return $nav . '
  • ' . _x( 'Search', 'submit button', 'shesha' ) . '
  • '; } // Our primary menu isn't set, return the regular nav. // In this case, the search icon is added to the shesha_menu_fallback() function in navigation.php. return $nav; } } if ( ! function_exists( 'shesha_mobile_menu_search_icon' ) ) { add_action( 'shesha_inside_navigation', 'shesha_mobile_menu_search_icon' ); /** * Add search icon to mobile menu bar * */ function shesha_mobile_menu_search_icon() { $shesha_settings = wp_parse_args( get_option( 'shesha_settings', array() ), shesha_get_defaults() ); // If the search icon isn't enabled, return the regular nav. if ( 'enable' !== $shesha_settings['nav_search'] ) { return; } ?>