This file contains hidden or 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
Object.prototype.merge = function ( source, target ) { | |
var merged = (typeof target !== 'object') ? {} : target; | |
for ( var property in source ) { | |
if(source.hasOwnProperty(property)) { | |
var sourceProperty = source[property]; | |
if(typeof sourceProperty === 'object') { | |
// call this function recursively for nested objects | |
merged[property] = this.merge( merged[property], sourceProperty); | |
continue; | |
} |
This file contains hidden or 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 isFunction( fn ){ | |
var getType = {}; | |
return fn && getType.toString.call(fn) === '[object Function]'; | |
} |
This file contains hidden or 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
var addListener = (function() { | |
if (window.addEventListener) { | |
return function(el, ev, fn) { | |
el.addEventListener(ev, fn, false); | |
}; | |
} else if (window.attachEvent) { | |
return function(el, ev, fn) { | |
el.attachEvent('on' + ev, function() { fn.call(el); }, false); | |
}; | |
} |
This file contains hidden or 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 get_terms_also_in( $list_taxonomy, $also_in_taxonomy, $with_term ){ | |
global $wpdb; | |
$second_term_slug = sanitize_title_with_dashes( $with_term ); | |
$tax1 = sanitize_title_with_dashes( $list_taxonomy ); | |
$tax2 = sanitize_title_with_dashes( $also_in_taxonomy ); | |
$sql = $wpdb->prepare(" | |
SELECT cat.name, cat.slug, cat.term_id | |
FROM ( SELECT ac.name, ac.slug, ac.term_id, ac.term_taxonomy_id, tr.object_id | |
FROM {$wpdb->prefix}posts p, | |
( SELECT t.name, t.slug, t.term_id, tt.term_taxonomy_id FROM {$wpdb->prefix}term_taxonomy tt, {$wpdb->prefix}terms t |
This file contains hidden or 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 fprint_r() { | |
foreach(func_get_args() as $arg) print '<pre>' . print_r($arg, 1) . '</pre>'; | |
} |