Skip to content

Instantly share code, notes, and snippets.

@elimn
elimn / count_recurrences.sql
Last active August 9, 2016 05:59
MT | TEC | Count number of recurrences in database
/*
Shows how many recurrences each recurring event has.
Includes events from all statuses including in the trash.
*/
SELECT
`post_parent` as event_id,
COUNT(*) As recurrences
FROM
wp_posts
@elimn
elimn / tribe_get_next_upcoming_recurrence.php
Last active August 4, 2016 15:45
MT | TEC | Retrieve the next upcoming recurrence for a given post ID
<?php
/**
* Retrieves the next upcoming recurrence for a given post ID
*
* @param int $event_id The post ID for the event
*
* @return WP_Post|null The event post object, or null if nothing was found
*/
function tribe_get_next_upcoming_recurrence( $event_id ) {
@elimn
elimn / tribe_add_ongoing_class_month_view.php
Last active August 5, 2016 05:36
MT | TEC | Add CSS classes to month view multiday events
<?php
/**
* Add CSS classes to month view multiday events
* Three classes are added: tribe-month-multiday-event, tribe-month-multiday-start-date, tribe-month-multiday-end-date
*/
function tribe_add_ongoing_class_month_view ( $classes ) {
global $post;
$event_id = $post->ID;
@elimn
elimn / tribe_embed_google_map_true.php
Created August 2, 2016 04:59
MT | TEC | Always show Google Map and Map Link on Single Events
<?php
/**
* Causes calendar to always show Google Map and Link, regardless of individual event settings
*/
add_filter( 'tribe_embed_google_map', '__return_true' );
add_filter( 'tribe_show_google_map_link', '__return_true' );
@elimn
elimn / tribe_remove_time_list_view.php
Created August 2, 2016 03:49
MT | TEC | Remove event time from showing in List View
<?php
/**
* Removes time from List View
*/
function tribe_remove_time_list_view( $settings ) {
if( ! tribe_is_upcoming() && ! tribe_is_past() ) return $settings;
$settings[ 'time' ] = false;
@elimn
elimn / tribe_events_output_cta.php
Created August 2, 2016 03:23
MT | ETP | Add a link to the list view for booking an event
<?php
/**
* Adds a link to the list view for booking an event if an RSVP or Ticket is available
*/
function tribe_events_output_cta() {
if( ! tribe_is_list_view() ) return;
$event = tribe_events_get_event( null );
@elimn
elimn / tribe_remove_json_ld_month.php
Last active January 23, 2017 16:22
MT | TEC | Remove JSON LD from loading on month view
<?php
/**
* Removes json LD from loading on month view
*/
function tribe_remove_json_ld_month() {
if ( tribe_is_month() ) {
tribe_remove_anonymous_hook( 'wp_head', 'Tribe__Events__Template__Month', 'json_ld_markup' );
}
}
@elimn
elimn / tribe_community_show_all_cats.php
Created July 7, 2016 20:59
MT | CE | Automatically show all categories on Community Events: Add/Edit page
<?php
/**
* Automatically shows all categories on Community Events: Add/Edit page
*/
function tribe_community_show_all_cats() {
if ( ! tribe_is_community_edit_event_page() ) return;
echo ' <script type="text/javascript">
jQuery( document ).ready(function(){
@elimn
elimn / Tribe__Events__Filterbar__Filters__Category_Custom.php
Created June 21, 2016 05:59
MT | TEC | Customized version of the Category Filter that includes CSS classes for subcategories
<?php
/**
* Customized version of the Category Filter that includes CSS classes for subcategories
* New filter available in WP-Admin > Events > Settings > Filters
*/
if ( class_exists( 'Tribe__Events__Filterbar__Filters__Category' ) ) {
class Tribe__Events__Filterbar__Filters__Category_Custom extends Tribe__Events__Filterbar__Filters__Category {
@elimn
elimn / disable_tribe_json_ld_markup.php
Created June 18, 2016 16:49
MT | TEC | Disable JSON LD markup used by search engines
<?php
/*
* Disable JSON LD markup used by search engines
*/
add_filter( 'tribe_json_ld_markup', '__return_empty_string' );