tamarazuk
10/16/2013 - 7:56 AM

Fixes a 'popstate' issue with The Events Calendar WordPress plugin. Issue described full detail here: https://tri.be/support/forums/topic/ca

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

<?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');