Skip to content

Instantly share code, notes, and snippets.

@amdrew
amdrew / gist:e0437f3df26cc1f54f5c
Created December 6, 2014 04:46
Easy Digital Downloads - show dimensions of image
<?php
function sumobi_edd_get_download_file_dimensions() {
$download_files = edd_get_download_files( get_the_ID() );
if ( $download_files ) {
foreach ( $download_files as $file ) {
$attachment_id = $file['attachment_id'];
@amdrew
amdrew / gist:f402f6df0c5d77b06eb1
Created December 4, 2014 23:19
EDD Purchase Limits - Automatically set all purchase limits to 1
<?php
function sumobi_edd_set_purchase_limit( $ret, $download_id ) {
return 1;
}
add_filter( 'edd_file_purchase_limit', 'sumobi_edd_set_purchase_limit', 10, 2 );
@amdrew
amdrew / gist:e5761f53814feed8fee8
Last active August 29, 2015 14:10
WooCommerce - Add a "prevent purchase" checkbox to product meta and when checked disallows the product from being purchased and removes add to cart buttons
<?php
/**
* Prevent product from being purchased/added to cart, eg with ?add-to-cart=5735 or otherwise
*/
function sumobi_wc_prevent_purchase_validation( $passed, $product_id ) {
$prevent_purchase = get_post_meta( $product_id, '_wc_prevent_purchase', true );
if ( $prevent_purchase ) {
@amdrew
amdrew / gist:2ae8420de8b6ca28bf6a
Created December 3, 2014 21:38
AffiliateWP - Change the emails from plain text to HTML, filter the application accepted email
<?php
/**
* Change the email content types to HTML
*/
function affwp_custom_email_headers( $headers ) {
$headers[] = "Content-type: text/html";
return $headers;
}
@amdrew
amdrew / gist:c149510eef862f822b1f
Created December 3, 2014 09:10
AffiliateWP + WooCommerce - Alter the product commission depending on which category it's assigned to
<?php
/**
* Change the commission amount if products belong to certain categories
*
*/
function affwp_custom_wc_commission_per_category( $referral_amount, $affiliate_id, $amount, $reference, $product_id ) {
// You can specify an array of categories to alter the commission for. Separate by a comma and use either the term name, term_id, or slug
$categories = array( 'category-one', 5 );
@amdrew
amdrew / gist:7dff6aa4325401780f05
Last active August 29, 2015 14:10
Easy Digital Downloads - Add an "IP Address" column to the exported .csv file at Downloads -> Reports -> Export -> Export Payment History
<?php
/**
* Add a new column for the customer's IP Address
*/
function sumobi_edd_export_payments_csv_cols( $cols ) {
$cols['ip_address'] = 'IP Address';
return $cols;
}
<?php
/*
Plugin Name: Easy Digital Downloads - Downloads Email Tag
Plugin URI: http://sumobi.com/
Description: Adds a {downloads} email tag for use in email templates that outputs a simple list of linked downloads without file names
Version: 1.0
Author: Andrew Munro, Sumobi
Author URI: http://sumobi.com/
License: GPL-2.0+
License URI: http://www.opensource.org/licenses/gpl-license.php
@amdrew
amdrew / gist:9f79c4d09a48dd1c945a
Created November 24, 2014 19:45
Easy Digital Downloads + EDD Social Discounts. Remove sharing buttons for free downloads
<?php
/**
* EDD Social Discounts - remove sharing buttons for free downloads
*/
function sumobi_edd_social_discount_display_share_buttons() {
if ( edd_is_free_download( get_the_ID() ) ) {
return;
}
@amdrew
amdrew / gist:cc3c3713165feec5aa91
Created November 20, 2014 21:29
AffiliateWP - Edit the application accepted email
<?php
/**
* Edit the application accepted email
*/
function affwp_custom_application_accepted_email( $message, $args ) {
$message = sprintf( __( "Congratulations %s!\n\n", "affiliate-wp" ), affiliate_wp()->affiliates->get_affiliate_name( $args['affiliate_id'] ) );
$message .= sprintf( __( "Your affiliate application on %s has been accepted!\n\n", "affiliate-wp" ), home_url() );
$message .= sprintf( __( "Log into your affiliate area at %s\n\n", "affiliate-wp" ), get_permalink( affiliate_wp()->settings->get( 'affiliates_page' ) ) );
@amdrew
amdrew / gist:978267209a8cd0d4d3cd
Created November 16, 2014 23:48
AffiliateWP - disable affiliate to affiliate referrals
<?php
function affwp_custom_disable_affiliate_to_affiliate_referrals( $referral_amount, $affiliate_id, $amount, $reference, $product_id ) {
// affwp_is_affiliate() will check if the currently logged in user is an affilaite.
// if they are an affiliate, set the referral amount to 0.00
if ( affwp_is_affiliate() ) {
$referral_amount = 0.00;
}