Last active
December 25, 2015 16:09
-
-
Save tamarazuk/7004172 to your computer and use it in GitHub Desktop.
Fixes a 'popstate' issue with The Events Calendar WordPress plugin. Issue described full detail here: https://tri.be/support/forums/topic/category-feed-lost-after-viewing-single-event-going-back-to-category/#post-68858
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
<?php | |
function namespace_temp_fix_tribe_cat() { | |
?> | |
<script type="text/javascript"> | |
jQuery(document).ready(function($) { | |
if ( typeof(tribe_ev) !== 'undefined' ) { | |
var trive_ev_cat = tribe_ev.fn.get_category(); | |
if (trive_ev_cat && trive_ev_cat != "") { | |
if ( typeof(tribe_ev.data.params) == 'string' ) { | |
tribe_ev.data.params += 'tribe_event_category=' + trive_ev_cat; | |
} else { | |
tribe_ev.data.params["tribe_event_category"] = trive_ev_cat; | |
} | |
} | |
} | |
}); | |
</script> | |
<?php | |
} | |
add_action('wp_head', 'namespace_temp_fix_tribe_cat', 8); // high priprity to make sure it is added before TEC js files | |
function namespace_tribe_events_view_data_attributes($data_attributes) { | |
$data_attributes['category'] = get_query_var('tribe_events_cat') ? get_query_var('tribe_events_cat') : ''; | |
return $data_attributes; | |
} | |
add_filter('tribe_events_view_data_attributes', 'namespace_tribe_events_view_data_attributes'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment