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 | |
//wp_get_active_and_valid_plugins() is the function which fetches all the active plugins and load them. | |
//This function gets these active plugins from the database where the list of active plugins are stored | |
//as an array in the wpdb_options table with option name as “active_plugins” | |
foreach ( wp_get_active_and_valid_plugins() as $plugin ) | |
include_once( $plugin ); | |
unset( $plugin ); | |
?> |
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 checkPalindrome(thestr) { | |
var reverseStr = thestr.split('').reverse().join(''); | |
if (thestr == reverseStr){ | |
return "yay"; | |
}else{ | |
return "nope" | |
} | |
} | |
//checkPalindrome("aba"); |
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
var numbers = [342, 16, 8, 345, 23, 436, 75]; | |
highestVal(numbers);//436 | |
lowestVal(numbers);//8 | |
function highestVal(array){ | |
var highestN = Math.max.apply(Math, array) | |
return highestN; | |
} |
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
//Adding a hidden product to cart with applied coupon woocommerce/wordpress | |
//a modified version of this:http://docs.woothemes.com/document/automatically-add-product-to-cart-on-visit/ | |
add_action( 'init', 'add_product_to_cart' ); | |
<?php | |
function add_product_to_cart() { | |
if ( ! is_admin() ) { | |
global $woocommerce; | |
$product_id = 1211; | |
$found = 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
//@ http://jsfromhell.com/array/shuffle | |
shuffle = function(v){ | |
for(var j, x, i = v.length; i; j = parseInt(Math.random() * i), x = v[--i], v[i] = v[j], v[j] = x); | |
return v; | |
}; | |
//example: | |
var a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; | |
shuffle(a); |
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
//// http://stackoverflow.com/questions/10032024/how-to-remove-leading-and-trailing-white-spaces-from-a-given-html-string | |
//Running the following code before any other code will create trim() if it's not natively available. | |
if(!String.prototype.trim) { | |
String.prototype.trim = function () { | |
return this.replace(/^\s+|\s+$/g,''); | |
}; | |
} |
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 custom_code(){ | |
if ( is_page( 102 )) { | |
?> | |
<!-- TRACKING CODE OR WHATEVER --> | |
<?php | |
} | |
} | |
add_action('wp_footer', 'custom_code'); |
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
<!-- load script from CDN --> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js"></script> | |
<!-- if fails, fallback a local version --> | |
<script>window.angular || document.write('<script src="js/angular.min.js"><\/script>');</script> |