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
<?php
/**
* If a (ticket) product is updated via the WooCommerce product editor
* or even via quick edits then attempt to keep the cost fields in sync.
*
* @param int $product_id
*/
function tempfix_62004_sync_ticket_price( $product_id ) {
if ( ! class_exists( 'Tribe__Tickets_Plus__Commerce__WooCommerce__Main' ) ) return;
if ( ! tribe_events_product_is_ticket( $product_id ) ) return;
@barryhughes
barryhughes / custom-purchase-emails_ithemes-exchange.php
Last active June 8, 2016 03:51
Shows a means of tweaking iThemes Exchange purchase emails according to whether downloadables or physical products (or a mix) have just been ordered.
<?php
/**
* Modify the purchase email template according to the sort of products
* that have been ordered.
*
* This is just an example/rough outline and it doesn't concern itself
* with the possibility that other product types besides physical and
* downloadable might exist ;-)
*
* @param string $template
@barryhughes
barryhughes / temp-fix-45385.php
Created March 31, 2016 19:42
Temp fix for empty ticket email problem: ET+ 4.1/4.1.1 (using WooCommerce)
<?php
/**
* If the order is determined to contain no tickets, sets up a filter
* preventing the 'wootickets' email from being dispatched.
*
* @param int $order_id
*/
function stop_empty_ticket_emails( $order_id ) {
$contains_tickets = false;
@barryhughes
barryhughes / event-view-url-slug-filter.php
Last active April 28, 2017 13:14
Revision of custom event view slug snippet
<?php
/**
* Modify the "bases" used to form event URLs for various views.
*
* @param array $bases
*
* @return array
*/
function rename_event_view_slugs( $bases ) {
if ( isset( $bases['month'] ) ) $bases['month'] = [ 'calendar', 'calendar' ];
@barryhughes
barryhughes / wp-http-simulated.php
Last active March 21, 2016 18:19
WP HTTP API: simulated transport for troubleshooting and testing
<?php
/**
* Once setup, this WP HTTP transport does a couple of things:
*
* 1) it means calls to wp_http_get() etc don't result in anything
* actually being sent on the wire
*
* 2) if a save directory is specified it will save a text representation
* of the request in that directory
*
<?php
/**
* Adds email and name columns to the attendee export data (CSV only).
*
* Filters via the tribe_events_tickets_attendees_csv_items hook; intended for use
* with the initial 4.1 release of Event Tickets and Event Tickets Plus in
* combination with EDD only.
*
* @param array $items
* @return array
@barryhughes
barryhughes / add-email-col_et-41.php
Last active March 17, 2016 21:24
ET 4.1: add customer email column to CSV export data
<?php
/**
* Adds email and name columns to the attendee export data (CSV only).
*
* Filters via the tribe_events_tickets_attendees_csv_items hook; intended for use
* with the initial 4.1 release of Event Tickets/Event Tickets Plus in combination
* with WooCommerce only.
*
* @param array $items
* @return array
@barryhughes
barryhughes / cleanup-events-query.sql
Last active January 8, 2016 19:09
This query attempts to delete expired events with special handling for recurring events. Use at own risk!
-- Delete expired events.
--
-- Use at own risk and consider running on a test set of data first of all!
-- As is, should remove all events that have expired by more than one week,
-- with the exception of parent events for recurring events which will be
-- left in place.
--
-- Assumes a standard table prefix of "wp_" - adjust as required to match
-- your installation.
DELETE FROM wp_posts
@barryhughes
barryhughes / temp-fix-week-view-init-date.php
Created January 5, 2016 19:23
Possible temp workaround for an issue where week view 'jumps' to the next upcoming week in conditions where it still ought to show the current week (due to timezone issues)
<?php
function temp_fix_42765( $date ) {
global $wp_query;
if ( ! empty( $wp_query->get( 'eventDate' ) ) )
return $date;
if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
return $date;
@barryhughes
barryhughes / EventWebsiteLink.php
Last active December 11, 2015 22:38 — forked from theeventscalendar/Event Website link
Make an Event Website a link instead of showing the text url