Skip to content

Instantly share code, notes, and snippets.

Avatar

Pippin Williamson pippinsplugins

View GitHub Profile
@pippinsplugins
pippinsplugins / Warn when saving any EDD payment
Last active Apr 25, 2019 — 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
View Warn when saving any EDD payment
function custom_prefix_warn_about_old_refunds_js() {
if ( ! isset( $_GET['prevent_accidental_refunds_js'] ) ) {
return false;
}
header('Content-Type: application/javascript');
?>
View how.php
<?php
add_filter( 'mailchimp_sync_subscriber_data', function( MC4WP_MailChimp_Subscriber $subscriber, $user ) {
$affiliate = affiliate_wp()->affiliates->get_by( 'user_id', $user->ID );
if( ! empty( $affiliate ) ) {
$subscriber->merge_fields['MERGE6'] = $affiliate->affiliate_id;
}
return $subscriber;
}, 10, 2 );
@pippinsplugins
pippinsplugins / edd-slack-slash-command.php
Last active Oct 14, 2018 — 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/
View edd-slack-slash-command.php
<?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'] ) )
View functions.php
<?php
function change_author_capabilities() {
$role = get_role( 'shop_vendor' ) ;
$role->add_cap( 'delete_products' );
}
add_action( 'admin_init', 'change_author_capabilities' );
View gist:9771238
<?php
/**
* Plugin Name: Update Previous Order Numbers for EDD
* Description: For users of the sequential order number beta, use this before you get new orders to have your previous orders sequentially numbered
* Version: 0.1
* Author: Chris Christoff
* Author URI: http://www.chriscct7.com
*/
function update_script_edd_seq_numbers(){
View gist:9197316
// make downloads hierarchical
function thesrpr_edd_make_hierarchical($download_args ) {
$download_args['hierarchical'] = true;
return $download_args;
}
add_filter( 'edd_download_post_type_args', 'thesrpr_edd_make_hierarchical' );
@pippinsplugins
pippinsplugins / gist:5788774
Last active Dec 18, 2015 — forked from markjaquith/gist:2653957
Modified version of Mark's class that includes a flush() member function.
View gist:5788774
<?php
/*
Usage:
$frag = new CWS_Fragment_Cache( 'unique-key', 3600 ); // Second param is TTL
if ( !$frag->output() ) { // NOTE, testing for a return of false
functions_that_do_stuff_live();
these_should_echo();
// IMPORTANT
$frag->store();
// YOU CANNOT FORGET THIS. If you do, the site will break.
@pippinsplugins
pippinsplugins / edd_get_purchase_id_by_key.php
Created Oct 27, 2012 — forked from jdevalk/edd_get_purchase_id_by_key.php
Retrieve the purchase ID based on the purchase key
View edd_get_purchase_id_by_key.php
<?php
/**
* Retrieve the purchase ID based on the purchase key
*
* @access public
* @since 1.2.3
*
* @param string $key the purchase key to search for
* @return int $order_id
*/
@pippinsplugins
pippinsplugins / class.php
Created Sep 27, 2012 — forked from fxbenard/class.php
How to make it i18n without error ?
View class.php
private $defaultCapabilities = array(
'connections_view_dashboard' => __('View Dashboard', 'your-domain'),
'connections_manage' => __('View List (Manage)', 'your-domain'),
'connections_add_entry' => __('Add Entry', 'your-domain'),
'connections_add_entry_moderated' => __('Add Entry Moderated', 'your-domain'),
'connections_edit_entry' => __('Edit Entry', 'your-domain'),
'connections_edit_entry_moderated' => __('Edit Entry Moderated', 'your-domain'),
'connections_delete_entry' => __('Delete Entry', 'your-domain'),
'connections_view_public' => __('View Public Entries', 'your-domain'),
'connections_view_private' => __('View Private Entries', 'your-domain'),
@pippinsplugins
pippinsplugins / EDD Add to Cart Checkout
Created Sep 8, 2012 — forked from bryceadams/EDD Add to Cart + Checkout
Easy Digital Downloads - Add to Cart and redirect to Checkout Page
View EDD Add to Cart Checkout
<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>
You can’t perform that action at this time.