Skip to content

Instantly share code, notes, and snippets.

View supercleanse's full-sized avatar

Blair Williams supercleanse

View GitHub Profile
@supercleanse
supercleanse / prettylinktracker.php
Created July 13, 2011 03:59
Pretty Link Tracking
<?php
// This is where the magic happens!
function track_link($slug,$values)
{
global $wpdb, $prli_click, $prli_options, $prli_link, $prli_update;
$query = "SELECT * FROM ".$prli_link->table_name." WHERE slug='$slug' LIMIT 1";
$pretty_link = $wpdb->get_row($query);
$pretty_link_target = apply_filters('prli_target_url',array('url' => $pretty_link->url, 'link_id' => $pretty_link->id));
$pretty_link_url = $pretty_link_target['url'];
@supercleanse
supercleanse / prettylinkrobotdetector.php
Created July 13, 2011 04:01
Pretty Link Robot detection
<?php
function is_robot(&$click,&$browsecap,$header='')
{
global $prli_utils, $prli_click, $prli_options;
$ua_string = trim(urldecode($click->browser));
$btype = trim($click->btype);
// Yah, if the whole user agent string is missing -- wtf?
if(empty($ua_string))
return 1;
@supercleanse
supercleanse / caseproof-lamp.sh
Created April 12, 2012 15:35
Install the caseproof lamp install vagrant box
vagrant box add caseproof-lamp https://s3.amazonaws.com/caseproof/caseproof-lamp.box
vagrant init caseproof-lamp
vagrant up
@supercleanse
supercleanse / maze.rb
Created May 21, 2012 23:50
Some Fun code to generate a maze
# Uses a depth first traversal algorithm to generate a maze
# You can change the width & height by altering the w & h variables
w=24;h=12;g=[];v=[]
# Setup the grid
(h+1).times{|y|g[y]=[];(w+1).times{|x|g[y]<<[x==w ? 0 : 1,y==h ? 0 : 1]}}
# Opening for the start and end & set the end cell
g[h][w-1][0]=g[0][0][0]=0;c=[w-1,h-1]
# Where the magic happens
def t(c,v,w,h,g)
# add cell to visited & get list of neighbors
@supercleanse
supercleanse / wp_full_page_modification.php
Created July 13, 2012 17:02
Full page modification in WordPress
<?php
add_action('init', 'fpm_start_output');
add_action('shutdown', 'fpm_end_output');
function fpm_start_output() {
ob_start('fpm_mod_buffer');
}
function fpm_mod_buffer($buffer) {
// Modification ... regexp, etc
@supercleanse
supercleanse / mepr_lifetime_trial.php
Last active December 11, 2015 16:49
This should work ... just make sure you change the id on line 18 to go along with the products you want to be setup as your lifetime + trials
<?php
/*
Plugin Name: MemberPress Lifetime Trial
Plugin URI: http://memberpress.com
Description: Creates a lifetime subscription from a 1 year subscription + a *free* trial. This basically cancels the subscription after the first real payment
Version: 1.0.0
Author: Caseproof, LLC
Author URI: http://caseproof.com
Text Domain: memberpress
Copyright: 2004-2013, Caseproof, LLC
<?php
// TRIM PARAMS FROM REQUEST_URI
$request_uri = preg_replace('#\?.*#','',$_SERVER['REQUEST_URI']);
preg_match('#^https?://[^/]+(/.*)?#', home_url(), $matches);
$pre_slug = isset($matches[1])?$matches[1]:'';
if( !empty($plugin) and $plugin == 'wafp' and
!empty($controller) and !empty($action) )
{
self::standalone_route($controller, $action);
@supercleanse
supercleanse / custom_signup.php
Created February 5, 2013 05:23
Shows how to add custom variables to a memberpress signup form.
<?php
/*
Plugin Name: MemberPress Custom Membership Signup
Plugin URI: http://memberpress.com
Description: Adds some custom fields to the MemberPress signup process
Version: 1.0.0
Author: MemberPress
Author URI: http://memberpress.com
Text Domain: memberpress
*/
@supercleanse
supercleanse / WafpDigLabsStripePaymentsController.php
Created February 7, 2013 07:04
This is the Affiliate Royale integration for DigLabs Stripe Payment plugin for WordPress ...
<?php
if(!defined('ABSPATH')) {die('You are not allowed to call this page directly.');}
/** This is a controller that handles all of the DigLabs Stripe Payment
* specific public static functions for Affiliate Royale.
*/
class WafpDigLabsStripePaymentsController {
public static function load_hooks() {
if(function_exists( 'stripe_register_payment_end_callback' ))
@supercleanse
supercleanse / stripe_outright.rb
Last active December 16, 2015 12:49
Sinatra script to output Stripe income and expenses as Outright CSV files...
# Requires the HTTParty, Stripe & Sinatra gems
require 'httparty'
require 'stripe'
require 'time'
require 'csv'
require 'sinatra'
# NOTE: This script also requires tht you set a ENV['LIVE_STRIPE_SECRET']
# environment variable with your Live Secret Key from your Stripe Dashboard