Skip to content

Instantly share code, notes, and snippets.

View wpscholar's full-sized avatar
😀
Happy

Micah Wood wpscholar

😀
Happy
View GitHub Profile
<?php
$email = isset( $_GET['email'] ) ? $_GET['email'] : 'null';
$salt = isset( $_GET['salt'] ) ? $_GET['salt'] : '';
// hash email, split it up
$hash = str_split( sha1( $email . $salt ), 2 );
// use first 3 values for foreground
$foreground = "{$hash[0]}{$hash[1]}{$hash[2]}";
@caseydriscoll
caseydriscoll / gist:20e7f714b90cd8c56d56
Created June 27, 2014 17:54
Tribe Unlimited iCal Feed
class UnlimitedICalFeed {
public static function setup() {
add_action( 'pre_get_posts', array( __CLASS__, 'pre_get_posts' ), 75 );
}
public static function pre_get_posts( WP_Query $query ) {
if ( ! $query->tribe_is_event_query ) return self::shutdown();
if ( ! isset($_GET['ical'] ) || 'all' !== $_GET['ical'] ) return self::shutdown();
$query->set( 'posts_per_page', -1 );
}
@wpscholar
wpscholar / load-views.php
Created July 23, 2014 18:47
Load Ember templates in WordPress
<?php
/**
* Load Ember templates in WordPress
*/
public static function load_views() {
$iterator = new \DirectoryIterator( plugin_dir_path( __FILE__ ) . 'views' );
foreach ( $iterator as $file ) {
/**
* @var \SplFileInfo $file
anonymous
anonymous / tabbed-tertiary
Created December 23, 2011 22:43
General markup for tabbed tertiary navigation in WordPress admin
<h2 class="nav-tab-wrapper">
Plugin Settings
<a href="#" class="nav-tab nav-tab-active">Tab 1</a>
<a href="#" class="nav-tab">Tab 2</a>
</h2>
@joewest
joewest / didRequestRange.js
Created January 13, 2012 20:14
Ember.PaginationSupport
App.collectionController = Em.ArrayProxy.create(Ember.PaginationSupport, {
content: [],
fullContent: App.store.findAll(App.Job),
totalBinding: 'fullContent.length',
didRequestRange: function(rangeStart, rangeStop) {
var content = this.get('fullContent').slice(rangeStart, rangeStop);
this.replace(0, this.get('length'), content);
}
});
@thelonecabbage
thelonecabbage / recursive.tojson for backbone
Created March 12, 2012 08:31
Recursive toJSON for Backbone.js
Data.Model = Backbone.Model.extend({
toJSON: function(){
var clone = _.clone(this.attributes);
_.each(clone, function (attr, idx) {
if(attr.toJSON){
clone[idx] = attr.toJSON();
}
});
return clone;
}
@taras
taras / purge.php
Created November 13, 2012 15:26
Script that empties Varnish Cache
# get param
$url = $_POST["url"];
$host = $_POST["host"];
$ip = "127.0.0.1";
$port = "80";
$timeout = 1;
$verbose = 1;
@tott
tott / gist:1220235
Created September 15, 2011 19:29
hide certain posts from search
if ( function_exists( 'wpcom_is_vip' ) && wpcom_is_vip() ) {
wpcom_vip_load_helper_wpcom();
} else {
require_once( WP_CONTENT_DIR . '/themes/vip/plugins/vip-do-not-include-on-wpcom/vip-local-development-helper/vip-local-development-helper.php' );
require_once( WP_CONTENT_DIR . '/themes/vip/plugins/vip-do-not-include-on-wpcom/vip-powered-wpcom/vip-powered-wpcom.php' );
}
wpcom_vip_load_helper();
wpcom_vip_load_plugin( 'easy-custom-fields' );
@FrankM1
FrankM1 / provision.sh
Created May 18, 2015 14:06
Faster provisioning for vvv - Removed provisioning for Wordpress Core development. That took a long time to complete
#!/bin/bash
#
# provision.sh
#
# This file is specified in Vagrantfile and is loaded by Vagrant as the primary
# provisioning script whenever the commands `vagrant up`, `vagrant provision`,
# or `vagrant reload` are used. It provides all of the default packages and
# configurations included with Varying Vagrant Vagrants.
# By storing the date now, we can calculate the duration of provisioning at the
@trepmal
trepmal / no-whitespace-nav.php
Created January 3, 2014 00:14
(WordPress snippet) Gets rid of the whitespace between "</li> <li>" in custom nav menus. Why? The whitespace can cause stupid headaches when the li's have `display: inline-block;`
<?php
// note the walker param
wp_nav_menu( array(
'walker' => new No_WhiteSpace_Nav_Menu,
'theme_location' => 'primary',
'menu_class' => 'nav-menu'
) );
// in your theme's functions.php