function add_search_box($items, $args)
{
    if ($args->theme_location == 'we-main-nav-mobile') {
        $search_args = 'Search';
        $items .= '<li id="mobile-search" class="menu-item menu-item-type-post_type menu-item-object-page">' . headway_get_search_form($search_args) . '</li>';
    }
    return $items;
}
Example #2
0
 function content($block)
 {
     self::$block = $block;
     /* Add filter to add home link */
     add_filter('wp_nav_menu_items', array(__CLASS__, 'home_link_filter'));
     add_filter('wp_list_pages', array(__CLASS__, 'home_link_filter'));
     add_filter('wp_page_menu', array(__CLASS__, 'fix_legacy_nav'));
     /* Variables */
     $vertical = parent::get_setting($block, 'vert-nav-box', false);
     $alignment = parent::get_setting($block, 'alignment', 'left');
     $search = parent::get_setting($block, 'enable-nav-search', false);
     $search_position = parent::get_setting($block, 'nav-search-position', 'right');
     $hide_home_link = parent::get_setting($block, 'hide-home-link', false);
     /* Classes */
     $nav_classes = array();
     $nav_classes[] = $vertical ? 'nav-vertical' : 'nav-horizontal';
     $nav_classes[] = 'nav-align-' . $alignment;
     if ($search && !$vertical) {
         $nav_classes[] = 'nav-search-active';
         $nav_classes[] = 'nav-search-position-' . $search_position;
     }
     $nav_classes = trim(implode(' ', array_unique($nav_classes)));
     $nav_location = 'navigation_block_' . $block['id'];
     echo '<div class="' . $nav_classes . '">';
     $nav_menu_args = array('theme_location' => $nav_location, 'container' => false);
     if (HeadwayRoute::is_grid() || headway_get('ve-live-content-query', $block)) {
         $nav_menu_args['link_before'] = '<span>';
         $nav_menu_args['link_after'] = '</span>';
     }
     wp_nav_menu(apply_filters('headway_navigation_block_query_args', $nav_menu_args, $block));
     if ($search && !$vertical) {
         echo '<div class="nav-search">';
         echo headway_get_search_form(parent::get_setting($block, 'nav-search-placeholder', null));
         echo '</div>';
     }
     echo '</div><!-- .' . $nav_classes . ' -->';
     /* Remove filter for home link so other non-navigation blocks are modified */
     remove_filter('wp_nav_menu_items', array(__CLASS__, 'home_link_filter'));
     remove_filter('wp_list_pages', array(__CLASS__, 'home_link_filter'));
     remove_filter('wp_page_menu', array(__CLASS__, 'fix_legacy_nav'));
 }
Example #3
0
 public static function search_form()
 {
     return headway_get_search_form();
 }