Last active
September 16, 2020 05:02
-
-
Save vicskf/1bd6b26ea215d3812e5ff454e936f113 to your computer and use it in GitHub Desktop.
TEC - Filter Bar plugin > Always show open filters in mobile views
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
<?php | |
/** | |
* Filter Bar plugin | |
* Always show open filters in mobile views | |
* Author: Barry Hughes | |
*/ | |
add_action( 'wp_footer', function() { | |
if ( | |
! class_exists( 'Tribe__Events__Filterbar__View' ) | |
|| is_admin() | |
|| ! tribe_is_event_query() | |
) { | |
return; | |
} | |
echo <<<HTML | |
<script type="text/javascript"> | |
( function( $ ) { | |
function run() { | |
if ( 'undefined' === typeof tribe_ev ) { | |
return; | |
} | |
if ( tribe_ev.data.v_width < tribe_ev.data.mobile_break ) { | |
$( 'body' ) | |
.removeClass( 'tribe-filters-closed' ) | |
.removeClass( 'tribe-ajax-success' ) | |
.addClass( 'tribe-filters-open' ); | |
if ( tribe_storage ) { | |
tribe_storage.setItem( 'tribe_events_filters_wrapper', 'open' ); | |
}; | |
} | |
} | |
$( document ).ready( run ); | |
} )( jQuery ); | |
</script> | |
HTML; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment