Skip to content

Instantly share code, notes, and snippets.

View brandwaffle's full-sized avatar

Vasken Hauri brandwaffle

View GitHub Profile
<?php
add_filter( 'ep_prepare_meta_allowed_protected_keys', 'ep_add_priority_meta', 10, 2 );
function ep_add_priority_meta( $keys, $post ) {
$keys[] = '_priority';
return $keys;
}
wordpress:
endpoint: 'http://local.wordpress.dev/wp-json'
cacheLimit: 3600000 # 1000ms * 60s * 60m = 1hr
@brandwaffle
brandwaffle / gist:a8584a5b422f2ea5e6db
Created August 22, 2014 01:33
Harvest Invoice Sorter Bookmarklet
javascript:(function()%7Bfunction callback()%7Bdocument.getElementsByTagName('table')%5B0%5D.className %3D "timesheet_summary invoice_dashboard sortable"%7Dvar s%3Ddocument.createElement("script")%3Bs.src%3D"https%3A%2F%2Fcdn.jsdelivr.net%2Fsorttable%2F2%2Fsorttable.min.js"%3Bif(s.addEventListener)%7Bs.addEventListener("load"%2Ccallback%2Cfalse)%7Delse if(s.readyState)%7Bs.onreadystatechange%3Dcallback%7Ddocument.body.appendChild(s)%3B%7D)()
@brandwaffle
brandwaffle / gist:68261e7d42cf6dc3d184
Created August 22, 2014 01:16
Harvest Sortable invoice table bookmarklet
document.getElementsByTagName('table')[0].className = "timesheet_summary invoice_dashboard sortable";
/*
SortTable
version 2
7th April 2007
Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/
Instructions:
Download this file
Add <script src="sorttable.js"></script> to your HTML
@brandwaffle
brandwaffle / events.js
Created June 28, 2012 21:13
Globalized JS events for WP
//based on and borrowing heavily from http://tdanemar.wordpress.com/2010/01/19/global-events-with-jquery/
//define an addAction plugin method that will store the event in a single container object (WP.eventHolder)
//so that it doesn't pollute the global space, but we can still access it in a 'global' way
$.fn.addAction = function(eventName, func) {
$(WP.eventHolder).bind(eventName, this, function(e) { func.call(e.data);
});
//add an action that will fire when the addFeaturedPost WP event fires
$('.featured-post').addAction('WP.eventTriggers.addFeaturedPost', function(e){
@brandwaffle
brandwaffle / gist:2703078
Created May 15, 2012 16:31
Changes WP_Dependencies' constructor to handle a string $deps and convert it to an array with a single element (props @abackstrom)
Index: class.wp-dependencies.php
===================================================================
--- class.wp-dependencies.php (revision 20792)
+++ class.wp-dependencies.php (working copy)
@@ -245,7 +245,9 @@
function __construct() {
@list($this->handle, $this->src, $this->deps, $this->ver, $this->args) = func_get_args();
- if ( !is_array($this->deps) )
+ if ( is_string( $this->deps ) )
@brandwaffle
brandwaffle / gist:2703013
Created May 15, 2012 16:20
wp_enqueue_script that converts a string $deps to an array with a single element
Index: functions.wp-scripts.php
===================================================================
--- functions.wp-scripts.php (revision 20792)
+++ functions.wp-scripts.php (working copy)
@@ -131,6 +131,11 @@
$wp_scripts = new WP_Scripts();
}
+ //if a single param is passed as the dependency, convert to an array so WP_Dependencies won't convert
+ //it to an empty array
@brandwaffle
brandwaffle / gist:2702967
Created May 15, 2012 16:13
Add an array check to wp_enqueue_script and convert a single $deps passed as a string to an array with one element
<?php
function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false, $in_footer = false ) {
global $wp_scripts;
if ( !is_a($wp_scripts, 'WP_Scripts') )
$wp_scripts = new WP_Scripts();
if ( $src ) {
$_handle = explode('?', $handle);
$wp_scripts->add( $_handle[0], $src, $deps, $ver );
@brandwaffle
brandwaffle / gist:1525319
Created December 27, 2011 22:11
P2 jQuery cleanup diff
Index: inc/js.php
===================================================================
--- inc/js.php (revision 18733)
+++ inc/js.php (working copy)
@@ -239,26 +239,26 @@
<script type="text/javascript">
/* <![CDATA[ */
- jQuery(document).ready( function() {
+ jQuery(document).ready( function($) {