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
window.debugMode = document.location.hash.match(/debug/) and console? console.log 'This is the first of many debug-mode outputs' if debugMode |
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
<?php | |
preg_match_all('!\d+\,*\d*!', $price, $matches); | |
?> |
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
<?php | |
add_filter( 'woocommerce_get_price_html', 'wpa83367_price_html', 100, 2 ); | |
function wpa83367_price_html( $price, $product ){ | |
preg_match_all('!\d+\,*\d*!', $price, $prices); | |
$discount = ''; | |
if(isset($prices[0]) && !empty($prices[0])){ | |
if(count($prices[0])==2){ //There's total and discount prices | |
$total_price = floatval(str_replace(',', '.', $prices[0][0])); | |
$discount_price = floatval(str_replace(',', '.', $prices[0][1])); | |
$discount_amount = $total_price - $discount_price; |
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
/* | |
* Taken from http://www.wprecipes.com/log-in-a-wordpress-user-programmatically | |
*/ | |
<?php | |
function auto_login( $user ) { | |
$username = $user; | |
if ( !is_user_logged_in() ) { | |
$user = get_userdatabylogin( $username ); | |
$user_id = $user->ID; | |
wp_set_current_user( $user_id, $user_login ); |
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
//Taken from http://stackoverflow.com/questions/18206115/how-to-avoid-affecting-other-queries-when-using-posts-orderby | |
// My list of post IDs in my custom order | |
$my_post_ids = array(1,3,2); | |
// Apply filter to the ORDERBY SQL statement | |
add_filter('posts_orderby', 'my_custom_orderby'); | |
function my_custom_orderby($orderby_statement) { | |
// Disable this filter for future queries! |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
<?php | |
function list_hooked_functions($tag=false){ | |
global $wp_filter; | |
if ($tag) { | |
$hook[$tag]=$wp_filter[$tag]; | |
if (!is_array($hook[$tag])) { | |
trigger_error("Nothing found for '$tag' hook", E_USER_WARNING); | |
return; | |
} | |
} |
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 make_absolute($url, $base) | |
{ | |
// Return base if no url | |
if( ! $url) return $base; | |
// Return if already absolute URL | |
if(parse_url($url, PHP_URL_SCHEME) != '') return $url; | |
// Urls only containing query or anchor | |
if($url[0] == '#' || $url[0] == '?') return $base.$url; |
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
-- Adapted from http://movingparts.net/2012/09/25/changing-backgroundwallpaper-on-os-x-with-multiple-spaces-and-multiple-monitors/ | |
-- Copied from http://apple.stackexchange.com/questions/61677/changing-desktop-background-in-os-x-10-8-only-changes-it-for-the-current-desktop | |
-- pick a new background image | |
set theFile to choose file | |
-- *Note*: Set the number of spaces/desktops manually | |
set numSpaces to 12 | |
-- Loop through the spaces/desktops, setting each of their backgrounds in turn: |
OlderNewer