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 / custom-event-category-templates.php
Created October 25, 2018 19:58
An example of using a different theme template for different event categories.
<?php
/**
* Use custom templates for event views when specific categories
* have been requested.
*/
class Event_Category_Templates {
/**
* This will be true if an event view has been requested.
*
* @var bool
<?php
add_filter('tribe_tickets_plus_qr_check_security_code', '__return_true' );
<?php
# Quickly generate a set of test events on Eventbrite.com
# (from within a WordPress environment - useful for setting
# up test scenarios etc).
$token = '--YOUR-TOKEN-HERE--';
$date = date_create( '2019-01-01 12:00:00' );
for ( $i = 0; $i <= 60; $i++ ) {
$date->modify( '+2 days' );
@barryhughes
barryhughes / override-min-max-coords.php
Created August 8, 2018 16:46
Sample of overriding the min/max map view coords (ECP 4.4.30)
<?php
# Prohibit caching of geoloc center point/bounds
add_filter( 'pre_transient_geoloc_center_point_estimation', '__return_null' );
# Override the min/max coords
add_filter( 'tribe_geoloc_pre_get_min_max_coords', function() {
return [
'min_lat' => 30,
'max_lat' => 40,
'min_lng' => 20,
@barryhughes
barryhughes / modifiy-multiday-event-tooltips.php
Created August 7, 2018 12:15
Alter the date presented within month view tooltips for multiday events.
<?php
/**
* Modifies the month view tooltip for multiday events.
*
* Instead of seeing "5 - 15 August", the tooltip for multiday event will show
* the date of the cell which contains it.
*
* For example, if a visitor hovers over the multiday event name within the cell
* for 11 August, the tooltip will now display "11 August" etc.
*/
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 23 columns, instead of 16. in line 3.
Date,Time,End date,Artist,Artist URL,Venue,Address,City,State,Postal code,Country,Venue phone,Venue URL,Admittance,Price,Ticket URL,Ticket phone,External URL,Notes,Tour,Status,Related ID,Related URL
2018-10-02,12:00:00,2018-10-05,Jon Bon Jovi,https://www.bonjovi.com/,Party Spot NW,1041 SW Marine Dr,Vancouver,BC,V6P 6L6,CA,,,Not sure,,,,,,,active,0,
2018-08-25,14:00:00,,The Spice Girls,http://thespicegirls.com/,Lakeway Dance Hall,714 Lakeway Dr,Bellingham,WA,98229,US,456-789-0123,http://lakeway.site.web,All Ages/Licensed,"¥2,225.00",,01222 333444,,"A rare treat with beef ribs jowl officia corned beef ad. Sed in culpa dolore irure corned beef shoulder nostrud cupidatat swine.
Dolore ullamco minim short loin short ribs cillum. Beef ham short loin strip steak in. Laboris biltong do filet mignon veniam drumstick.",,active,0,
2018-07-17,07:30:00,,Anna Carina,http://www.annacarina.net/,Chalkpit at Cedar City,1575 W 200 N,Cedar City,UT,84720,US,(1) 234 567 8901,,All Ages/Licensed,$25,http://some.tickets/getem/j
@barryhughes
barryhughes / remove-rsvp-ticket-form.php
Last active May 18, 2018 15:18
Remove RSVP ticket form from single events/posts, via code that can be added to a theme's functions.php file (where that's appropriate)
<?php
// This code can be added to a theme's functions.php file to remove
// the frontend ticket form (RSVPs only)
if ( function_exists( 'tribe' ) && class_exists( 'Tribe__Tickets__RSVP' ) ) {
// Remove the RSVP ticket form from blog posts, etc
remove_filter( 'the_content', array(
tribe( 'tickets.rsvp' ), 'front_end_tickets_form_in_content'
), 11 );
// Remove the RSVP ticket form from single event posts
@barryhughes
barryhughes / experimental-smart-month-search.php
Created May 17, 2018 15:32
Improve month view search so it is not restricted to the current month. Experimental! Use at own risk, there are known bugs/quirks with this code.
<?php
/**
* If a search is conducted in month view but the relevant events
* are in a different month, switch to that month.
*
* Experimental! Especially during live ajax navigation, there are
* parts of this that don't work cleanly (pushstate/URL changes).
* Unsupported, use at own risk.
*/
class Transmogrified_Month_View_Search {
@barryhughes
barryhughes / add-post-date-column-to-events-wp-list-table.php
Created May 4, 2018 20:53
Add post date column to the events WP List Table (TEC 4.x)
<?php
function events_post_date_column( $column_id, $post_id ) {
echo 'post_date' === $column_id ? get_the_date( '', $post_id ) : '';
}
function events_post_date_column_header( $headers ) {
$headers['post_date'] = 'Post Date';
return $headers;
}
@barryhughes
barryhughes / remove-mini-cal-list-limits.php
Created May 4, 2018 20:04
Allows the list of events below the mini calendar widget to include events from future months, if there are none (or not enough) in the current month
<?php
function remove_mini_cal_list_end_date( $query ) {
remove_action( 'tribe_events_pre_get_posts', 'remove_mini_cal_list_end_date' );
$query->set( 'end_date', '' );
}
function listen_for_mini_cal_list( $template_file ) {
if ( basename( dirname( $template_file ) ) . '/' . basename( $template_file ) == 'mini-calendar/list.php' ) {
add_action( 'tribe_events_pre_get_posts', 'remove_mini_cal_list_end_date' );
}