Skip to content

Instantly share code, notes, and snippets.

@amdrew
amdrew / gist:8037145
Last active December 31, 2015 19:59
Output a list of EDD's terms (with links) from the 'download_category' taxonomy
<?php
/**
* Output a list of EDD's terms (with links) from the 'download_category' taxonomy
*/
function sumobi_list_edd_terms() {
$taxonomy = 'download_category'; // EDD's taxonomy for categories
$terms = get_terms( $taxonomy ); // get the terms from EDD's download_category taxonomy
?>
<ul class="download-categories">
<?php foreach ( $terms as $term ) : ?>
@amdrew
amdrew / gist:8078696
Last active January 1, 2016 02:19
Allows you to append a string to the sharing URL for all social networks so you can track purchases better, Requires EDD Social Discounts v2.0.1 or newer. https://easydigitaldownloads.com/extensions/edd-social-discounts/
<?php
function sumobi_edd_social_discounts_share_url( $url ) {
// append to URL
$url .= '?source=social_share';
return $url;
}
add_filter( 'edd_social_discounts_share_url', 'sumobi_edd_social_discounts_share_url' );
@amdrew
amdrew / gist:8078887
Last active January 1, 2016 02:19
Filters the sharing success message to include a purchase link. This is so the customer can add the product to the cart and proceed directly to checkout after sharing.Requires EDD Social Discounts v2.0.1 or newer. https://easydigitaldownloads.com/extensions/edd-social-discounts/
<?php
function sumobi_edd_sd_success_message( $message, $product_id ) {
// if there's a $product_id passed in from ajax use that, otherwise set to post ID of page
$product_id = $product_id ? $product_id : get_the_ID();
// return if the ID is not a 'download'
if ( 'download' != get_post_type( $product_id ) )
return $message;
@amdrew
amdrew / gist:8090796
Last active January 1, 2016 04:19
EDD Social Discounts - If you add the shortcode to your purchase confirmation page, and only 1 product is purchased, it will share the URL to that product in each of the social networks.
<?php
function sumobi_social_discounts_purchase_confirmation_url( $url ) {
global $edd_options;
// make sure we are on the EDD Purchase Confirmation page, else return
if ( ! ( isset( $edd_options['success_page'] ) && is_page( $edd_options['success_page'] ) ) )
return;
// get the purchase session
@amdrew
amdrew / gist:8264128
Last active January 2, 2016 06:29
Filter the default button text in Easy Digital Downloads
<?php
function sumobi_purchase_link_text( $defaults ) {
// add conditionals here
// change text, depending on conditionals
$defaults['text'] = 'The new button text';
return $defaults;
}
@amdrew
amdrew / gist:8324352
Created January 8, 2014 20:48
Change the number of downloads that show on a category page. For Easy Digital Downloads
<?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 ); // change this number
@amdrew
amdrew / gist:8447714
Last active January 3, 2016 10:09
Call this function on the single product page with <?php echo sumobi_custom_show_average_star_rating(); ?>
<?php
function sumobi_custom_show_average_star_rating() {
// make sure edd reviews is active
if ( ! function_exists( 'edd_reviews' ) )
return;
$edd_reviews = edd_reviews();
// get the average rating for this download
$average_rating = (int) $edd_reviews->average_rating( false );
@amdrew
amdrew / gist:8468347
Last active January 3, 2016 13:19
Order downloads alphabetically on category pages in Easy Digital Downloads
<?php
function sumobi_edd_order_category_downloads( $query ) {
if ( is_admin() || ! $query->is_main_query() )
return;
if( $query->is_tax( 'download_category' ) ) {
$query->set( 'orderby', 'title' );
$query->set( 'order', 'ASC' );
}
@amdrew
amdrew / gist:8486389
Created January 18, 2014 04:49
Move the user fields in Easy Digital Downloads to after the register fields
<?php
// remove/unhook the user info fields
remove_action( 'edd_register_fields_before', 'edd_user_info_fields' );
// add/rehook the user info fields to after the register fields
add_action( 'edd_register_fields_after', 'edd_user_info_fields' );
@amdrew
amdrew / gist:8501816
Last active January 3, 2016 18:19
Filter EDD Hide Download's redirect when "Disable direct access to this download" is enabled, on a per download level
<?php
function sumobi_custom_edd_hide_download_redirect( $url ) {
// download has ID of 17
if ( '17' == get_the_ID() ) {
$url = 'http://easydigitaldownloads.com'; // redirect user to another external URL
}
// download has ID of 15
if( '15' == get_the_ID() ) {