Skip to content

Instantly share code, notes, and snippets.

@theeventscalendar
theeventscalendar / add-event-title.php
Last active July 3, 2023 22:47 — forked from geoffgraham/gist:145f929f4547bb2c690e
Add event title to cart next to ticket name
<?php
/**
* Example for adding event data to WooCommerce checkout for Events Calendar tickets.
* @link http://theeventscalendar.com/support/forums/topic/event-title-and-date-in-cart/
*/
add_filter( 'woocommerce_cart_item_name', 'woocommerce_cart_item_name_event_title', 10, 3 );
function woocommerce_cart_item_name_event_title( $title, $values, $cart_item_key ) {
$ticket_meta = get_post_meta( $values['product_id'] );
$event_id = absint( $ticket_meta['_tribe_wooticket_for_event'][0] );
@theeventscalendar
theeventscalendar / exclude events category.php
Last active November 27, 2022 03:30 — forked from elimn/tribe_exclude_events_category.php
Excludes specified categories from List and Month views. Add you own categories in line 9.
<?php
/*
* Removes categories "meetup" and "shindig" from list and month views
*/
function tribe_exclude_events_category( $wp_query ) {
// Slugs for the categories you wish to hide
$exclude_cats = array('meetup', 'shindig');
@theeventscalendar
theeventscalendar / sample functions with changed text.php
Last active July 20, 2022 19:18 — forked from elimn/tribe_custom_theme_text.php
This is an example of a functions.php file with custom text added.
<?php
/*
* EXAMPLE OF CHANGING ANY TEXT (STRING) IN THE EVENTS CALENDAR
* See the codex to learn more about WP text domains:
* http://codex.wordpress.org/Translating_WordPress#Localization_Technology
* Example Tribe domains: 'tribe-events-calendar', 'tribe-events-calendar-pro'...
*/
function tribe_custom_theme_text ( $translation, $text, $domain ) {
@theeventscalendar
theeventscalendar / ticketsplus_woocommerce-products.php
Last active February 15, 2022 22:38 — forked from elimn/tribe_wootix_no_hijack.php
Allows customers to access the WooCommerce product page for tickets with Tickets Plus
<?php
/*
* Causes WooCommerce Ticket product pages to stop redirecting to their event page
* See https://theeventscalendar.com/knowledgebase/selling-tickets-from-the-woocommerce-products-page/
*/
function tribe_wootix_no_hijack() {
if ( ! class_exists( 'Tribe__Tickets_Plus__Commerce__WooCommerce__Main' ) ) return;
$woo_tickets = Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance();
remove_filter( 'post_type_link', array( $woo_tickets, 'hijack_ticket_link' ), 10, 4 );
<?php
$count = 0;
echo '<ul>';
foreach ( $tickets as $ticket ) {
global $product;
$count++;
if ( class_exists( 'WC_Product_Simple' ) ) $product = new WC_Product_Simple( $ticket->ID );
else $product = new WC_Product( $ticket->ID );
@theeventscalendar
theeventscalendar / EventWebsiteLink2.php
Last active December 28, 2020 13:22 — forked from barryhughes/EventWebsiteLink.php
Make an Event Website a link instead of showing the text url. This version opens a new window with the additional target=blank code.
<?php
add_filter( 'tribe_get_event_website_link_label', 'tribe_get_event_website_link_label_default' );
function tribe_get_event_website_link_label_default( $label ) {
if ( $label === tribe_get_event_website_url() ) {
$label = "Visit Website &raquo;";
}
return '<a href="' . tribe_get_event_website_url() . '" target="_blank">' . $label . '</a>';
}
@theeventscalendar
theeventscalendar / default month.php
Last active May 7, 2020 13:24 — forked from elimn/tribe_set_default_date.php
Show a default month or date range in the calendar
<?php
/**
* Sets the default date for event queries.
*
* Expects to be called during tribe_events_pre_get_posts. Note that this
* function modifies $_REQUEST - this is needed for consistency because
* various parts of TEC inspect that array directly to determine the current
* date.
*
@theeventscalendar
theeventscalendar / list view default for categories.php
Last active December 13, 2019 15:06 — forked from barryhughes/use-list-view-for-categories.php
Category archive pages default to List View regardless of the default view set
/**
* Redirect event category requests to list view.
*
* @param $query
*/
function use_list_view_for_categories( $query ) {
// Disregard anything except a main archive query
if ( is_admin() || ! $query->is_main_query() || ! is_archive() ) return;
// We only want to catch *event* category requests being issued
@theeventscalendar
theeventscalendar / change_events_view_titles.php
Created August 25, 2015 00:13 — forked from elimn/tribe_alter_event_archive_titles.php
Changes the title/headings on Events views
<?php
/*
* Alters event's archive titles
*/
function tribe_alter_event_archive_titles ( $original_recipe_title, $depth ) {
// Modify the titles here
// Some of these include %1$s and %2$s, these will be replaced with relevant dates
$title_upcoming = 'Upcoming Events'; // List View: Upcoming events
@theeventscalendar
theeventscalendar / link-directly-to-website-url.php
Last active January 15, 2019 19:55 — forked from elimn/tribe_set_link_website.php
Change event or venue links in The Events Calendar to the relevant website URL