Skip to content

Instantly share code, notes, and snippets.

@sproutventure
sproutventure / gist:1435603
Created December 5, 2011 22:08
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();
}
}
@sproutventure
sproutventure / php_helpers.php
Created September 27, 2011 17:06
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
@sproutventure
sproutventure / gist:1032689
Created June 18, 2011 01:00
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'])) {
@sproutventure
sproutventure / gist:980988
Created May 19, 2011 15:13
PaymentExpress Payment Class
<?php
#******************************************************************************
#* Name : PxPay_Curl.inc.php
#* Description : Classes used interact with the PxPay interface using PHP with the cURL extension installed
#* Copyright : Direct Payment Solutions 2009(c)
#* Date : 2009-04-10
#* Version : 1.0
#* Author : Thomas Treadwell
#******************************************************************************
@sproutventure
sproutventure / GBS latest deal redirect
Created March 21, 2011 20:04
list of locations, link to latest deal instead of archive page
function gb_list_locations_custom( $format = 'ul' )
{
global $gb;
// Form an array of all the locations ( the location term is called 'deals' )
$locations = get_terms(array('deals'),array('hide_empty'=>true,'fields'=>'all'));
// Build out the ul of locations
if ( !empty( $locations) && $format == 'ul' ) {
echo "<ul class='locations-ul clearfix'>";
foreach ($locations as $location) {
$args=array(
@sproutventure
sproutventure / Basic GBS loop
Created March 18, 2011 18:15
Returns some GBS deals
<?php
global $wp_query;
$add_deal_query= null;
$args=array(
'post_type' => 'deal',
'post_status' => 'publish',
'meta_key' => $gb->_metaDealExpiration, // Make sure the deal is not exprired
'posts_per_page' => 3, // return this many
'post__not_in' => array( $wp_query->post->ID ) // do not show the current deal within this loop
);
/**
* Unhook regsitration_form_addons from parent theme on init. Hooking to init because register_form has already been hooked-in
*
* @author Dan Cameron
*/
add_action('init', 'unhook_registration_form_addons');
function unhook_registration_form_addons()
{
remove_action( 'register_form', 'registration_form_addons' );
}
if ( isset($_GET['payment-success']) && ($_GET['payment-success'] != '0' || $_GET['payment-success'] != null) ) {
$userID = Group_Buying_Utility::getCurrentUserId();
?>
<iframe src="http://www.example.com/wp-content/plugins/wp-affiliate-platform/api/post.php?secret=XXXXXXX&trans_id=<?php echo $_GET['trnId'] ?>&ap_id=XXXXXXXX&sale_amt=<?php echo get_deal_value_in_credits( $_GET['item-id'] ); ?>&item_id=<?php echo $_GET['item-id'] ?>" scrolling="no" frameborder="0" width="1" height="1"></iframe>
<?php
}
if ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] ) {
$userID = Group_Buying_Utility::getCurrentUserId();
?>
@sproutventure
sproutventure / gist:799639
Created January 28, 2011 01:15
Modify GB States
add_filter('getStates','new_states');
function new_states()
{
return array(
'' => 'Select',
'AL' => 'Alabama',
'AK' => 'Alaska',
'AS' => 'American Samoa',
'AZ' => 'Arizona',
'AR' => 'Arkansas',