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 / cart.php
Created March 13, 2018 08:08
Simplified example of using a redirect to prevent accidental resubmission of form data
<?
// Test early in the request for submitted data
if ( isset( $_POST['some-data'] ) ) {
// Add to cart or do other work with this data
setcookie( 'some-data', $_POST['some-data'] );
// Redirect to prevent resubmissions of the same form
header( 'Location: /cart.php' );
exit();
}
@barryhughes
barryhughes / custom-import-sample.php
Last active February 28, 2018 02:03
Example/starting point for custom import jobs using Eventbrite Tickets 4.4.8
<?php
/**
* Example of searching Eventbrite for events and importing them via
* Eventbrite Tickets.
*
* By design, Eventbrite Tickets 4.4.x allows importing from whichever user
* account it has been linked with as well as individual events belonging to
* other accounts, which can be specified via their ID or URL.
*
* This is an example of searching for and importing a broader swathe of
<?php
/**
* @param string $date (yyyy-mm-dd format)
* @param string $timezone
*
* @return bool|null
*/
function is_dst( $date, $timezone ) {
try {
$datetime = date_create();
@barryhughes
barryhughes / tec-remove-noindex-hints.php
Created February 5, 2018 20:14
Stop The Events Calendar from adding "noindex,follow" tags to event views. Use with caution/read up on soft 404s before using.
<?php
/**
* Plugin name: Remove Events No Index Tag
* Description: Prevents The Events Calendar from telling search engines not to index various views
*/
apply_filters( 'tribe_events_add_no_index_meta', '__return_false' );
<?php
### Example of adding an extra column to the Event Tickets/Event Tickets Plus
### attendee table.
###
### Tested with Event Tickets Plus 4.6.2
# Register our extra column
add_filter( 'tribe_tickets_attendee_table_columns', function( $columns ) {
$columns['extra'] = 'My extra column';
return $columns;
@barryhughes
barryhughes / temp-fix-embedded-month-view-day-links.php
Last active May 2, 2019 16:10
Provides a temp workaround to help ensure the more event/view all X event links within month view are functional
@barryhughes
barryhughes / single-event.php
Created November 29, 2017 22:54
Modified version of the single-event.php template (for TEC 4.6.3 → 4.6.6)
<?php
/**
* Modified single event template.
*
* This deviates from the default template by capturing the previous and next
* event link HTML and re-using it, preventing the same queries from running
* twice unnecessarily.
*
* @version 4.6.3
*/
@barryhughes
barryhughes / wpseo-tec-mobile-view-compat.php
Created November 22, 2017 22:56
Quick hack to resolve a conflict/integration issue between WP SEO and The Events Calendar re mobile view settings and navigation
<?php
/**
* Temporary workaround to try and ensure the default mobile
* view is respected and that switching between views is possible
* when TEC is running alongside WP SEO.
*
* Tested with:
*
* - The Events Calendar 4.6.6
* - WordPress SEO 5.8
@barryhughes
barryhughes / temp-fix-ecp-embedded-photo-view-avada.php
Last active February 6, 2018 20:59
Can be used to resolve a conflict caused by ECP and Avada adding two different versions of the same library (Isotope)
<?php
/**
* Temporary fix for an Isotope conflict between Events Calendar PRO
* and Avada, when the [tribe_events] shortcode is used to embed
* photo view.
*
* Tested with Events Calendar PRO 4.4.19
* and Avada 5.3.0.
*/
add_action( 'tribe_events_pro_tribe_events_shortcode_prepare_photo', function() {