Skip to content

Instantly share code, notes, and snippets.

@elimn
elimn / tribe_get_upcoming_organizers.php
Created June 8, 2016 15:45
MT | TEC | Function to obtain a list of upcoming organizers
<?php
/*
* Returns a list of upcoming organizers, behaves like get_posts()
*
* @return array Containing the WP_Post for each organizer
*/
function tribe_get_upcoming_organizers() {
$organizers = get_posts(
@elimn
elimn / tribe_get_event_website_link_target_blank.php
Created June 6, 2016 16:03
MT | TEC | Changes event website link to one that opens in a new window/tab
@elimn
elimn / tribe_event_tickets_rsvp_success_script.php
Created June 2, 2016 16:57
MT | ETP | When an RSVP is submitted succesfully redirect users to a new page
<?php
/*
* When an RSVP is submitted succesfully redirect users to a new page
*/
function tribe_event_tickets_rsvp_success_script() {
if( ! isset($_GET['rsvp_sent']) || $_GET['rsvp_sent'] != 1 ) return;
// Change this to URL that you want users redirected to
@elimn
elimn / Tribe__Events__Filterbar__Filters__Time_Of_Day.php
Last active December 5, 2017 05:17
MT | TEC | Custom Time of Day Filter
<?php
/**
* Customized version of the Time of Day filter that allows selecting by specific hour ranges in the afternoon
* New filter available in WP-Admin > Events > Settings > Filters
*/
if ( class_exists( 'Tribe__Events__Filterbar__Filter' ) ) {
class Tribe__Events__Filterbar__Filters__Time_Of_Day_Custom extends Tribe__Events__Filterbar__Filter {
public $type = 'checkbox';
@elimn
elimn / tribe_event_countdown_shortcode.php
Last active May 24, 2016 14:40
MT | TEC | Add shortcode to countdown to the next upcoming event
<?php
/*
* Shortcode that extends the existing countdown shortcode, but this ones shows
* the next upcoming events rather than a specific one.
*
* Example usage:
*
* [tribe_event_countdown_next show_seconds="1" complete="The party is on!"]
*/
@elimn
elimn / tribe_fast_forward_month_view.php
Created May 24, 2016 14:21
MT | TEC | Fast forward to the next month with upcoming events in Month View
<?php
/*
* In month view the month with the first upcoming event is shown
*/
function tribe_fast_forward_month_view( $query ) {
// Dont interfere with other month views (like mini-cal)
if ( ! $query->is_main_query() ) return;
// Dont interfere outside of month view
if ( ! tribe_is_month() ) return;
@elimn
elimn / tribe_prevent_add_cart_empty.php
Created April 29, 2016 20:22
MT | ET | Force users to select at least one ticket or RSVP before submitting the form
<?php
/*
* Prevents users from adding tickets to cart unless they have selected at least one ticket
*/
function tribe_prevent_add_cart_empty() {
echo '
<script type="text/javascript">
jQuery( document ).ready(function(){
jQuery( "form.cart" ).each(function(){
@elimn
elimn / tribe_subsequent_recurrence_default.php
Created April 19, 2016 03:37
MT | TEC | Tick first upcoming by default in front-end
<?php
/*
* Checks the front-end box "Show only the first upcoming instance of recurring events" by default
*/
function tribe_subsequent_recurrence_default( $option, $name, $default ) {
if ( $name === 'hideSubsequentRecurrencesDefault' && ! is_admin() ) $option = true;
return $option;
@elimn
elimn / delete_all_deleted_events.sql
Created April 13, 2016 22:10
MT | TEC | Truly delete all deleted iCal events
/*
With events that were imported via iCal, when deleted the calendar still
remembers them a bit so they don't get reimported. This SQL Query will truly
delete all those events.
The query and steps below is modified version of that in this tutorial:
http://wpguru.co.uk/2013/02/how-to-bulk-delete-posts-in-wordpress-with-mysql/
It is recommended that you read the source article above before proceeding.
In particular it mentioned the importance of making backups before running
SQL queries. :)
@elimn
elimn / delete_all_recurrences.sql
Created April 8, 2016 13:32
MT | ECP | Quick way to delete all recurrences of an event
/*
This SQL Query will delete all recurrences of an event, while preserving the
original event. It can delete many thousands of recurrences per second on most
servers.
The query and steps below is modified version of that in this tutorial:
http://wpguru.co.uk/2013/02/how-to-bulk-delete-posts-in-wordpress-with-mysql/
It is recommended that you read the source article above before proceeding.
Step 1) Grab the "post_parent" ID for your recurring series of events. Navigate