Skip to content

Instantly share code, notes, and snippets.

View pippinsplugins's full-sized avatar

Pippin Williamson pippinsplugins

View GitHub Profile
@pippinsplugins
pippinsplugins / gist:9557012
Created March 14, 2014 21:10
Send an email anytime a payment is recurring through EDD Recurring Payments
<?php
function pw_edd_recurring_payment_received_notice( $payment, $parent_id, $amount, $txn_id, $unique_key ) {
$user_id = edd_get_payment_user_id( $parent_id );
$email = edd_get_payment_user_email( $parent_id );
$user_data = get_userdata( $user_id );
$subject = 'Payment Received';
$message = "Hello $usera_data->display_name, your payment for $amount has been received. Thanks!";
<?php
function pw_edd_send_email_on_pending( $payment_id, $payment_data ) {
// grab the gateway so we can only send on email for specific gateways
$gateway = isset( $_POST['edd-gateway'] ) ? $_POST['edd-gateway'] : '';
// TODO: replace "bacs" with your gateway ID
if( $gateway != 'bacs' )
return;
@pippinsplugins
pippinsplugins / edd-slack-slash-command.php
Last active July 11, 2021 18:17 — forked from jameslaws/edd-slack-slash-command.php
A Slash command to retrieve earnings in Restrict Content Pro for the specified time period. Based on http://wpninjas.com/using-slack-slash-commands-to-get-edd-sales-info/
<?php
function pw_rcp_earnings_slash_command() {
# Check to make sure this is a Slash Command Request
if ( ! isset( $_REQUEST['slack_slash'] ) && 'your_custom_string' != $_REQUEST['slack_slash'] )
return false;
# Check to see if a token has been passed as well
if ( ! isset( $_REQUEST['token'] ) )
@pippinsplugins
pippinsplugins / edd_grid.php
Last active April 24, 2020 17:48
sample Easy Digital Downloads Product Grid with Pagination
<?php get_header(); ?>
<div id="main-content" class="row store-template">
<div class="content clearfix">
<?php
$current_page = get_query_var('paged');
$per_page = get_option('posts_per_page');
$offset = $current_page > 0 ? $per_page * ($current_page-1) : 0;
$product_args = array(
'post_type' => 'download',
<?php
/**
* Plugin Name: EDD Heartbeat API test plugin
* Description: Demonstrates how to use the Heartbeat API to update the payments count on the dashboard
*/
// Load the heartbeat JS
function edd_heartbeat_enqueue( $hook_suffix ) {
// Make sure the JS part of the Heartbeat API is loaded.
wp_enqueue_script( 'heartbeat' );
<?php
function get_the_user_ip() {
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
//check ip from share internet
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
//to check ip is pass from proxy
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
@pippinsplugins
pippinsplugins / edd-commission-update.php
Created July 21, 2015 00:34
Bulk set EDD Commissions to "unpaid" for all commissions after a specific date
<?php
$commissions = get_posts( array(
'post_type' => 'edd_commission',
'posts_per_page' => -1,
'fields' => 'ids',
'date_query' => array(
'after' => array(
'year' => 2015,
'month' => 03,
'day' => 15
@pippinsplugins
pippinsplugins / Warn when saving any EDD payment
Last active April 25, 2019 18:23 — forked from mintplugins/Warn when saving any EDD payment
Just a quick sample to demonstrate how you could approach asking "Are you sure" when saving a payment
function custom_prefix_warn_about_old_refunds_js() {
if ( ! isset( $_GET['prevent_accidental_refunds_js'] ) ) {
return false;
}
header('Content-Type: application/javascript');
?>
@pippinsplugins
pippinsplugins / EDD Add to Cart Checkout
Created September 8, 2012 02:46 — forked from bryceadams/EDD Add to Cart + Checkout
Easy Digital Downloads - Add to Cart and redirect to Checkout Page
<a href="<?php echo add_query_arg( array( 'edd_action' => 'add_to_cart', 'download_id' => get_the_ID() ), edd_get_checkout_uri() ); ?>">Add to Cart</a>
@pippinsplugins
pippinsplugins / gist:3c1fe20e6abb04a2e85d
Created October 10, 2014 17:54
Make the first name not required during EDD checkout
<?php
function pw_edd_purchase_form_required_fields( $required_fields ) {
unset( $required_fields['edd_first'] );
return $required_fields;
}
add_filter( 'edd_purchase_form_required_fields', 'pw_edd_purchase_form_required_fields' );