Skip to content

Instantly share code, notes, and snippets.

@andrasguseo
andrasguseo / gist:d1011344b1ca497d206575f3443afdbc
Created March 26, 2025 21:55
TEC/ECP > Delete orphaned recurring events after migrating to the new data structure introduced in TEC 6.0
<?php
/**
* Deletes orphaned 'old' recurring events, after the events have been migrated.
* You know you have orphaned events if on the Event admin list the number of All events
* and the number of items don't match.
* @see https://dl.dropbox.com/scl/fi/tmljvc5fzzpr48arklsbt/shot_250326_225112.png?rlkey=dkg0qjh72zhafasnitbrfokv5&dl=0
*
* Creating a database dump before and running a test on a staging site first is recommended!
* Creating a database backup before running the snippet on a production site is recommended!
*
@andrasguseo
andrasguseo / functions.php
Created March 13, 2025 16:17
ET > Delete abandoned orders and related tickets (experimental)
<?php
/**
* Deletes Tickets Commerce Orders and related Tickets/Attendees,
* which are missing a related event or post.
* Creating a database dump before and running a test on a staging site first is recommended.
*
* Usage: Add the snippet with Code Snippets as a "run once" snippet.
* Run the snippet when needed.
*
* @author: Andras Guseo
@andrasguseo
andrasguseo / functions.php
Created March 5, 2025 13:51
TEC > Use space as the thousand separator (TEC only)
<?php
/**
* Format the event cost by using a space as the thousand separator.
*
* Usage: Add the snippet with Code Snippets or to your functions.php file.
* Enter the cost without a thousand separator, when creating the event.
*
* @since March 5, 2025 Initial version.
*
* @param double $cost the event cost
@andrasguseo
andrasguseo / functions.php
Last active February 5, 2025 15:28
ETP + Woo > Autocomplete some orders
<?php
/**
* Set WooCommerce orders for Ticket products to 'completed' status automatically based on certain criteria.
*
* You can further tweak the behavior by adjusting the snippet:
* - based on order status: line 29
* - based on payment gateway: line 36
*/
add_action( 'woocommerce_thankyou', function ( $order_id ) {
// Bail if there is no order.
@andrasguseo
andrasguseo / change-event-time-zone.php
Created January 14, 2025 11:30
TEC > Time zone changer for events
<?php
/**
* Change the time zone of all events and adjust the UTC times accordingly.
*
* Usage: Add the snippet with Code Snippets.
* Set your target time zone on line 20.
* Optional: Set your target time zone abbreviation on line 33.
* Save it as a 'Run once' snippet.
* Go to the Snippet list and click on 'Run' next to the snippet.
*
@andrasguseo
andrasguseo / ea-advanced-category-management.php
Created November 29, 2024 15:29
EA > If an event category is changed locally, don't import the category anymore.
<?php
/**
* When importing from Other URL with Event Aggregator, only import/update the event
* category, if it hasn't been changed on the destination site yet.
*
* Usage: Add the snippet with a plugin like Code Snippets, or to the functions.php file.
*
* @author: Andras Guseo
*
* Plugins required: The Events Calendar, Event Aggregator
@andrasguseo
andrasguseo / functions.php
Last active November 7, 2024 22:00
TEC > Block REST API requests coming from EA.
<?php
/**
* Block REST API requests coming from Event Aggregator. Basically blocks imports.
* It can block other sites trying to siphon events with EA through the "Other URL" source.
*
* Usage: Add the snippet with a plugin like Code Snippets or to your functions.php file.
*
* @author: Andras Guseo
*
* Plugins required: The Events Calendar
@andrasguseo
andrasguseo / functions.php
Created November 7, 2024 13:16
TEC > Change event content im the subscription feed
<?php
/**
* Changes the event title and description in the iCal feed which is used to export events or
* subscribe to the calendar. Can be used to prank subscribers to the calendar. :)
*
* Usage: Add the snippet with a plugin like Code Snippets or to your functions.php file.
*
* @author: Andras Guseo
*
* Plugins required: The Events Calendar
@andrasguseo
andrasguseo / functions.php
Last active November 4, 2024 11:14
ECP > Add the virtual event URL to the end of the description in the iCal exports.
<?php
/**
* Insert virtual event meeting URL at the end of the description.
*
* @param array $item Array of items describing the event in ical format.
* @param object $event The event object.
*
* @return array
*/
add_filter( 'tribe_ical_feed_item', function ( $item, $event ) {
@andrasguseo
andrasguseo / functions.php
Created October 22, 2024 19:05
ET > Trash (or delete) orphaned tickets
<?php
/**
* Trash (or delete) orphaned Tickets Commerce tickets.
*
* Usage: Add the snippet with a plugin like Code Snippets.
* Save it as a "Run once" snippet.
* Go to the All Snippets page and run the snippet.
*
* @author: Andras Guseo
*