Skip to content

Instantly share code, notes, and snippets.

Avatar

Barry Hughes barryhughes

View GitHub Profile
@barryhughes
barryhughes / remove-category-filter-categories.php
Created Dec 12, 2014
Quick hack to remove a specific category from the Filter Bar (3.9) output
View remove-category-filter-categories.php
/**
* You could add this snippet to your theme's functions.php file
* or any other suitable location.
*/
add_filter( 'tribe_events_filter_values', 'filter_categories_in_category_filter', 10, 2 );
/**
* Handles modifying the list of event categories within Filter Bar.
*
* @param $values
@barryhughes
barryhughes / tec-extensions-transition.php
Created Jan 25, 2015
Helpers/aliases to avoid notices when transitioning from TEC 3.9.x -> 3.10/4.x
View tec-extensions-transition.php
<?php
/**
* Provides access to the main TEC object.
*
* @return TribeEvents|Tribe__Events__Events
*/
function prefix_get_event_instance() {
static $instance;
if ( ! isset( $instance ) && class_exists( 'Tribe__Events__Events' ) ) {
@barryhughes
barryhughes / fix-long-gcal-descriptions.php
Created Feb 9, 2015
Reduces the gcal description size *after* it has been filtered by the_content (applies to TEC 3.9.x)
View fix-long-gcal-descriptions.php
<?php
// ---------------------------------------------------------------------------------------
// When inserting this into a theme's functions.php file you can copy and paste everything
// below this comment (no need to include the opening "<?php" tag, etc!)
// ---------------------------------------------------------------------------------------
/**
* Shortens the event description used within Google Calendar links.
*
@barryhughes
barryhughes / woo231-fix.php
Created Feb 12, 2015
Fixes a compatibility issue between WooCommerce 2.3.x and WooCommerce Tickets 3.9
View woo231-fix.php
<?php
// -----------------------------------------------------------------------------
// The code below this comment should be added to the theme's functions.php file
// -----------------------------------------------------------------------------
// Compatibility fix to help run WooCommerce Tickets 3.9 with WooCommerce 2.3.x
if ( class_exists( 'TribeWooTickets' ) ) {
// Form reference to ticket processing callback
$wootickets = TribeWooTickets::get_instance();
@barryhughes
barryhughes / temp-fix-wt391.php
Created Feb 20, 2015
Fixes an issue with WooCommerce Tickets 3.9.1 and adding multiple items to the cart
View temp-fix-wt391.php
<?php
/**
* Moves the add-to-cart functionality to a later point in the request (ie,
* after the existing cart contents have been populated).
*/
function wootix_rehook_add_to_cart() {
$wootickets = TribeWooTickets::get_instance();
$callback = array( $wootickets, 'process_front_end_tickets_form' );
// Switch to a later action
@barryhughes
barryhughes / list-widget-order-by-publication.php
Created Mar 20, 2015
Make one, some or all list widgets (advanced and regular) show events in publication order (most recent first)
View list-widget-order-by-publication.php
class EventsListWidget_NewlyAddedEvents {
protected $constraints = array(
'sidebar_id' => null,
'widget_id' => null,
'widget_title' => null
);
public function __construct( array $constraints = array() ) {
$this->constraints = array_merge( $this->constraints, $constraints );
add_filter( 'widget_display_callback', array( $this, 'setup' ), 10, 3 );
@barryhughes
barryhughes / continual-month-pagination.php
Created Mar 24, 2015
Let visitors page through all months (not just the populated date range)
View continual-month-pagination.php
/**
* Allows visitors to page forward/backwards in any direction within month view
* an "infinite" number of times (ie, outwith the populated range of months).
*/
class ContinualMonthViewPagination {
protected $tec;
public function __construct() {
add_filter( 'tribe_events_the_next_month_link', array( $this, 'next_month' ) );
add_filter( 'tribe_events_the_previous_month_link', array( $this, 'previous_month' ) );
@barryhughes
barryhughes / category.css.php
Last active Aug 29, 2015
Modified TECCC category CSS template
View category.css.php
<?php
namespace Fragen\Category_Colors;
?>/* The Events Calendar Category Colors <?php echo Main::$version ?> generated CSS */
.teccc-legend a, .tribe-events-calendar a, #tribe-events-content .tribe-events-tooltip h4
{
font-weight: <?php echo $options['font_weight'] ?>;
}
.tribe-events-list .vevent.hentry h2 { padding-left: 5px; }
View undo-single-event-filter.php
/**
* Helper to undo the effects of the Tribe_Template_Factory::title_tag()
* filter (runs on wp_title).
*
* Since in current builds (3.9.x) the actual template object is anonymous
* it is not possible to cleanly unhook it with noodling in WP's global filter
* array, hence the approach taken here.
*/
class SingleEventTitleFilter {
static $title = '';
@barryhughes
barryhughes / all-events-photo-view.php
Created Apr 7, 2015
Show all events past, present and future in photo view (TEC/ECP 3.9.x)
View all-events-photo-view.php
add_action( 'tribe_events_pre_get_posts', 'show_all_in_photo_view' );
function show_all_in_photo_view( $query ) {
// Only modify the main query
if ( ! $query->is_main_query() ) return;
// Only modify photo view (comment out or delete the following
// line to remove this restriction)
if ( 'photo' !== $query->get( 'eventDisplay' ) ) return;