Skip to content

Instantly share code, notes, and snippets.

View mindctrl's full-sized avatar

John Parris mindctrl

View GitHub Profile
<?php
/**
* Plugin Name: Easy Digital Downloads - Change Purchase Receipt Heading
* Description: Changes the Default Template purchase receipt heading from "Purchase Receipt" to "Download Confirmation".
*/
function jp_filter_email_heading( $headers, $payment_id, $payment_data ) {
EDD()->emails->__set( 'heading', 'Download Confirmation' );
return $headers;
}
@mindctrl
mindctrl / gist:29b31d5c594b2c081d69
Created February 16, 2015 18:11
A [purchase_history_login] shortcode for Easy Digital Downloads that displays purchase history when the user is logged in and a login form when the user is not logged in.
<?php
function jp_edd_purchase_history_login( $atts, $content = null ) {
if ( is_user_logged_in() ) {
ob_start();
edd_get_template_part( 'history', 'purchases' );
return ob_get_clean();
} else {
extract( shortcode_atts( array(
@mindctrl
mindctrl / gist:a7eda7c5f0b09adebf0a
Created February 18, 2015 16:21
Change logged out text on the EDD Reviews plugin
<?php
// Use this one to change the text and keep the 'download' label
function jp_change_reviews_text() {
return sprintf( 'You must buy this %s to leave a review.', strtolower( edd_get_label_singular() ) );
}
add_filter( 'edd_reviews_user_logged_out_message', 'jp_change_reviews_text' );
@mindctrl
mindctrl / gist:d4ae2b7ed87c07f0dddd
Created February 20, 2015 05:04
EDD Frontend Submissions - Remove "The Shop of Vendor" text from the vendor archive page title.
<?php
/**
* Easy Digital Downloads - Frontend Submissions
* Removes "The Shop of Vendor" text from the vendor archive page title.
*/
function jp_change_fes_shop_title( $title, $vendor ) {
$store_name = EDD_FES()->helper->get_user_meta( 'name_of_store', $vendor );
if( empty( $store_name ) ) {
@mindctrl
mindctrl / gist:6c267b54970ee3ab69d5
Created March 4, 2015 19:08
Easy Digital Downloads - Frontend Submissions: Display vendor website address in the sidebar using the Marketify theme
<?php
function jp_custom_profile_information( $author ) {
$website = get_user_meta( $author->ID, 'user_url', true );
if( ! empty( $website ) ) {
echo '<p class="vendor-url"><a href="' . $website . '">Website</a></p>';
}
}
add_action( 'marketify_vendor_profile_after_social', 'jp_custom_profile_information' );
@mindctrl
mindctrl / gist:a23c0e2b6f4f01a61ed9
Created March 17, 2015 16:10
Removes the featured image from single download pages in the Shop Front theme for Easy Digital Downloads.
<?php
/*
Plugin Name: Easy Digital Downloads - Shop Front Theme: Remove featured image from single download pages.
*/
function jp_remove_featured_image_single() {
if( is_singular( 'download' ) && has_post_thumbnail() ) {
remove_action( 'shopfront_single_download_image', 'shopfront_single_download_image' );
}
}
add_action( 'template_redirect', 'jp_remove_featured_image_single' );
@mindctrl
mindctrl / checkout-add-to-download-sidebar.php
Created April 17, 2015 15:49
Checkout WordPress Theme - Add a contact form, or other shortcode output, below the download sidebar
<?php
/*
Plugin Name: Checkout - Add Contact Form to download sidebar
*/
function jp_add_to_sidebar() {
echo do_shortcode( '[contact-form-7 id="15" title="Contact form 1"]' );
}
add_action( 'checkout_below_purchase_sidebar', 'jp_add_to_sidebar' );
@mindctrl
mindctrl / edd-sort-archive-by-sales.php
Last active June 24, 2017 13:55
Sort the downloads archive in Easy Digital Downloads by number of sales
<?php
/*
Plugin Name: Easy Digital Downloads - Sort archive by number of sales
*/
function jp_sort_downloads_archive( $query ) {
if ( is_post_type_archive( 'download' ) && $query->is_main_query() ) {
$query->set( 'meta_key', '_edd_download_sales' );
$query->set( 'orderby', 'meta_value_num' );
$query->set( 'order', 'DESC' );
}
@mindctrl
mindctrl / edd-purchase-button-padlock.php
Last active August 29, 2015 14:20
Adds a padlock icon to the purchase button value in Easy Digital Downloads. Note this requires you set the font-family to FontAwesome for #edd-purchase-button
<?php
function jp_padlock_purchase_button( $content ) {
return str_replace( 'Purchase', '&#xf023; Purchase', $content );
}
add_filter( 'edd_checkout_button_purchase', 'jp_padlock_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' );