This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Console application, which adds textdomain argument | |
* to all i18n function calls | |
* | |
* Adapted from: | |
* http://develop.svn.wordpress.org/trunk/tools/i18n/add-textdomain.php | |
* | |
* Extended such that all text domains are replaced if found or added otherwise. | |
* Also, double-quoted strings are replaced by single-quoted strings. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Pass a defined variable and an arbitrary number of | |
* property names to get the typeof the deepest property. | |
* @param {mixed} value any defined JS variable | |
* optional, unlimited: | |
* @param {string|array} property name or array of args to call the previous property with and use that value | |
* @return {string|false} typeof that property or false if evaluating the chain would result in a reference error | |
* | |
* @example | |
* typeofProp(window,'location','href','toString',[],'substr','foo','bar'); // false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Takes a block of CSS and uses the browser's CSS parsing mechanism to sanitize | |
* the content and return only valid style declarations. Optionally you can | |
* prepend each selector with another selector to isolate the styles even further. | |
* A use case would be accepting user-generated CSS. | |
*/ | |
function sanitizeCSS(css, selectorPrefix) { | |
var style = document.createElement('style') | |
, rules | |
, output = '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($,a,f){a=$.ajax,f={};f.done=f.fail=f.always=f.abort=function(){return f};$.ajax=function(d){return d&&d.data&&d.data.action=='heartbeat'?f:a.apply($,arguments)};console.log('\uD83D\uDC94')})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($,s,l,p){(s=$('iframe.wysihtml5-sandbox')[0])&&(s=s.contentWindow.getSelection())&&(l=$(s.focusNode).closest('li'))&&(p=l.prev('li'))&&p.length&&p.append($('<ul>').append(l))})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.HTMLElement.prototype.getXPath = function() { | |
// special cases | |
if (this.id) return '//*[@id="' + this.id + '"]'; | |
if (this.tagName.toLowerCase() === 'html') return '/html'; | |
var count = 0, index, nodes = this.parentNode.childNodes; | |
for (var i = 0; i < nodes.length; i++) { | |
if (nodes[i].nodeType !== 1 || nodes[i].tagName !== this.tagName) continue; | |
count++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Protected setter/getter which uses an arbitrary object as a "key". | |
* The safety comes from the object "key" existing only within the protected scope of the consuming objects. | |
* @param {object} key object used to | |
* @param {bool} silent silently fails with incorrect key instead of | |
*/ | |
function ProtectedData(key, silent) { | |
// key must be an object for it to be secure | |
if (Object(key) !== key) throw new Error('Invalid key type.'); | |
// property mapping |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Provides a rudimentary means of debugging by snooping on method calls to a particular kind of object. | |
* All of the object's prototypal methods will be wrapped in a new function that provides information | |
* in the console. When the method is called, the object type, method, and params will be logged in | |
* the console, then the original method will be called with the proper arguments. | |
* | |
* @param {function} obj object constructor to snoop (not an instantiated object) | |
* @return {function} the same object for chaining | |
*/ | |
function prototypeSnooper(obj) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* When using the WordPress Importer, update existing | |
* posts instead of skipping them. Updates content according | |
* to the import file even if the existing post was updated | |
* more recently. | |
* | |
* To use, drop this file into your /mu-plugins/ folder or | |
* copy this code into your functions.php file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// example output CSS | |
.container :nth-of-type(5n + 1), .container :nth-of-type(5n + 2), .container :nth-of-type(5n + 3) { | |
background: orange; | |
} | |
.container :nth-of-type(5n + 4), .container :nth-of-type(5n + 5) { | |
background: blue; | |
} |
OlderNewer