Skip to content

Instantly share code, notes, and snippets.

@mindctrl
mindctrl / edd-sort-category-archives-randomly.php
Created September 28, 2015 22:02
Easy Digital Downloads - Sort category archives randomly
<?php
/*
Plugin Name: Easy Digital Downloads - Sort category archives by random order
*/
function jp_sort_edd_category_archives( $query ) {
if ( is_tax( 'download_category' ) && $query->is_main_query() ) {
$query->set( 'orderby', 'rand' );
}
}
add_action( 'pre_get_posts', 'jp_sort_edd_category_archives' );
@mindctrl
mindctrl / edd-zero-decimal-currency.php
Created September 15, 2015 15:12
Easy Digital Downloads - Set the number of decimals to zero for certain currencies
function jp_no_krw_decimal( $decimals, $currency ) {
if ( 'KRW' == $currency ) { // Korean Won. Set to your currency code.
return 0;
}
return $decimals;
}
add_filter( 'edd_currency_decimal_count', 'jp_no_krw_decimal', 10, 2 );
INITIALISATION
==============
load wp-config.php
set up default constants
load wp-content/advanced-cache.php if it exists
load wp-content/db.php if it exists
connect to mysql, select db
load object cache (object-cache.php if it exists, or wp-include/cache.php if not)
load wp-content/sunrise.php if it exists (multisite only)
@mindctrl
mindctrl / fes-set-audio-post-format.php
Last active October 17, 2017 20:47
Easy Digital Downloads - Frontend Submissions: Automatically set post format to audio/video/gallery
<?php
// Sets the post format to audio on product submissions made in Frontend Submissions.
function jp_set_audio_post_format( $post_id ) {
set_post_format( $post_id, 'audio' );
}
add_action( 'fes_submit_submission_form_bottom', 'jp_set_audio_post_format' );
@mindctrl
mindctrl / edd-no-email-free-purchases.php
Created June 22, 2015 15:41
Easy Digital Downloads - Disable email notifications on $0 purchases
function jp_no_email_free( $payment_id ) {
$amount = edd_get_payment_amount( $payment_id );
if ( 0 == $amount ) {
remove_action( 'edd_complete_purchase', 'edd_trigger_purchase_receipt', 999, 1 ); // This disables customer purchase receipts
remove_action( 'edd_admin_sale_notice', 'edd_admin_email_notice', 10, 2 ); // This disables email notices to admins
}
}
add_action( 'edd_complete_purchase', 'jp_no_email_free', 998, 1 );
@mindctrl
mindctrl / digital-store-storefront-content.php
Created May 27, 2015 17:37
Easy Digital Downloads - Digital Store theme - Make storefront template display page content.
<?php
/**
* Plugin Name: Digital Store - Add content to storefront template.
*/
function jp_inject_the_content() {
remove_action( 'digitalstore_store_front', 'digitalstore_front_latest_downloads', 2 );
add_action( 'digitalstore_store_front', 'digitalstore_front_latest_downloads', 3 );
add_action( 'digitalstore_store_front', 'jp_add_content', 2 );
}
add_action( 'init', 'jp_inject_the_content' );
@mindctrl
mindctrl / edd-remove-billing-details.php
Created May 13, 2015 13:30
Easy Digital Downloads - Remove billing details section on the checkout screen.
/**
* Removes the billing details section on the checkout screen.
*/
function jp_disable_billing_details() {
remove_action( 'edd_after_cc_fields', 'edd_default_cc_address_fields' );
}
add_action( 'init', 'jp_disable_billing_details' );
@mindctrl
mindctrl / edd-product-titles-link.php
Created May 5, 2015 14:54
Easy Digital Downloads - Make product title links open in a new tab when on the checkout page. Useful for Cross-sells & Upsells plugin and other plugins that display product links in the checkout screen using the shortcode template files.
@mindctrl
mindctrl / edd-move-purchase-button.php
Created April 30, 2015 16:43
Easy Digital Downloads - Move purchase button above download content
<?php
function jp_move_purchase_button() {
remove_action( 'edd_after_download_content', 'edd_append_purchase_link' );
add_action( 'edd_before_download_content', 'edd_append_purchase_link' );
}
add_action( 'template_redirect', 'jp_move_purchase_button' );
@mindctrl
mindctrl / edd-purchase-button.php
Created April 30, 2015 15:42
Adds a padlock icon to the purchase button value in Easy Digital Downloads. Requires style changes to make the lock appear to be inside the button.
<?php
function jp_padlock_purchase_button( $content ) {
$color = edd_get_option( 'checkout_color', 'blue' );
$color = ( $color == 'inherit' ) ? '' : $color;
$style = edd_get_option( 'button_style', 'button' );
$label = edd_get_option( 'checkout_label', '' );
if ( edd_get_cart_total() ) {
$complete_purchase = ! empty( $label ) ? $label : __( 'Purchase', 'edd' );