Skip to content

Instantly share code, notes, and snippets.

View DevinWalker's full-sized avatar
🌱
Coding for good

Devin Walker DevinWalker

🌱
Coding for good
View GitHub Profile

Simple Optin form example for WordPress

This is a simplified showcase of how you can easily build your own Optin form in WordPress.

It can connect to any API that supports cURL (most of them do). There is no error reporting implemented. It uses exit intent detection script called Ouibounce, which needs to be enqueued in your functions.php

@DevinWalker
DevinWalker / cmb2-address.php
Created July 29, 2015 22:15
Plugin demonstrating CMB2 address field as repeatable
<?php
/*
* Plugin Name: CMB2 Custom Field Type - Address
* Description: Makes available an 'address' CMB2 Custom Field Type. Based on https://github.com/WebDevStudios/CMB2/wiki/Adding-your-own-field-types#example-4-multiple-inputs-one-field-lets-create-an-address-field
* Author: jtsternberg
* Author URI: http://dsgnwrks.pro
* Version: 0.1.0
*/
/**
@DevinWalker
DevinWalker / give-is-user-recent-donor
Created September 21, 2015 19:31
Determine if a user is a recent donor (last 30 days) with this conditional check.
<?php
/**
* Is User Recent Donor (Rename/Prefix)
*
* @description: Display Donors from Last 30 Days
*
* @return bool
*/
function my_give_is_user_recent_donor() {
@DevinWalker
DevinWalker / Beanstalk_to_GitHub
Created October 9, 2015 17:19
Move Git Repository from Beanstalk to GitHub with full repository history
#Example moving the DPSG Global Library
# 1 Checkout the Beanstalk Repo
git clone --bare git@codeandtheory.beanstalkapp.com:/dpsg-global-library.git
# 2 Push into your desired GitHub repo. (Please note that you must create the github repo prior to this step)
git push --mirror git@github.com:codeandtheory/dpsg-global-library.git
@DevinWalker
DevinWalker / give-addon-banner-activation.php
Last active October 10, 2015 03:05
To use the banner class built into Give's core use the following
<?php
/**
* Give NAME OF ADD-ON Activation Banner
*
* @description: Includes and initializes the activation banner class; only runs in WP admin
* @hook admin_init
*/
function give_myaddon_activation_banner() {
if ( ! class_exists( 'Give_Addon_Activation_Banner' ) && file_exists( GIVE_PLUGIN_DIR . 'includes/admin/class-addon-activation-banner.php' ) ) {
@DevinWalker
DevinWalker / custom-donation-total-label.php
Last active December 23, 2016 20:36
Customized the Give donation total label globally
/**
* Give Custom Donation Total Label
*
* @return string|void
*/
function my123_custom_donation_total_label(){
return __('My Custom Label', 'my_textdomain');
}
@DevinWalker
DevinWalker / give-recurring-dummy-subscriptions.php
Last active December 9, 2015 01:10
This will add child subscription payments to a given subscription
<?php
/**
* Create Recurring Dummy Subscriptions
*/
$subscription = new Give_Subscription( 68 );
$args = array(
'subscription_id' => 68,
'amount' => 20,
'transaction_id' => md5(uniqid(rand(), true)),
/**
* Give function to reorder array keys
* @see: http://php.net/manual/en/function.ksort.php
* reorder the keys of an array in order of specified keynames; all other nodes not in $keynames will come after last $keyname, in normal array order
* @param array &$array - the array to reorder
* @param mixed $keynames - a csv or array of keynames, in the order that keys should be reordered
*/
function give_9812491_my_array_reorder_keys(&$array, $keynames){
if(empty($array) || !is_array($array) || empty($keynames)) return;
if(!is_array($keynames)) $keynames = explode(',',$keynames);
@DevinWalker
DevinWalker / give-literal-gateway-labels.php
Created January 14, 2016 02:18
Call the Gateway by it's name; primarily used for testing purposes
/**
* Call Give Payment Gateways by Name
*
* @param $gateways
*
* @return mixed
*/
function gr_override_gateway_labels( $gateways ) {
$gateways['authorize']['checkout_label'] = 'Authorize';
$gateways['stripe']['checkout_label'] = 'Stripe';
/* Basic form style cleanup */
ul#give-donation-level-radio-list {
list-style: none;
padding: 0;
}
ul#give-donation-level-radio-list input {
margin: 0 5px 0 3px;
}