Skip to content

Instantly share code, notes, and snippets.

View barryhughes's full-sized avatar
🇨🇦

Barry Hughes barryhughes

🇨🇦
  • Automattic
  • Vancouver Island, Canada
View GitHub Profile
@barryhughes
barryhughes / EventWebsiteLink.php
Last active December 11, 2015 22:38 — forked from theeventscalendar/Event Website link
Make an Event Website a link instead of showing the text url
@barryhughes
barryhughes / WooCommerce-product-page.php
Last active August 29, 2015 14:28
Allows customers to access the WooCommerce Tickets product page for tickets. See https://theeventscalendar.com/knowledgebase/selling-tickets-from-the-woocommerce-products-page/.
<?php
function wootix_no_hijack() {
if ( ! class_exists( 'Tribe__Events__Tickets__Woo__Main' ) ) return;
$woo_tickets = Tribe__Events__Tickets__Woo__Main::get_instance();
remove_filter( 'post_type_link', array( $woo_tickets, 'hijack_ticket_link' ), 10, 4 );
}
add_action( 'init', 'wootix_no_hijack' );
add_filter( 'tribe-events-bar-views', 'setup_listview_in_bar', 1, 1 );
add_filter( 'tribe-events-bar-views', 'setup_gridview_in_bar', 5, 1 );
function setup_listview_in_bar( $views ) {
$views[] = array( 'displaying' => 'upcoming', 'anchor' => 'List View', 'url' => tribe_get_listview_link() );
return $views;
}
function setup_gridview_in_bar( $views ) {
$views[] = array( 'displaying' => 'month', 'anchor' => 'Calendar', 'url' => tribe_get_gridview_link() );
add_filter( 'tribe-events-bar-views', 'my_setup_view_for_bar', 10);
function my_setup_view_for_bar( $views ) {
$tec = TribeEvents::instance();
$views[] = array('displaying' => 'myview', 'anchor' => 'My view', 'url' => $tec->getOption( 'eventsSlug', 'events' ) . '/my_view_slug' );
return $views;
}
add_filter( 'tribe_events_pre_get_posts', 'setup_my_bar_field_in_query', 10, 1 );
function setup_my_bar_field_in_query( $query ){
if ( !empty( $_REQUEST['tribe-bar-my-field'] ) ) {
$query->query_vars['my_var'] = $_REQUEST['tribe-bar-my-field'];
}
return $query;
}
add_filter( 'tribe-events-bar-filters', 'setup_my_field_in_bar', 1, 1 );
function setup_my_field_in_bar( $filters ) {
$filters['tribe-bar-my-field'] = array(
'name' => 'tribe-bar-my-field',
'caption' => 'My Field',
'html' => '<input type="text" name="tribe-bar-my-field" id="tribe-bar-my-field">'
);
return $filters;