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

Team 8 Concession Duty

No volunteers yet!

We have been asked to cover 12.10pm - 1.20pm on March 29 (so the times have since changed, originally we were to provide volunteers later in the afternoon).

Contact me by email / add a comment if you are available to help out.

@barryhughes
barryhughes / gist:bae73fd5489be6a676cf
Created May 23, 2014 14:51
Replacing the existing date filter (Tribe Bar/3.5)
<?php
/**
* Outline for replacing the existing datepicker with a custom filter field.
*
* (TEC 3.5)
*/
add_action( 'init', 'replace_tribe_bar_search_field', 50 );
function replace_tribe_bar_search_field() {
$callback = array( TribeEvents::instance(), 'setup_date_search_in_bar' );
@barryhughes
barryhughes / gist:31f3941071ea54b102c5
Created June 19, 2014 14:30
Quick hack to remove "Upcoming Events >" (photo view/category applied/TEC 3.6.x)
<?php
add_action( 'tribe_pre_get_view', 'occassionally_kill_pro_title_filter' );
function occassionally_kill_pro_title_filter() {
remove_action( 'tribe_pre_get_view', 'occassionally_kill_pro_title_filter' );
if ( ! tribe_is_photo() ) return; // You could extend or further limit when this runs
remove_filter( 'tribe_get_events_title', array( TribeEventsPro::instance(), 'reset_page_title'));
add_filter( 'tribe_get_events_title', 'modify_events_title' );
}
<?php
/**
* Change the position of the Eventbrite Tickets ticket form (within single event pages).
*/
function change_eventbrite_ticket_position() {
// Do nothing if Eventbrite Tickets is not active
if ( ! class_exists( 'Event_Tickets_PRO' ) ) return;
// Get a reference to the callback method responsible for displaying the ticket form
$display_tickets = array( Event_Tickets_PRO::instance(), 'print_ticket_form' );
@barryhughes
barryhughes / gunzipstring.php
Last active August 29, 2015 14:07
Write a string to a temp file, gunzip it, clean up the temp files and return the decompressed string
<?php
use Exception,
Zend\Filter\Decompress;
/**
* The gzip adapter for Zend's decompression filter doesn't always
* operate reliably on strings. This utility class transparently writes
* the string to a temp file and then passes it through the filter.
*
@barryhughes
barryhughes / fix-31895.php
Created November 11, 2014 14:22
Helper for customizations relying on front page pagination hack
<?php
/**
* Workaround for themes, plugins and customizations that rely on
* redirect_canonical() *not* redirecting when pagination is used
* on a static front page.
*/
add_action( 'init', 'modify_pro_canonical_filter' );
function modify_pro_canonical_filter() {
if ( ! class_exists( 'TribeEventsPro' ) ) return;
@barryhughes
barryhughes / wp-unhook-anonymous-obj-methods.php
Created November 25, 2014 18:03
Unhook actions/filters belonging to anonymous objects
<?php
/**
* Sample approach for removing action/filter functions belonging
* to anonymous objects.
*/
function remove_anonymous_objects_from_wp_hooks() {
global $wp_filter;
// Specific hooks and priorities we want to search
$hooks = [
@barryhughes
barryhughes / nav.php
Created November 26, 2014 18:55
Template override for list/nav.php (TEC 3.8.x) - tests possible efficiency savings in list view pagination
<?php
/**
* List view nav template (making use of alternative pagination functions)
*
* This template isn't really the proper place for the two template definitions included
* at the top, but they could easily be moved to a more suitable location. They've been
* included in this file for no reason other than ease of demonstrating and sharing a
* workaround.
*/
defined( 'ABSPATH' ) or exit( '-1' );
@barryhughes
barryhughes / public_attendee_list.php
Created November 26, 2014 21:18
Registers a [public_attendee_list] shortcode. Should work with The Events Calendar + WooCommerce Tickets (or any of the other related ticketing addons). Simply drop the shortcode into the event description and it will *publicly* list how many folks are attending etc... tweak to make it fit your own needs! You may for instance wish to add a check…
<?php
/**
* Generates output for the [public_attendee_list] shortcode.
*
* Assumes we're interested in the current event or, optionally, a specific
* event ID can be provided:
*
* [public_attendee_list id="789"]
*
* This is a rudimentary starting point only! Please assess and tweak to
@barryhughes
barryhughes / workaround-edd-print-tickets.php
Created December 4, 2014 22:06
Fix a temp issue between EDD Tickets 3.8 and EDD 2.1.9. Please place in your theme's functions.php file (or another suitable location) but be sure to remove the leading <?php tag as appropriate.
class Tribe_EDDTickets_Fix31092 {
/**
* Override EDDTickets' own print_ticket_url() callback.
*/
public function __construct() {
add_filter( 'edd_download_file_url_args', array( $this, 'print_ticket_url' ), 20 );
}
/**
* @param $item