Skip to content

Instantly share code, notes, and snippets.

@amdrew
amdrew / gist:7443009
Last active January 19, 2016 14:22
Add 'page-attributes' to the download post type in Easy Digital Downloads. This adds a "Sort By Order" to the download admin screen, where you can use drag and drop ordering with the Simple Page Ordering WordPress plugin.
<?php
function my_child_theme_edd_download_supports( $supports ) {
// add page-attributes
$add_support = array( 'page-attributes' );
// merge it back with the original array
return array_merge( $add_support, $supports );
}
add_filter( 'edd_download_supports', 'my_child_theme_edd_download_supports' );
@amdrew
amdrew / gist:7477544
Last active September 11, 2017 18:50
Allows you to search by the payment ID on the downloads > payment history screen. Also allows you to search on the downloads page if you know the ID.
<?php
function edd_search_by_id( $where ) {
if( is_admin() ) {
global $wpdb, $pagenow, $typenow;
if ( ! ( 'download' == $typenow && in_array( $pagenow, array( 'edit.php' ) ) ) )
return $where;
if ( isset( $_GET['s'] ) && !empty( $_GET['s'] ) && intval( $_GET['s'] ) != 0 ) {
@amdrew
amdrew / gist:7477894
Last active December 28, 2015 09:19
Add a new currency to Easy Digital Downloads
<?php
function my_child_theme_edd_add_currency( $currencies ) {
// change these values
$currencies['YNC'] = 'Your New Currency';
return $currencies;
}
add_filter( 'edd_currencies', 'my_child_theme_edd_add_currency' );
<?php
// set decimal places to 8
function my_child_theme_edd_format_amount_decimals( $decimal_places ) {
return 8;
}
add_filter( 'edd_format_amount_decimals', 'my_child_theme_edd_format_amount_decimals' );
// format final amount with (float)
function my_child_theme_edd_format_amount( $formatted, $amount, $decimals, $decimal_sep, $thousands_sep ) {
@amdrew
amdrew / gist:7557921
Last active December 28, 2015 20:29
Change the purchase button text and append the price in Easy Digital Downloads
<?php
function edd_custom_edd_checkout_button_purchase() {
global $edd_options;
$color = isset( $edd_options[ 'checkout_color' ] ) ? $edd_options[ 'checkout_color' ] : 'gray';
$color = ( $color == 'inherit' ) ? '' : $color;
$style = isset( $edd_options[ 'button_style' ] ) ? $edd_options[ 'button_style' ] : 'button';
@amdrew
amdrew / gist:7559698
Created November 20, 2013 08:28
Remove the "Get the EDD Sales / Earnings tracker for iOS" link from the payment history page in Easy Digital Downloads
<?php
remove_action( 'edd_payments_page_bottom', 'edd_payment_history_mobile_link' );
@amdrew
amdrew / gist:7610982
Created November 23, 2013 04:58
Remove the "shortcode" column from Easy Digital Download's "All Downloads" screen
<?php
function my_child_theme_remove_edd_shortcode_column( $download_columns ) {
unset( $download_columns['shortcode'] );
return $download_columns;
}
add_filter( 'edd_download_columns', 'my_child_theme_remove_edd_shortcode_column' );
@amdrew
amdrew / gist:7683426
Created November 27, 2013 21:21
Add a twitter share button to EDD's purchase confirmation page.
<?php
function edd_custom_success_page_share() {
global $edd_receipt_args, $edd_options;
$payment = get_post( $edd_receipt_args['id'] );
$meta = edd_get_payment_meta( $payment->ID );
$cart = edd_get_payment_meta_cart_details( $payment->ID, true );
$first_download = array_values( $cart );
$first_download = array_shift( $first_download );
@amdrew
amdrew / gist:7764705
Created December 3, 2013 06:21
Overwrite amount of downloads per category
<?php
function my_child_theme_filter_taxonomy( $query ) {
if ( is_admin() || ! $query->is_main_query() )
return;
if( $query->is_tax( 'download_category' ) ) {
$query->set( 'posts_per_page', 50 );
@amdrew
amdrew / gist:7817984
Created December 6, 2013 03:13
Remove "no downloadable files" on the purchase confirmation page when there are no files for a download
<?php
/**
* This template is used to display the purchase summary with [edd_receipt]
*/
global $edd_receipt_args, $edd_options;
$payment = get_post( $edd_receipt_args['id'] );
$meta = edd_get_payment_meta( $payment->ID );
$cart = edd_get_payment_meta_cart_details( $payment->ID, true );
$user = edd_get_payment_meta_user_info( $payment->ID );