The popular open-source contract for web professionals by Stuff & Nonsense
- Originally published: 23rd December 2008
- Revised date: March 15th 2016
- Original post
<?php | |
/* | |
* REMOVE WORDPRESS' CRAPPY EMOJI | |
*/ | |
remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); | |
remove_action( 'wp_print_styles', 'print_emoji_styles' ); | |
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); | |
remove_action( 'admin_print_styles', 'print_emoji_styles' ); |
const ObjectSingleton = { | |
_instance: null, | |
get instance() { | |
if (!this._instance) { | |
this._instance = { | |
singletonMethod() { | |
return 'singletonMethod'; | |
}, | |
_type: 'ObjectSingleton', |
/* | |
* Array.shuffle | |
* | |
* Usage: | |
* const arr1 = [1, 2, 3, 4, 5]; | |
* const arr2 = Array.shuffle(arr1); | |
* const arr3 = arr1.shuffle(); | |
* | |
* @TODO: | |
* - Add callback functionality to Array.prototype.shuffle |
const PubSub = (() => { | |
const topics = {}; | |
const hOP = topics.hasOwnProperty; | |
return { | |
subscribe(topic, listener) { | |
// Create the topic's object if not yet created | |
if(!hOP.call(topics, topic)) topics[topic] = []; | |
// Add the listener to queue |
(function(globals){ | |
// module name | |
const MODULE_NAME = 'moduleName'; | |
// define your functions here | |
const functions = { | |
fn1: alert, | |
fn2: console.log | |
}; | |
/* | |
* Observer.js | |
* | |
* SYNTAX: | |
* const EventHandler = new MessageBus( context ); | |
* --- | |
* context: identifier for the event handler | |
* --- | |
* USAGE: | |
* var handler = new MessageBus( document ); |
#301 Redirects for .htaccess | |
#Redirect a single page: | |
Redirect 301 /pagename.php http://www.domain.com/pagename.html | |
#Redirect an entire site: | |
Redirect 301 / http://www.domain.com/ | |
#Redirect an entire site to a sub folder | |
Redirect 301 / http://www.domain.com/subfolder/ |
/** | |
* Add dataset support to elements | |
* No globals, no overriding prototype with non-standard methods, | |
* handles CamelCase properly, attempts to use standard | |
* Object.defineProperty() (and Function bind()) methods, | |
* falls back to native implementation when existing | |
* Inspired by http://code.eligrey.com/html5/dataset/ | |
* (via https://github.com/adalgiso/html5-dataset/blob/master/html5-dataset.js ) | |
* Depends on Function.bind and Object.defineProperty/Object.getOwnPropertyDescriptor (polyfills below) | |
* All code below is Licensed under the X11/MIT License |
Object.prototype.data = function (prop, val) { | |
var _return, | |
notIE = ( this.dataset !== undefined ); | |
return ( notIE )? // not IE | |
( typeof val === "undefined" ) ? // get data value | |
this.dataset[prop] : this.dataset[prop] = val | |
: // is IE | |
( typeof val === "undefined" ) ? // get data value | |
this.getAttribute('data-' + prop) : this.setAttribute('data-' + prop, val); |