Created
October 20, 2018 07:38
-
-
Save yousufansa/d915f619725815dd6b8dc54ea97bdb7c to your computer and use it in GitHub Desktop.
Jobhunt - Job Region Dropdown in Job Search
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 ( class_exists( 'WP_Job_Manager' ) && class_exists( 'Astoundify_Job_Manager_Regions' ) ) { | |
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__( 'All Region', 'jobhunt' ), | |
'category_select_text' => esc_html__( 'Any Category', 'jobhunt' ), | |
'show_category_select' => false, | |
'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> | |
<div class="job-search-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' => $location_placeholder_text,'hierarchical' => 1, 'name' => 'filter_job_listing_region','id' => 'search_category','class' => 'jobhunt-job-region-select','value_field' => 'name',) ); ?> | |
</div> | |
<?php if ( $show_category_select ) : ?> | |
<div class="job-search-category"> | |
<label class="sr-only" for="search_category"><?php echo esc_html__( 'Category', 'jobhunt' ); ?></label> | |
<select id="search_category" name="search_category"> | |
<option value=""><?php echo esc_html( $category_select_text ); ?></option> | |
<?php foreach ( get_job_listing_categories() as $cat ) : ?> | |
<option value="<?php echo esc_attr( $cat->term_id ); ?>"><?php echo esc_html( $cat->name ); ?></option> | |
<?php endforeach; ?> | |
</select> | |
</div> | |
<?php endif; ?> | |
<div class="job-search-submit"> | |
<button type="submit" value="<?php echo esc_attr_x( 'Search', 'submit button', 'jobhunt' ); ?>"><i class="la la-search"></i><span class="job-search-text"><?php echo esc_html__( 'Search', 'jobhunt' ); ?></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> | |
<style> | |
.job-search-location { | |
height: 60px; | |
min-width: 240px; | |
} | |
.job-search-location:after { | |
content: none !important; | |
} | |
.jobhunt-job-region-select { | |
height: 100%; | |
} | |
</style> | |
<?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