Last active
October 3, 2019 18:05
-
-
Save KZeni/b5e0e54d4615d3bbef8df22b25c46597 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
$shortcode = '[jobs '; | |
if(isset($_GET['job_listing_category']) && $_GET['job_listing_category'] != ''){ | |
echo '<p><a href="'. get_permalink(get_option('job_manager_jobs_page_id')).'" class="button btn">← Back to All Job Listings</a></p>'; | |
echo '<h3>'.ucwords(str_replace('-',' ',sanitize_text_field($_GET['job_listing_category']))).'</h3>'; | |
$shortcode.= 'categories="'.sanitize_text_field($_GET['job_listing_category']).'" '; | |
} | |
$shortcode.= ']'; | |
echo do_shortcode($shortcode); | |
echo " | |
<script> | |
jQuery(document).ready(function($){ | |
var jobListingsPageURL = '".get_permalink(get_option('job_manager_jobs_page_id'))."'; | |
if(window.location.href === jobListingsPageURL){ // If on the main job listings page (no URL parameters or anything making it potentially showing something other than the intial job listing search page content) | |
window.sessionStorage.removeItem('job_listing_' + $('div.job_listings').data( 'post_id' ) + '_' + $( 'div.job_listings' ).index( $('div.job_listings') )); // Clear session storage to avoid persistent job filter data from being used when it should be a clean state (based on the session storage/clearing/etc. behavior from https://github.com/Automattic/WP-Job-Manager/blob/master/assets/js/ajax-filters.js) | |
$('div.job_listings ul.job_listings').hide(); // Hide the results initially (wait for a search to occur before showing results) | |
var initialDisplaySuppresed = false; // The first attempt at showing the results (via update_results) hasn't been suppressed yet | |
$( 'div.job_listings' ).on( 'update_results', function(){ // A search has been made | |
if(initialDisplaySuppresed){ // Only have the first update_results trigger keep hidden while the subsequent ones should display their results as expected | |
$('div.job_listings ul.job_listings').show(); // Show the results | |
} | |
initialDisplaySuppresed = true; // The first attempt was suppressed | |
}); | |
} | |
}); | |
</script> | |
"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment