Created
July 15, 2024 06:45
-
-
Save jmabbas/9a4801435f9c33aa3340a283e166bccf to your computer and use it in GitHub Desktop.
Bookworm- Header v7 Search
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
function bookworm_site_search_v7() { | |
if ( apply_filters('bookworm_enable_site_search' , true )): | |
?> | |
<div class="site-search ml-xl-0 ml-md-auto w-r-100 flex-grow-1 mr-md-5 py-2 py-md-0"> | |
<?php if ( bookworm_is_woocommerce_activated() ) : ?> | |
<form method="get" id="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>" class="form-inline my-2 my-xl-0"> | |
<div class="input-group w-100"> | |
<div class="input-group-prepend z-index-2 d-none d-xl-block"> | |
<?php $selected_cat = isset( $_GET['product_cat'] ) ? $_GET['product_cat'] : 0; | |
$navbar_search_dropdown_text = apply_filters( 'bookworm_navbar_search_category_dropdown_default_text', esc_html__( 'All Categories', 'bookworm' ) ); | |
wp_dropdown_categories( apply_filters( 'bookworm_search_dropdown_categories_filter_args', array( | |
'show_option_all' => $navbar_search_dropdown_text, | |
'taxonomy' => 'product_cat', | |
'hide_if_empty' => 1, | |
'name' => 'product_cat', | |
'selected' => $selected_cat, | |
'value_field' => 'slug', | |
'id' => 'inputGroupSelect01', | |
'class' => 'd-none d-lg-block custom-select pr-7 pl-4 rounded-0 height-5 shadow-none text-dark' | |
) ) ); | |
?> | |
</div> | |
<input type="text" name="s" id="s" value="<?php echo get_search_query(); ?>" class="form-control border-right-0 px-3" placeholder="<?php esc_attr_e( 'Search for books by keyword', 'bookworm' ); ?>" aria-label="<?php esc_attr_e( 'Amount (to the nearest dollar)', 'bookworm' ); ?>"> | |
<input type="hidden" id="search-param" name="post_type" value="product" /> | |
<div class="input-group-append border-left"> | |
<button class="btn btn-dark px-3 rounded-0 py-2" type="submit"> | |
<i class="mx-1 glph-icon flaticon-loupe"></i> | |
</button> | |
</div> | |
</div> | |
</form> | |
<?php else : ?> | |
<form method="get" id="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>" class="form-inline my-2 my-xl-0"> | |
<div class="input-group w-100"> | |
<div class="input-group-prepend z-index-2 d-none d-xl-block"> | |
<?php $selected_cat = isset( $_GET['category'] ) ? $_GET['category'] : 0; | |
$navbar_search_dropdown_text = apply_filters( 'bookworm_navbar_search_category_dropdown_default_text', esc_html__( 'All Categories', 'bookworm' ) ); | |
wp_dropdown_categories( apply_filters( 'bookworm_search_dropdown_categories_filter_args', array( | |
'show_option_all' => $navbar_search_dropdown_text, | |
'taxonomy' => 'category', | |
'hide_if_empty' => 1, | |
'name' => 'category', | |
'selected' => $selected_cat, | |
'value_field' => 'slug', | |
'id' => 'inputGroupSelect01', | |
'class' => 'd-none d-lg-block custom-select pr-7 pl-4 rounded-0 height-5 shadow-none text-dark' | |
) ) ); | |
?> | |
</div> | |
<input type="text" name="s" id="s" value="<?php echo get_search_query(); ?>" class="form-control border-right-0 px-3" placeholder="<?php esc_attr_e( 'Search for books by keyword', 'bookworm' ); ?>" aria-label="<?php esc_attr_e( 'Amount (to the nearest dollar)', 'bookworm' ); ?>"> | |
<input type="hidden" id="search-param" name="post_type" value="post" /> | |
<div class="input-group-append border-left"> | |
<button class="btn btn-dark px-3 rounded-0 py-2" type="submit"> | |
<i class="mx-1 glph-icon flaticon-loupe"></i> | |
</button> | |
</div> | |
</div> | |
</form> | |
<?php endif; ?> | |
</div> | |
<?php | |
endif; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment