-
-
Save billerickson/15c2d38053727ff12f321fbc1f840ca6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Primary Menu Extras | |
* | |
*/ | |
function ea_primary_menu_extras( $menu, $args ) { | |
if( 'primary' == $args->theme_location ) | |
$menu .= '<li class="menu-item search"><a href="#" class="search-toggle"><i class="icon-search"></i></a>' . get_search_form( false ) . '</li>'; | |
return $menu; | |
} | |
add_filter( 'wp_nav_menu_items', 'ea_primary_menu_extras', 10, 2 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(function($){ | |
// Search toggle | |
$('.nav-primary .search-toggle').click(function(e){ | |
e.preventDefault(); | |
$(this).parent().toggleClass('active').find('input[type="search"]').focus(); | |
}); | |
$('.search-submit').click(function(e){ | |
if( $(this).parent().find('.search-field').val() == '' ) { | |
e.preventDefault(); | |
$(this).parent().parent().removeClass('active'); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment