Skip to content

Instantly share code, notes, and snippets.

View pippinsplugins's full-sized avatar

Pippin Williamson pippinsplugins

View GitHub Profile
@pippinsplugins
pippinsplugins / gist:7118673
Created October 23, 2013 13:23
This is retrieving the number of items in the "edd_discount" post type that also have the meta key "_edd_tracking_log_id".
<?php
function pw_count_discount_codes_created() {
$args = array(
'post_type' => 'edd_discount',
'meta_key' => '_edd_tracking_log_id',
'nopaging' => true,
'fields' => 'ids',
'update_post_term_cache' => false,
'update_post_meta_cache' => false
);
@pippinsplugins
pippinsplugins / gist:6827946
Created October 4, 2013 15:37
Show a message to users that have purchased the currently viewed product in EDD.
<?php
/**
* Show Has Purchased Item Message
*
* Prints a notice when user has already purchased the item.
*
* @since 1.0
* @global $user_ID
* @param int $download_id Download ID
* @return void
@pippinsplugins
pippinsplugins / gist:6599135
Created September 17, 2013 19:03
Make EDD think every page is the checkout page. Useful for sites that load everything via ajax and make standard is_page() checks fail.
<?php
/*
* Plugin name: Force EDD Is Checkout
*/
add_filter( 'edd_is_checkout', '__return_true' );
<?php
function pw_edd_Custom_countries( $countries ) {
$countries = array(
'US' => 'United States',
'CA' => 'Canada'
);
}
add_filter( 'edd_countries', 'pw_edd_Custom_countries' );
@pippinsplugins
pippinsplugins / gist:6357212
Created August 27, 2013 18:29
Send the "active subscription welcome email when manually changing a user to active in RCP
<?php
function pw_rcp_email_status( $new_status, $user_id ) {
if( 'active' != $new_status )
return;
rcp_email_subscription_status( $user_id, 'active' );
}
add_action( 'rcp_set_status', 'pw_rcp_email_status', 10, 2 );
$('body').on( 'edd_discount_applied', function() {
alert( 'test' );
});
@pippinsplugins
pippinsplugins / gist:6300295
Created August 21, 2013 21:05
Modify the way event links are displayed on the calendar for Sugar Event Calendar
function pw_sc_event_link( $link, $id, $size ) {
if ( $size == 'small' ) {
$link = '<a href="'. get_permalink( $id ) .'" title="' . esc_html( get_the_title( $id ) ) . '">&bull;</a>';
} else {
$link = '<a href="'. get_permalink( $id ) .'">'. esc_html( get_the_title( $id ) ) .'</a><br/>';
}
return $link;
}
add_filter( 'sc_event_calendar_link', 'pw_sc_event_link' );
@pippinsplugins
pippinsplugins / gist:6295847
Created August 21, 2013 15:20
Illustrates how to modify EDD checkout fields
<?php
/*
* Plugin Name: Custom EDD Fields
*/
function pw_edd_remove_fields() {
// Call remove action on each of the sections you want to remove
// You can locate the exact action name by looking at includes/checkout/template.php
<?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' );
@pippinsplugins
pippinsplugins / get-gallery-image-urls.php
Created August 4, 2013 16:44
Get Gallery Image URLs plugin. Just a sample plugin illustrating how to retrieve all image URLs of gallery images in a post