Created
January 14, 2019 07:45
-
-
Save yousufansa/4d9c5a70c84e121e9be2623fdb5d6603 to your computer and use it in GitHub Desktop.
Jobhunt - Job Header Search Hierarchical Dropdown
This file contains hidden or 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
if ( ! function_exists( 'jobhunt_job_header_search_block' ) ) { | |
/** | |
* Display Job Header Search block | |
*/ | |
function jobhunt_job_header_search_block( $args = array() ) { | |
$defaults = apply_filters( 'jobhunt_job_header_search_block_args', array( | |
'section_title' => esc_html__( 'Explore Thousand Of Jobs With Just Simple Search...', 'jobhunt' ), | |
'sub_title' => '', | |
'search_placeholder_text' => esc_html__( 'Job title, keywords or company name', 'jobhunt' ), | |
'location_placeholder_text' => esc_html__( 'City, province or region', 'jobhunt' ), | |
'category_select_text' => esc_html__( 'Any Category', 'jobhunt' ), | |
'show_category_select' => false, | |
'search_button_icon' => 'la la-search', | |
'search_button_text' => esc_html__( 'Search', 'jobhunt' ), | |
'show_browse_button' => false, | |
'browse_button_label' => esc_html__( 'Or browse job offers by', 'jobhunt' ), | |
'browse_button_text' => esc_html__( 'Category', 'jobhunt' ), | |
'browse_button_link' => '#' | |
) ); | |
$args = wp_parse_args( $args, $defaults ); | |
extract( $args ); | |
$jobs_page_id = jh_wpjm_get_page_id( 'jobs' ); | |
$jobs_page_url = get_permalink( $jobs_page_id ); | |
?><div class="job-search-block"> | |
<?php do_action( 'jobhunt_job_header_search_block_before' ); ?> | |
<?php if ( ! empty( $section_title ) || ! empty( $sub_title ) ) : ?> | |
<div class="section-header"> | |
<?php if ( ! empty( $section_title ) ) : ?> | |
<h3 class="section-title"><?php echo esc_html( $section_title ); ?></h3> | |
<?php endif; ?> | |
<?php if ( ! empty( $sub_title ) ) : ?> | |
<span class="section-sub-title"><?php echo esc_html( $sub_title ); ?></span> | |
<?php endif; ?> | |
</div> | |
<?php endif; ?> | |
<div class="job-search-form"> | |
<form method="GET" action="<?php echo esc_url( $jobs_page_url ); ?>"> | |
<div class="job-search-keywords"> | |
<label class="sr-only" for="search_keywords"><?php echo esc_html__( 'Keywords', 'jobhunt' ); ?></label> | |
<input type="text" id="search_keywords" name="search_keywords" placeholder="<?php echo esc_attr( $search_placeholder_text ); ?>"/> | |
</div> | |
<?php if ( jobhunt_is_astoundify_job_manager_regions_activated() && get_option( 'job_manager_regions_filter' ) ) : ?> | |
<div class="job-search-location region-location"> | |
<label class="sr-only" for="filter_job_listing_region"><?php echo esc_html__( 'Region', 'jobhunt' ); ?></label> | |
<?php wp_dropdown_categories( array('taxonomy' => 'job_listing_region', 'show_option_all' => ' Select Region', 'hierarchical' => 1, 'name' => 'filter_job_listing_region','id' => 'search_category','class' => 'jobhunt-job-region-select','value_field' => 'name','orderby' => 'name' ) ); ?> | |
</div> | |
<?php else : ?> | |
<div class="job-search-location"> | |
<label class="sr-only" for="search_location"><?php echo esc_html__( 'Location', 'jobhunt' ); ?></label> | |
<input type="text" id="search_location" name="search_location" placeholder="<?php echo esc_attr( $location_placeholder_text ); ?>"/> | |
</div> | |
<?php endif; ?> | |
<?php if ( $show_category_select && taxonomy_exists( 'job_listing_category' ) ) : ?> | |
<div class="job-search-category"> | |
<label class="sr-only" for="search_category"><?php echo esc_html__( 'Category', 'jobhunt' ); ?></label> | |
<?php wp_dropdown_categories( array( 'taxonomy' => 'job_listing_category', 'show_option_all' => $category_select_text, 'hierarchical' => 1, 'depth' => 0, 'name' => 'search_category', 'id' => 'search_category', 'value_field' => 'name', 'orderby' => 'name' ) ); ?> | |
</div> | |
<?php endif; ?> | |
<div class="job-search-submit"> | |
<button type="submit" value="<?php echo esc_attr( $search_button_text ); ?>"><i class="<?php echo esc_attr( $search_button_icon ); ?>"></i><span class="job-search-text"><?php echo esc_html( $search_button_text ); ?></span></button> | |
</div> | |
</form> | |
<?php if ( $show_browse_button ) : ?> | |
<div class="browse-jobs-by-category"> | |
<span><?php echo esc_html( $browse_button_label ); ?></span> | |
<a href="<?php echo esc_url( $browse_button_link ); ?>" title="<?php echo esc_attr( $browse_button_text ); ?>"><?php echo esc_html( $browse_button_text ); ?></a> | |
</div> | |
<?php endif; ?> | |
</div> | |
<?php do_action( 'jobhunt_job_header_search_block_after' ); ?> | |
</div><?php | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment