Skip to content

Instantly share code, notes, and snippets.

View brandwaffle's full-sized avatar

Vasken Hauri brandwaffle

View GitHub Profile
@brandwaffle
brandwaffle / jquery.scrolltest.js
Created April 20, 2011 02:20
hashbang jQuery scroller
jQuery(window).load(function(){
var scroll_array = window.location.hash.split('/', 2);
if(scroll_array[0] === '#!showcomment')
window.scroll(0,jQuery('#div-comment-'+scroll_array[1]).offset().top - 100);
jQuery('#div-comment-'+scroll_array[1]).css('background-color', '#F5A9A9');
});
@brandwaffle
brandwaffle / jquery.commentswitcher.js
Created April 21, 2011 00:31
switches betwixt fb and wp comments
jQuery('.switch-to-fb-comments').live('click', function(){
window.wp_comm_form = jQuery('#respond').html();
jQuery('#facebook_comments').remove();
jQuery('#respond').html('<a href="#" class="switch-to-wp-comments">Switch to WP</a><fb:comments id="facebook_comments" href="url_to_comment"></fb:comments>');
fbAsyncInit();
event.preventDefault();
});
jQuery('.switch-to-wp-comments').live('click', function(){
jQuery('#respond').html(window.wp_comm_form);
event.preventDefault();
@brandwaffle
brandwaffle / facebook.html
Created September 27, 2011 00:11
facebook data retrieval
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"
xmlns:fb="https://www.facebook.com/2008/fbml">
<head prefix="og: http://ogp.me/ns# brandwaffel:
http://ogp.me/ns/apps/brandwaffel#">
<meta property="fb:app_id" content="164019983683858" />
<meta property="og:type" content="brandwaffel:the_noid" />
<meta property="og:title" content="the Noid" />
<meta property="og:image" content="http://brandwaffle.info/facebook/noid.gif" />
<meta property="og:description" content="Can you do it?" />
@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($) {
@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: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: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 / 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: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 / 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)()