Skip to content

Instantly share code, notes, and snippets.

View dancameron's full-sized avatar
💭
🍻Cheersing

Dan Cameron dancameron

💭
🍻Cheersing
View GitHub Profile
@dancameron
dancameron / filter_homepage_redirect.php
Created March 1, 2012 23:14
GBS: Preserve GET/Tracking Variables from the Homepage Redirect
add_filter('gb_latest_deal_redirect', 'filter_homepage_redirect');
function filter_homepage_redirect() {
$url = gb_get_latest_deal_link();
if ( isset($_GET) ) {
$url = add_query_arg( $_GET ,$url );
}
return $url;
}
@dancameron
dancameron / gist:2148579
Created March 21, 2012 15:35 — forked from sproutventure/gist:1435603
GBS: Action: Require Login on Voucher Claim - GBS
add_action('on_biz_voucher_page','require_login_on_voucher_claim');
function require_login_on_voucher_claim() {
if ( !gb_account_has_merchant() ) {
wp_redirect(gb_get_account_login_url());
exit();
}
}
@dancameron
dancameron / php_helpers.php
Created March 21, 2012 15:35 — forked from sproutventure/php_helpers.php
PHP: Dev Helpers
<?php
function pp() {
$msg = __v_build_message(func_get_args());
echo '<pre style="white-space:pre-wrap; text-align: left; '.
'font: normal normal 11px/1.4 menlo, monaco, monospaced; '.
'background: white; color: black; padding: 5px;">'.$msg.'</pre>';
}
function dp() {
$msg = __v_build_message(func_get_args(), 'var_dump');
echo '<pre style="white-space:pre-wrap;; text-align: left; '.
<?php
function filter_term_archive( $query ) {
if( is_tax( some_custom_post_type_tax_slug() ) ) {
$query->set( 'tax_query', array(
'relation' => 'AND', // Change to OR if we only want to filter one type.
array(
'taxonomy' => some_custom_tax_slug(),
'field' => 'slug',
'terms' => $array_of_terms
<?php
function filter_term_archive( $query ) {
if( is_tax( some_custom_post_type_tax_slug() ) ) {
$query->set( 'tax_query', array(
'relation' => 'AND', // Change to OR if we only want to filter one type.
array(
'taxonomy' => some_custom_tax_slug(),
'field' => 'slug',
'terms' => $array_of_terms
@dancameron
dancameron / gist:2148602
Created March 21, 2012 15:36 — forked from sproutventure/gist:1126637
WP: Action: Filter TAX Archive
<?php
function filter_term_archive( $query ) {
if ( $query->is_tax('your_taxonomy') ) {
$query->set( 'tax_query', array(
'relation' => 'AND', // Change to OR if we only want to filter one type.
array(
'taxonomy' => some_custom_tax_slug(),
'field' => 'slug',
'terms' => $array_of_terms
@dancameron
dancameron / gist:2148648
Created March 21, 2012 15:39 — forked from sproutventure/gist:1032689
GBS: WP Affiliate + GBS +Payfast
<?php
add_filter( 'purchase_record_array', 'affiliate_post');
function affiliate_post( $record_array ) {
// Config
$post_url = "http://www.youdeal.co.za/wp-content/plugins/wp-affiliate-platform/api/post.php";
$key = "ijweol383h538t34t9j";
if ( isset($_COOKIE['ap_id'])) {
@dancameron
dancameron / function.php
Created March 21, 2012 23:15
GBS: Upload and Set Attachment
/**
* Add a file as a post attachment.
*
* @return null
*/
public static function set_attachement( $post_id, $files ) {
if (!function_exists('wp_generate_attachment_metadata')){
require_once(ABSPATH . 'wp-admin' . '/includes/image.php');
@dancameron
dancameron / functions.php
Created March 27, 2012 15:18
GBS: Filter Checkout Registration Panes
add_action('init','filter_gb_controllers', 500);
function filter_gb_controllers() {
remove_all_filters('gb_checkout_account_registration_panes');
add_filter('gb_checkout_account_registration_panes','remove_contact_info_pane');
}
function remove_contact_info_pane( $panes ) {
//Make it a minimal registration since the checkout process will save the billing info.
unset($panes['contact_info']);
return $panes;
}
@dancameron
dancameron / gist:2380052
Created April 13, 2012 20:45 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt