Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block dalethedeveloper

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View JavaScript - DOM Ready(ier)
* Works in Chrome, Firefox, MSIE, Opera and Safari.
function onDOMContentLoaded( event ) {
if( event ) {
document.removeEventListener( event.type, onDOMContentLoaded, false );
document.onreadystatechange = null;
// For testing purposes.
alert( "DOM Content Loaded" );
dalethedeveloper / gist:965036
Created May 10, 2011
Wordpress + Facebook Done Right: Load FBConnect asynchronously for XFBML and handle the channelUrl
View gist:965036
* A class-based approach to bring in Facbook Connect asynchronously on every
* frontend page load. Also handles side-loading channelURL when using
* Facebook's FB.init() method.
* This fits nicely in any functions.php, or can be dropped in to a standalone
* php file to use as a plugin.
* @link
dalethedeveloper / gist:966848
Created May 11, 2011
Reorder a PHP array, moving items up or down
View gist:966848
A quick set of functions to move items in a non-associative array
up or down by one, shifting the items around it appropriately.
Original usage was to for a set of UP and DOWN buttons to
manipulate the order of an array of items stored in Wordpress option.
$a = array('a','b','c','d','e');
dalethedeveloper / gist:968926
Created May 12, 2011
Encrypt a WordPress Option using MySQL ENCRYPT()
View gist:968926
An example of using MySQL's ENCRYPT() and DECRYPT() functions to store
sensitive data in a Wordpress Option. In this case, a password.
This only provides a bare amount of security as your Key is likely stored somewhere
else in your code or database. Basically, its not plaintext.
dalethedeveloper / gist:1042934
Created Jun 23, 2011
Backup bash script for Webserver DB + Site Files
View gist:1042934
# Requires:
dalethedeveloper / gist:1093962
Created Jul 19, 2011
Mimic a static HTML file from Wordpress using functions.php
View gist:1093962
/* When an html page like URL is accessed, return some static content,
In this case, a verification page for Google Apps
In the current theme functions.php:
if( !class_exists('google_verify') ) {
class google_verify {
public function __construct() {
add_filter('rewrite_rules_array', array($this,'gv_rewrite') );
if( !is_admin() ) {
dalethedeveloper / gist:1123968
Created Aug 3, 2011
Timestamp to a plain words description of elapsed delta (great for Twitter timestamps)
View gist:1123968
// Adapted from jQuery TimeAgo plugin:
// Update, check out performance:
function timetowords(timestamp) {
var words = {
"seconds": "less than a minute",
"minute": "about a minute",
"minutes": "%d minutes",
dalethedeveloper / gist:1126105
Created Aug 4, 2011
Minimalist post-load of Twitter Statuses to a page using jQuery (with bonus relative time description + Wordpress wraps!)
View gist:1126105
jQuery(document).ready(function($) {
$.getJSON('', function(data){
var relative_time = function(datetime) {
var delta = parseInt(( - Date.parse(datetime)) / 1000, 10);
var r = '';
if (delta < 60) {
r = delta + ' seconds ago';
} else if (delta < 120) {
r = 'A minute ago';
} else if (delta < (45 * 60)) {
dalethedeveloper / gist:1222205
Created Sep 16, 2011
Implementing rel="next" and rel="prev" on Wordpress
View gist:1222205
This will work on WP 2.7.0 on up on the commonly used get_xxxxxxx_posts_link call.
From Google:
add_filter('next_posts_link_attributes', create_function('$attr','return $attr.\' rel="next" \';'));
add_filter('previous_posts_link_attributes', create_function('$attr','return $attr.\' rel="prev" \';') );
dalethedeveloper / gist:1246351
Created Sep 27, 2011
Wordpress functions.php snippet to add Google Analytics tracking to wp_nav_menu with Yoast's plugin
View gist:1246351
For use in functions.php in combination with:
add_filter('wp_nav_menu', 'menu_ga_tracking', 99);
function menu_ga_tracking($menu) {
if( class_exists('GA_Filter') and yoast_ga_do_tracking() ) {
$menu = preg_replace_callback(
You can’t perform that action at this time.