epl_listing_query_cache_enabled: turn the listing search cache on or off
Description #
Turns the listing search cache on or off. From 3.6, EPL saves the results of its listing queries (the search dropdown values and the location list) across page loads. Return false to run the queries on every page load, as before 3.6, for example while you debug a custom search field. See How the listing search cache works.
Usage #
add_filter( 'epl_listing_query_cache_enabled', 'my_function' );
Parameters #
$enabled (bool)
True to save results across page loads. Default true.
Examples #
Turn the cache off:
add_filter( 'epl_listing_query_cache_enabled', '__return_false' );
Turn it off for administrators only, so they see changes straight away while visitors still get the fast, cached search:
function my_epl_no_search_cache_for_admins( $enabled ) {
if ( current_user_can( 'manage_options' ) ) {
return false;
}
return $enabled;
}
add_filter( 'epl_listing_query_cache_enabled', 'my_epl_no_search_cache_for_admins' );
With the cache off, a query asked for twice on the same page still runs once. Results saved earlier are left in place but not used. To refresh the cache rather than turn it off, use epl_flush_listing_query_cache().
Source #
lib/includes/functions.php, in epl_listing_query_cache(). Since 3.6.