Skip to content

Instantly share code, notes, and snippets.

View SeanChDavis's full-sized avatar
👋
Reach out.

Sean Christopher Davis SeanChDavis

👋
Reach out.
View GitHub Profile
@SeanChDavis
SeanChDavis / sample.php
Created November 7, 2015 19:02
EDD restrict sales summary dashboard widget by (admin) user ID
<?php // DO NOT COPY THIS LINE
// remove sales summary widget
remove_action( 'wp_dashboard_setup', 'edd_register_dashboard_widgets', 10 );
// add sales summary widget with new conditions
function sd_edd_register_dashboard_widgets() {
$no_access = array( 3, 20 ); // comma separated list of user IDs to restrict
$user_id = get_current_user_id();
@SeanChDavis
SeanChDavis / review-email-notice.php
Created October 25, 2015 19:43
EDD Reviews Email Address Notice
<?php // DO NOT COPY THIS LINE
function sd_reviews_form_message( $message ) {
$note = '<p><em>Your email address will not be displayed publicly.</em></p>';
$message = $note . $message;
return $message;
}
add_filter( 'edd_reviews_review_form_template', 'sd_reviews_form_message' );
@SeanChDavis
SeanChDavis / testing-plugin.php
Last active October 23, 2015 07:41
Testing Plugin
<?php
/*
Plugin Name: Easy Digital Downloads - Testing
Plugin URL: #
Description: Testing custom EDD code from a plugin
Version: 1.0
Author: Sean Davis
Author URI:
*/
@SeanChDavis
SeanChDavis / sl-key.php
Created October 15, 2015 20:05
EDD SL License Key Structure
<?php // DO NOT COPY THIS LINE
// SL license key structure based on username, time purchased, md5
function sd_edd_license_usernam_date_md5( $key, $license_id, $download_id, $payment_id, $cart_index ) {
$name = get_user_by( 'email', edd_get_payment_user_email( $payment_id ) );
$date = get_post_field( 'post_date', $payment_id );
$timestamp = strtotime($date);
$nice_date = date( 'Yndhis', $timestamp );
$license = md5( $license_id );
@SeanChDavis
SeanChDavis / required-address-fields.php
Created October 14, 2015 07:03
EDD Required Address Fields
<?php // do not copy this line
/**
* Make address fields required
*/
function sd_edd_required_address_fields( $required_fields ) {
$required_fields['card_address'] = array(
'error_id' => 'invalid_address',
'error_message' => 'Please enter your full address'
);
@SeanChDavis
SeanChDavis / edd-email-receipt.php
Created October 13, 2015 18:08
EDD Email Receipt Remove HTML small Tags
<?php // DO NOT COPY THIS LINE
function sd_remove_small_tag_email_receipt( $message ) {
$small = array( '<small>', '</small>' );
$message = str_replace( $small, '', $message );
return $message;
}
add_filter( 'edd_email_message', 'sd_remove_small_tag_email_receipt' );
@SeanChDavis
SeanChDavis / edd-archive-order.php
Created October 9, 2015 07:01
EDD Order Download Archive by ASC Title
<?php // DO NOT COPY THIS LINE
function sd_edd_order_category_downloads( $query ) {
if ( is_admin() || ! $query->is_main_query() )
return;
if( $query->is_post_type_archive( 'download' ) ) {
$query->set( 'orderby', 'title' );
$query->set( 'order', 'ASC' );
}
return;
@SeanChDavis
SeanChDavis / free-downloads-note.php
Created October 9, 2015 05:34
EDD Free Downloads Add Text w/ JS
<?php // DO NOT COPY THIS LINE
function sd_add_text_above_free_downloads_form() {
?>
<script type="text/javascript">
jQuery(document).ready(function($){
$( '#edd_free_download_form' ).before( '<p class="free-download-note">Your Text Here</p>' );
});
</script>
<?php
@SeanChDavis
SeanChDavis / fes.php
Created September 23, 2015 03:44
EDD FES Use Vendor Display Name As Store Name
<?php // DO NOT COPY THIS LINE
/**
* User vendor's display name for store name if unedited
*/
function sd_fes_store_name_username() {
if ( class_exists( 'EDD_Front_End_Submissions' ) ) {
$the_vendor = wp_get_current_user();
$vendor_name = get_user_meta( $the_vendor->ID, 'display_name', true );
$vendor_store_name = get_user_meta( $the_vendor->ID, 'name_of_store', true );
@SeanChDavis
SeanChDavis / custom-payment-status.php
Last active September 17, 2015 02:48
EDD Add Custom Payment Statuses
<?php // DO NOT COPY THIS LINE
// add custom payment statuses
function sd_extra_payment_statuses( $statuses ) {
$statuses = array(
'pending' => __( 'Pending', 'edd' ),
'publish' => __( 'Complete', 'edd' ),
'refunded' => __( 'Refunded', 'edd' ),
'failed' => __( 'Failed', 'edd' ),
'abandoned' => __( 'Abandoned', 'edd' ),