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.php
Created May 8, 2012 15:30
GBS :: Add custom rewrite rules for filtering vouchers
<?php
/**
* Add custom rewrite rules for filtering vouchers
*
* @param array $vars
* @return array
@dancameron
dancameron / deploy.sh
Created August 15, 2012 19:28
Script to deploy from Github to WordPress.org Plugin Repository
#! /bin/bash
#
# Script to deploy from Github to WordPress.org Plugin Repository
#prompt for plugin slug
echo -e "Plugin Slug: \c"
read PLUGINSLUG
# main config, set off of plugin slug
CURRENTDIR=`pwd`
@dancameron
dancameron / Copy Billing to Shipping
Created August 29, 2012 17:26
Copy Billing into Shipping and cache original values.
gbs.ready = function($) {
var $copy_billing_option = $('#gb_shipping_copy_billing');
var $shipping_option_cache = {}; // cache options
$copy_billing_option.bind( 'change', function() {
// Loop over all gb_shipping options, unknowingly what is actually set because of customizations.
$('#gb-shipping [name^="gb_shipping_"]').each(function () {
if ( $( $copy_billing_option ).is(':checked') ) {
var $billing_name = this.name.replace('gb_shipping_', 'gb_billing_'); // Search for a matching field
$shipping_option_cache[this.name] = $(this).val(); // Cache the original option so it can be used later.
$( this ).val( $( '[name="' + $billing_name + '"]' ).val() ); // set the value
@dancameron
dancameron / wp_filter.php
Created September 16, 2012 05:14
Allow WP_Embed (oEmbed) to filter the_content on non post_content.
<?php
// WP_Embed::shortcode will not proceed without a postID
global $post;
$post->ID = PHP_INT_MAX - $data['id']; // Make sure the id is unique so that it can be cached without conflict
echo apply_filters('the_content', $data['content'] );
@dancameron
dancameron / updater.php
Created September 19, 2012 02:49
Theme Updater Example.
<?php
if ( is_admin() ) {
add_filter( 'pre_set_site_transient_update_themes', 'gb_check_for_premium_theme_update' );
}
function gb_check_for_premium_theme_update( $transient ) {
$current_version = 1.2;
$api_key = get_option('theme_api_key'); // your theme options will need to have an option to add the API key.
$theme_slug = 'theme_slug'; // Change to match with API Key Manager
$api_url = 'http://yoursite.com/check-key/'; // change to your site
@dancameron
dancameron / filters.php
Created October 5, 2012 22:15
GBS :: Filter submit_deal for non sponsors
add_action( 'submit_deal', 'redirect_non_sponsor_deal_submission' );
function redirect_non_sponsor_deal_submission( Group_Buying_Deal $deal ) {
if ( is_user_logged_in() && !gb_account_has_merchant( get_current_user_id() ) ) {
$deal_id = $deal->get_ID();
self::redirect_to_merch_registration( $deal_id );
}
}
@dancameron
dancameron / ewaytest.php
Created October 25, 2012 04:51
eWay Tokenized SOAP Client
$client = new SoapClient(
"https://www.eway.com.au/gateway/ManagedPaymentService/test/managedcreditcardpayment.asmx?WSDL",
array( 'soap_version' => SOAP_1_2, 'trace' => 1, 'exceptions' => 1 ) );
$header_data = new stdClass;
$header_data->eWAYCustomerID = '9876543211000';
$header_data->Username = 'test@eway.com.au';
$header_data->Password = 'test123';
$header = new SoapHeader( "https://www.eway.com.au/gateway/managedpayment", "eWAYHeader", $header_data, FALSE );
@dancameron
dancameron / functions.php
Created November 8, 2012 23:41
functions override method
////////////////////////////////////////////
// Child Theme functions override support //
////////////////////////////////////////////
// include functions-parent-override.php from the child theme if it exists. the child theme functions.php is loaded before the template functions.php so we need a place to load overrides afterwards (if necessary)
if ( file_exists( trailingslashit( STYLESHEETPATH ).'functions-parent-override.php' ) && TEMPLATEPATH != STYLESHEETPATH ) {
include_once trailingslashit( STYLESHEETPATH ).'functions-parent-override.php';
}
@dancameron
dancameron / GBS 4.3.0.1 Patch
Created March 15, 2013 19:47
wp_insert_post Title Fix for wp_unique_post_slug latency
diff --git models/groupBuyingCart.class.php models/groupBuyingCart.class.php
index 0c8bee0690f813b094bec94269484c18bd0fc07c..0aba99614a37273440c7d162533abe1707503121 100755
--- models/groupBuyingCart.class.php
+++ models/groupBuyingCart.class.php
@@ -296,8 +296,8 @@ class Group_Buying_Cart extends Group_Buying_Post_Type {
);
} else {
$post = array(
- 'post_title' => self::__( 'Anonymous' ),
- 'post_name' => 'anonymous',
@dancameron
dancameron / gist:5347046
Last active December 16, 2015 00:19
Log of an attempted payment preference status.

Create a payment preference response

[09-Apr-2013 15:50:11] Array
(
[status] => 201
[response] => Array
    (
        [collector_id] => 131258484

[operation_type] => regular_payment