Skip to content

Instantly share code, notes, and snippets.

@evansolomon
evansolomon / gist:3186427
Created July 27, 2012 06:11
Generic function to add body classes on the fly in WordPress
<?php
/**
* Generic function to add body classes
* Can take either a string of space-separated classes or an array
*
* Requires PHP 5.3 for access to closures
*/
function es_add_body_class( $new_classes ) {
// Turn the input into an array we can loop through
@jazbek
jazbek / gist:6189599
Last active December 20, 2015 20:19
Change tribe community events template
<?php
add_action('wp_router_generate_routes', 'tribe_set_community_template', 100, 1);
function tribe_set_community_template( $router ) {
$new_template = array(
'template' => array('new-template.php'), // edit this filename to be the one you want to use in your theme
);
$router->edit_route('ce-edit-venue-route', $new_template);
$router->edit_route('ce-edit-organizer-route', $new_template);
$router->edit_route('ce-edit-route', $new_template);
@jazbek
jazbek / gist:6585714
Created September 16, 2013 19:55
Fix for hosts with low join limit
<?php
add_action('init', 'tribe_allow_large_joins');
function tribe_allow_large_joins(){
global $wpdb;
$wpdb->query('SET SQL_BIG_SELECTS=1');
}
@jbrinley
jbrinley / gist:6693934
Created September 25, 2013 01:32
Redirect a user after a successful community events submission.
<?php
/**
* This actually does the redirect. If an event was submitted, and we're about
* to reload the submission page (with a message instead of a form), this will
* redirect to the home page.
*
* @param WP $wp
* @return void
*/
@jazbek
jazbek / gist:11382578
Last active August 29, 2015 14:00
Filter a category out of the filter bar options
<?php
add_filter( 'tribe_events_filter_values', 'tribe_filter_event_categories', 10, 2 );
function tribe_filter_event_categories( $values, $slug ) {
if ( $slug == 'eventcategory' ) {
foreach ( $values as $i => $category ) {
if ( $category['name'] == 'Event Category 1' ) {
unset ( $values[$i] );
break;
}
@eriteric
eriteric / movegfjstofooter.php
Last active October 13, 2021 16:55
Load gravity forms JS in footer
// GF method: http://www.gravityhelp.com/documentation/gravity-forms/extending-gravity-forms/hooks/filters/gform_init_scripts_footer/
add_filter( 'gform_init_scripts_footer', '__return_true' );
// solution to move remaining JS from https://bjornjohansen.no/load-gravity-forms-js-in-footer
add_filter( 'gform_cdata_open', 'wrap_gform_cdata_open' );
function wrap_gform_cdata_open( $content = '' ) {
$content = 'document.addEventListener( "DOMContentLoaded", function() { ';
return $content;
}
add_filter( 'gform_cdata_close', 'wrap_gform_cdata_close' );
@kamranayub
kamranayub / ko.extendes.urlSync.js
Created May 11, 2015 16:19
Knockout Extender: URLSync - syncs observable value with URL hash
/**
* An extender that syncs the observable with the address
* bar (using hash fragment). Will load from URL hash or
* querystring (at time of creation) and will
* update hash when observable changes.
*
* Options: string|object
* String: Query parameter key to get/set
* Object:
* - param - Query parameter key to get/set
@brianaohern
brianaohern / om-Optin-success.js
Created July 11, 2018 20:29
om.Optin.success
document.addEventListener('om.Optin.success', function(event) {
// This event is passed the Campaign object
console.log(event.detail.Campaign);
// This event is passed the Optin object
console.log(event.detail.Optin);
// This event is passed the success response
console.log(event.detail.response);
} );