Skip to content

Instantly share code, notes, and snippets.

View cklosowski's full-sized avatar

Chris Klosowski cklosowski

View GitHub Profile
@cklosowski
cklosowski / gist:8885994
Created February 8, 2014 16:09
Overview of error message improvements
<?php
// Example of adding an error to the edd_set_error
/**
* Checks whether a discount code is active.
*
* @since 1.0
* @param int $code_id
* @return bool
*/
function edd_is_discount_active( $code_id = null ) {
@cklosowski
cklosowski / gist:10011065
Created April 6, 2014 20:20
EDD - No Price on Free Download
<?php
add_filter( 'edd_purchase_link_defaults', 'ck_edd_edd_purchase_link_defaults', 10, 1 );
function ck_edd_edd_purchase_link_defaults( $args ) {
if ( edd_get_download_price( $args['download_id'] ) == '0.00' )
$args['price'] = false;
return $args;
}
@cklosowski
cklosowski / gist:10011096
Last active August 29, 2015 13:58
EDD - Remove Purchase Total
<?php
function ck_edd_hide_payment_icons() {
$cart_total = edd_get_cart_total();
if ( $cart_total )
return;
remove_action( 'edd_purchase_form_before_submit', 'edd_checkout_final_total', 999 );
// If you want to remove the payment options as well, you can uncomment these lines
@cklosowski
cklosowski / checkout_cart.php
Created April 18, 2014 05:14
EDD - Checkout Cart - If products are free, the price column states 'Complementary'. If the price of the cart is 0, it hides the cart total.
<?php global $post; ?>
<table id="edd_checkout_cart" <?php if ( edd_is_ajax_enabled() ) { echo 'class="ajaxed"'; } ?>>
<thead>
<tr class="edd_cart_header_row">
<?php do_action( 'edd_checkout_table_header_first' ); ?>
<th class="edd_cart_item_name"><?php _e( 'Item Name', 'edd' ); ?></th>
<th class="edd_cart_item_price"><?php _e( 'Item Price', 'edd' ); ?></th>
<th class="edd_cart_actions"><?php _e( 'Actions', 'edd' ); ?></th>
<?php do_action( 'edd_checkout_table_header_last' ); ?>
</tr>
<?php
/**
* Adds a 'Continue Shopping' button to the left of the Update and Save Cart Buttons on checkout
*/
add_action( 'edd_cart_footer_buttons', 'ck_edd_continue_shopping_button', 1 );
function ck_edd_continue_shopping_button() {
global $edd_options;
// Change the 'green' at the end to choose a different color that EDD supports
$color = isset( $edd_options[ 'checkout_color' ] ) ? $edd_options[ 'checkout_color' ] : 'green';
@cklosowski
cklosowski / ck-edd-author-support.php
Created June 20, 2014 04:27
Plugin file to add author support to EDD
<?php
/*
Plugin Name: EDD Author Support
Plugin URI: http://easydigitaldownloads.com
Description: Adds Author Support to the Downloads Post Type in EDD
Version: 1.0
Author: Chris Klosowski
Author URI: http://filament-studios.com
License: GPLv2
*/
@cklosowski
cklosowski / update-payment-test.php
Created October 7, 2014 04:23
Update Payment Test
<?php
public function test_update_payment_amount() {
$pre_update_total_earnings = get_option( 'edd_earnings_total' );
$pre_update_payment_amount = edd_sanitize_amount( edd_get_payment_amount( $this->_payment_id ) );
$payment_download = array(
'id' => $this->_post->ID,
'price_id' => '1',
'amount' => '100',
'quantity' => '1'
@cklosowski
cklosowski / edd-ck-commenter-has-purchased.php
Last active August 29, 2015 14:14
See if a commenter has purchased a given download ID
<?php
/*
* Plugin Name: Easy Digital Downloads - Commenter has purchased
* Description: Adds a 'Purchased' tag after a commenter who's purchased a download
* Author: Chris Klosowski
* Version: 1.0
*/
/**
* NOTE: This is currently not very performant. If an email address has a lot
#jetpack_summary_widget .hndle {
background: inherit !important;
color: inherit !important;
}
@cklosowski
cklosowski / getrepo
Created April 15, 2015 16:29
Quickly checkout a repo from the EDD Org
#!/usr/bin/env bash
if [ $# -lt 2 ]; then
echo "usage: $0 <plugin/theme> <repo-slug>"
exit 1
fi
TYPE=$1"s"
REPO=$2
echo "Changing Directory to:"