Skip to content

Instantly share code, notes, and snippets.

@vicskf
Last active September 16, 2020 05:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vicskf/1bd6b26ea215d3812e5ff454e936f113 to your computer and use it in GitHub Desktop.
Save vicskf/1bd6b26ea215d3812e5ff454e936f113 to your computer and use it in GitHub Desktop.
TEC - Filter Bar plugin > Always show open filters in mobile views
<?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