Skip to content

Instantly share code, notes, and snippets.

@stephenharris
stephenharris / bookees-list.php
Created January 7, 2015 12:04
Displays a simple list of those who've placed a booking for an event
/**
* Appends a list of bookees to the event description.
* If you are selling tickets by 'date', it shows the bookees for each date.
*/
function my_display_attendees( $content ){
if( 'event' != get_post_type() || !is_singular( 'event' ) ){
return $content;
}
@stephenharris
stephenharris / register-template.php
Created January 8, 2015 18:35
Allows registering Backbone templates as scripts
/**
* @author Franz Josef Kaiser http://unserkaiser.com/
* @link http://chat.stackexchange.com/transcript/message/19439060#19439060
*/
// Allows registering Backbone templates as scripts
// Add type="text/template" and id="{handle}" for Backbones .tmpl <script>s
add_filter( 'script_loader_tag', function( $html, $handle, $src )
{
$dom = new \DOMDocument;
@stephenharris
stephenharris / exclude-bookings.php
Last active August 29, 2015 14:15
Excludes bookings for other organisers from Event Organiser's Pro bookings admin page
<?php
/**
* Excludes bookings for other organisers from Event Organiser's Pro bookings admin page
* Applies only to users who do not have permission to manage others' bookings
* (see Settings > Event Organiser > Permissions).
*/
function sod_eo_pro_bookings_for_event_organiser( $clauses, $query ){
global $wpdb;
@stephenharris
stephenharris / eo-theme.php
Created February 20, 2015 10:23
Examples of filters themes can use to easily style Event Organiser Pro's booking form
<?php
/**
* Examples of filters themes can use to easily style Event Organiser Pro's booking form
* The classes used in this example should ensure the booking form looks native to
* any bootstrap based theme.
* Of course, you can change those classes to whatever your theme uses.
**/
<?php
/*
* Plugin Name: Event Organiser iCal feed work around
* Version: 1.0
* License: GNU General Public License, v2 (or newer)
* License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* Description: Implements a work around for feeds with invalid DTSTART/DTEND properties.
*/
/**
@stephenharris
stephenharris / get-local-copy-of-all-remote-branches.sh
Created October 8, 2015 09:38
A oneline script to create tracking branches for all remote branches
# A oneline script to create tracking branches for all remote branches
# @see http://stackoverflow.com/a/4754797/932391
#
git branch -a | grep -v HEAD | perl -ne 'chomp($_); s|^\*?\s*||; if (m|(.+)/(.+)| && not $d{$2}) {print qq(git branch --track $2 $1/$2\n)} else {$d{$_}=1}' | csh -xfs;
@stephenharris
stephenharris / wp-member-conditional-logic.php
Last active December 11, 2015 08:28
Using WP-Member to hide / show content depending on various conditions.
<?php
/**
* Using WP-Member to hide / show content depending on various conditions.
*
* This displaying content depending on:
* * Whether the member has **only** the guest level attached to them (this includes, but not restricted to logged out users)
* * Whether the member has the level 'Some Level' attached to theme
* * Otherwise if the user is logged in, displays a different message.
*
*/
@stephenharris
stephenharris / sh-no-wp-footer.php
Last active December 11, 2015 11:38
Displays a warning if `wp_footer()` is not called by a theme.
@stephenharris
stephenharris / wp-member-get-level-by-slug.php
Created January 23, 2013 21:55
Get membership level ID by Name / Slug
<?php
/**
* Get membership level ID by Name / Slug
*/
//Be careful - the name is not unique!
$level = wpmember_get_level_by( 'name', 'Basic Subscription' );
if( $level ){
$level_id = $level->term_id;
}else{
//Not found!
@stephenharris
stephenharris / venue-tooltip-upcoming-events.php
Last active December 13, 2015 22:59 — forked from stephenh1988/venue-tooltip-upcoming-events.php
Adds upcoming events to the venue tooltip in Event Organiser.
<?php
/**
* Adds upcoming events to the venue tooltip in Event Organiser.
*
* Uses the eventorganiser_venue_tooltip filter to append content to the venue tooltip. This tooltip appears when
* clicking a venue on a map (if tooltips are enabled).
* @uses eventorganiser_venue_tooltip.
*
* The filter passes 2 objects: the content of the toolip, the venue (term) ID
*