Last active
April 13, 2019 00:49
-
-
Save cliffordp/04b7bbe6e7d9009aec12acc0b9bd5bdd to your computer and use it in GitHub Desktop.
Shortcode to display render Tribe Bar anywhere on site (e.g. website header) * Notes: It's not pretty or perfect, but it's a start if you want to pull something like this off on your site. FYI: You're in unsupported / custom coding territory. * Example: [tribe_bar_anywhere] * Screenshot: https://cl.ly/3h1S3d3a3T30
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 | |
/* | |
* By Barry and Cliff | |
* From https://gist.github.com/cliffordp/04b7bbe6e7d9009aec12acc0b9bd5bdd | |
* | |
* Shortcode to display render Tribe Bar anywhere on site (e.g. website header) | |
* For https://theeventscalendar.com/support/forums/topic/insert-search-bar-on-top-of-a-page/ which also links to http://gregorypearcey.com/blog/add-tribe-events-search-bar-home-page/ | |
* | |
* Notes: It's not pretty or perfect, but it's a start if you want to pull something like this off on your site. FYI: You're in unsupported / custom coding territory. | |
* | |
* Example: [tribe_bar_anywhere] | |
* Screenshot: https://cl.ly/3h1S3d3a3T30 | |
*/ | |
function tribe_bar_anywhere_logic() { | |
if ( ! class_exists( 'Tribe__Events__Bar' ) ) { | |
return false; | |
} | |
wp_enqueue_script( 'jquery' ); | |
Tribe__Events__Template_Factory::asset_package( 'bootstrap-datepicker' ); | |
Tribe__Events__Template_Factory::asset_package( 'calendar-script' ); | |
Tribe__Events__Template_Factory::asset_package( 'jquery-resize' ); | |
Tribe__Events__Template_Factory::asset_package( 'events-css' ); | |
Tribe__Events__Bar::instance()->load_script(); | |
ob_start(); | |
tribe_get_template_part( 'modules/bar' ); | |
return ob_get_clean(); | |
} | |
add_shortcode( 'tribe_bar_anywhere', 'tribe_bar_anywhere_logic' ); |
@taocroro, this code worked for me to display the Tribe Bar and for the search box to display events. Other than that, I didn't test it further and it's really just to be used as a starting point if you want to try to do something custom.
This probably needs an update to work with newer version of The Events Calendar.
add_shortcode( 'tribe_bar_anywhere', function() {
if ( ! class_exists( 'Tribe__Events__Bar' ) ) {
return false;
}
wp_enqueue_script( 'jquery' );
tribe_asset_enqueue('bootstrap-datepicker');
tribe_asset_enqueue('calendar-script');
tribe_asset_enqueue('jquery-resize');
tribe_asset_enqueue('events-css');
tribe( 'tec.bar' )->load_script();
ob_start();
tribe_get_template_part( 'modules/bar' );
return ob_get_clean();
});
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Barry&Cliff,
Thanks for the effort. Unfortunately, isn't working for me at all. Neither I get search results on date event or search box event, all I get is a redirect to the homepage without any results.
I'll be aware of this thread if you improve it and fix some bugs.
Thanks again for your work