Version Description
Download this release
Release Info
Developer | mordauk |
Plugin | Easy Digital Downloads |
Version | 2.6.14 |
Comparing to | |
See all releases |
Code changes from version 2.6.13 to 2.6.14
- assets/js/edd-checkout-global.js +13 -4
- assets/js/edd-checkout-global.min.js +1 -1
- easy-digital-downloads.php +19 -4
- includes/EDD_SL_Plugin_Updater.php +1 -1
- includes/admin/reporting/class-edd-graph.php +0 -1
- includes/admin/reporting/graphing.php +8 -5
- includes/admin/settings/register-settings.php +25 -25
- includes/admin/tracking.php +1 -1
- includes/cart/functions.php +4 -1
- includes/cart/template.php +2 -0
- includes/discount-functions.php +56 -22
- includes/emails/class-edd-email-tags.php +1 -1
- includes/payments/class-edd-payment.php +29 -18
- includes/payments/functions.php +34 -41
- includes/process-download.php +75 -18
- includes/template-functions.php +26 -1
- readme.txt +19 -2
- templates/history-downloads.php +1 -1
assets/js/edd-checkout-global.js
CHANGED
@@ -132,9 +132,14 @@ window.EDD_Checkout = (function($) {
|
|
132 |
if (discount_response.msg == 'valid') {
|
133 |
$('.edd_cart_discount').html(discount_response.html);
|
134 |
$('.edd_cart_discount_row').show();
|
135 |
-
|
136 |
-
|
137 |
-
|
|
|
|
|
|
|
|
|
|
|
138 |
$('#edd-discount', $checkout_form_wrap ).val('');
|
139 |
|
140 |
recalculate_taxes();
|
@@ -204,7 +209,11 @@ window.EDD_Checkout = (function($) {
|
|
204 |
// We're removing a 100% discount code so we need to force the payment gateway to reload
|
205 |
window.location.reload();
|
206 |
}
|
207 |
-
|
|
|
|
|
|
|
|
|
208 |
});
|
209 |
|
210 |
$('.edd_cart_discount').html(discount_response.html);
|
132 |
if (discount_response.msg == 'valid') {
|
133 |
$('.edd_cart_discount').html(discount_response.html);
|
134 |
$('.edd_cart_discount_row').show();
|
135 |
+
|
136 |
+
$( '.edd_cart_amount' ).each( function() {
|
137 |
+
// Format discounted amount for display.
|
138 |
+
$( this ).text( discount_response.total );
|
139 |
+
// Set data attribute to new (unformatted) discounted amount.'
|
140 |
+
$( this ).data( 'total', discount_response.total_plain );
|
141 |
+
} );
|
142 |
+
|
143 |
$('#edd-discount', $checkout_form_wrap ).val('');
|
144 |
|
145 |
recalculate_taxes();
|
209 |
// We're removing a 100% discount code so we need to force the payment gateway to reload
|
210 |
window.location.reload();
|
211 |
}
|
212 |
+
|
213 |
+
// Format discounted amount for display.
|
214 |
+
$( this ).text( discount_response.total );
|
215 |
+
// Set data attribute to new (unformatted) discounted amount.'
|
216 |
+
$( this ).data( 'total', discount_response.total_plain );
|
217 |
});
|
218 |
|
219 |
$('.edd_cart_discount').html(discount_response.html);
|
assets/js/edd-checkout-global.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
function recalculate_taxes(a){if("1"==edd_global_vars.taxes_enabled){var b=jQuery("#edd_cc_address");a||(a=b.find("#card_state").val());var c={action:"edd_recalculate_taxes",billing_country:b.find("#billing_country").val(),state:a};jQuery.ajax({type:"POST",data:c,dataType:"json",url:edd_global_vars.ajaxurl,xhrFields:{withCredentials:!0},success:function(a){jQuery("#edd_checkout_cart_form").replaceWith(a.html),jQuery(".edd_cart_amount").html(a.total);var b=new Object;b.postdata=c,b.response=a,jQuery("body").trigger("edd_taxes_recalculated",[b])}}).fail(function(a){window.console&&window.console.log&&(console.log(a),jQuery("body").trigger("edd_taxes_recalculated",[tax_data]))})}}window.EDD_Checkout=function(a){"use strict";function g(){b=a(document.body),c=a("#edd_purchase_form"),d=a(".edd_cart_amount"),e=d.text(),f=a("#edd_checkout_form_wrap"),b.on("keyup change",".edd-do-validate .card-number",function(){h(a(this))}),b.on("submit","#edd_payment_mode",function(){var b=a("#edd-gateway option:selected").val();if(0==b)return alert(edd_global_vars.no_gateway),!1}),b.on("click","#edd_payment_mode_select input",function(){a("#edd_payment_mode_select label.edd-gateway-option-selected").removeClass("edd-gateway-option-selected"),a("#edd_payment_mode_select input:checked").parent().addClass("edd-gateway-option-selected")}),f.on("click",".edd-apply-discount",i),f.on("keypress","#edd-discount",function(a){if("13"==a.keyCode)return!1}),f.on("keyup","#edd-discount",function(a){"13"==a.keyCode&&f.find(".edd-apply-discount").trigger("click")}),b.on("click",".edd_discount_remove",j),b.on("click",".edd_discount_link",function(b){b.preventDefault(),a(".edd_discount_link").parent().hide(),a("#edd-discount-code-wrap").show().find("#edd-discount").focus()}),b.find("#edd-discount-code-wrap").hide(),b.find("#edd_show_discount").show(),b.on("change",".edd-item-quantity",k),b.on("click",".edd-amazon-logout #Logout",function(a){a.preventDefault(),amazon.Login.logout(),window.location=edd_amazon.checkoutUri})}function h(b){var c=b;c.validateCreditCard(function(b){var d=a(".card-type");null==b.card_type?(d.removeClass().addClass("off card-type"),c.removeClass("valid"),c.addClass("error")):(d.removeClass("off"),d.addClass(b.card_type.name),b.length_valid&&b.luhn_valid?(c.addClass("valid"),c.removeClass("error")):(c.removeClass("valid"),c.addClass("error")))})}function i(c){c.preventDefault();var e=(a(this),a("#edd-discount").val()),g=a("#edd-discount-loader");if(""==e||e==edd_global_vars.enter_discount)return!1;var h={action:"edd_apply_discount",code:e,form:a("#edd_purchase_form").serialize()};return a("#edd-discount-error-wrap").html("").hide(),g.show(),a.ajax({type:"POST",data:h,dataType:"json",url:edd_global_vars.ajaxurl,xhrFields:{withCredentials:!0},success:function(c){if(c)if("valid"==c.msg){a(".edd_cart_discount").html(c.html),a(".edd_cart_discount_row").show(),a(".edd_cart_amount").each(function(){a(this).text(c.total)}),a("#edd-discount",f).val(""),recalculate_taxes();var d=a("#edd_cc_fields .edd-input, #edd_cc_fields .edd-select,#edd_cc_address .edd-input, #edd_cc_address .edd-select,#edd_payment_mode_select .edd-input, #edd_payment_mode_select .edd-select");"0.00"==c.total_plain?(a("#edd_cc_fields,#edd_cc_address,#edd_payment_mode_select").slideUp(),d.removeAttr("required"),a('input[name="edd-gateway"]').val("manual")):(d.is(".card-address-2")||d.attr("required","required"),a("#edd_cc_fields,#edd_cc_address").slideDown()),b.trigger("edd_discount_applied",[c])}else a("#edd-discount-error-wrap").html('<span class="edd_error">'+c.msg+"</span>"),a("#edd-discount-error-wrap").show(),b.trigger("edd_discount_invalid",[c]);else window.console&&window.console.log&&console.log(c),b.trigger("edd_discount_failed",[c]);g.hide()}}).fail(function(a){window.console&&window.console.log&&console.log(a)}),!1}function j(c){var d=a(this),e={action:"edd_remove_discount",code:d.data("code")};return a.ajax({type:"POST",data:e,dataType:"json",url:edd_global_vars.ajaxurl,xhrFields:{withCredentials:!0},success:function(c){var d="0"+edd_global_vars.decimal_separator+"00";a(".edd_cart_amount").each(function(){edd_global_vars.currency_sign+d!=a(this).text()&&d+edd_global_vars.currency_sign!=a(this).text()||window.location.reload(),a(this).text(c.total)}),a(".edd_cart_discount").html(c.html),c.discounts||a(".edd_cart_discount_row").hide(),recalculate_taxes(),a("#edd_cc_fields,#edd_cc_address").slideDown(),b.trigger("edd_discount_removed",[c])}}).fail(function(a){window.console&&window.console.log&&console.log(a)}),!1}function k(c){var d=a(this),e=d.val(),f=d.data("key"),g=d.closest(".edd_cart_item").data("download-id"),h=d.parent().find('input[name="edd-cart-download-'+f+'-options"]').val(),i={action:"edd_update_quantity",quantity:e,download_id:g,options:h};return a.ajax({type:"POST",data:i,dataType:"json",url:edd_global_vars.ajaxurl,xhrFields:{withCredentials:!0},success:function(c){a(".edd_cart_subtotal_amount").each(function(){a(this).text(c.subtotal)}),a(".edd_cart_tax_amount").each(function(){a(this).text(c.taxes)}),a(".edd_cart_amount").each(function(){a(this).text(c.total),b.trigger("edd_quantity_updated",[c])})}}).fail(function(a){window.console&&window.console.log&&console.log(a)}),!1}var b,c,d,e,f;return{init:g,recalculate_taxes:recalculate_taxes}}(window.jQuery),window.jQuery(document).ready(EDD_Checkout.init);
|
1 |
+
function recalculate_taxes(a){if("1"==edd_global_vars.taxes_enabled){var b=jQuery("#edd_cc_address");a||(a=b.find("#card_state").val());var c={action:"edd_recalculate_taxes",billing_country:b.find("#billing_country").val(),state:a};jQuery.ajax({type:"POST",data:c,dataType:"json",url:edd_global_vars.ajaxurl,xhrFields:{withCredentials:!0},success:function(a){jQuery("#edd_checkout_cart_form").replaceWith(a.html),jQuery(".edd_cart_amount").html(a.total);var b=new Object;b.postdata=c,b.response=a,jQuery("body").trigger("edd_taxes_recalculated",[b])}}).fail(function(a){window.console&&window.console.log&&(console.log(a),jQuery("body").trigger("edd_taxes_recalculated",[tax_data]))})}}window.EDD_Checkout=function(a){"use strict";function g(){b=a(document.body),c=a("#edd_purchase_form"),d=a(".edd_cart_amount"),e=d.text(),f=a("#edd_checkout_form_wrap"),b.on("keyup change",".edd-do-validate .card-number",function(){h(a(this))}),b.on("submit","#edd_payment_mode",function(){var b=a("#edd-gateway option:selected").val();if(0==b)return alert(edd_global_vars.no_gateway),!1}),b.on("click","#edd_payment_mode_select input",function(){a("#edd_payment_mode_select label.edd-gateway-option-selected").removeClass("edd-gateway-option-selected"),a("#edd_payment_mode_select input:checked").parent().addClass("edd-gateway-option-selected")}),f.on("click",".edd-apply-discount",i),f.on("keypress","#edd-discount",function(a){if("13"==a.keyCode)return!1}),f.on("keyup","#edd-discount",function(a){"13"==a.keyCode&&f.find(".edd-apply-discount").trigger("click")}),b.on("click",".edd_discount_remove",j),b.on("click",".edd_discount_link",function(b){b.preventDefault(),a(".edd_discount_link").parent().hide(),a("#edd-discount-code-wrap").show().find("#edd-discount").focus()}),b.find("#edd-discount-code-wrap").hide(),b.find("#edd_show_discount").show(),b.on("change",".edd-item-quantity",k),b.on("click",".edd-amazon-logout #Logout",function(a){a.preventDefault(),amazon.Login.logout(),window.location=edd_amazon.checkoutUri})}function h(b){var c=b;c.validateCreditCard(function(b){var d=a(".card-type");null==b.card_type?(d.removeClass().addClass("off card-type"),c.removeClass("valid"),c.addClass("error")):(d.removeClass("off"),d.addClass(b.card_type.name),b.length_valid&&b.luhn_valid?(c.addClass("valid"),c.removeClass("error")):(c.removeClass("valid"),c.addClass("error")))})}function i(c){c.preventDefault();var e=(a(this),a("#edd-discount").val()),g=a("#edd-discount-loader");if(""==e||e==edd_global_vars.enter_discount)return!1;var h={action:"edd_apply_discount",code:e,form:a("#edd_purchase_form").serialize()};return a("#edd-discount-error-wrap").html("").hide(),g.show(),a.ajax({type:"POST",data:h,dataType:"json",url:edd_global_vars.ajaxurl,xhrFields:{withCredentials:!0},success:function(c){if(c)if("valid"==c.msg){a(".edd_cart_discount").html(c.html),a(".edd_cart_discount_row").show(),a(".edd_cart_amount").each(function(){a(this).text(c.total),a(this).data("total",c.total_plain)}),a("#edd-discount",f).val(""),recalculate_taxes();var d=a("#edd_cc_fields .edd-input, #edd_cc_fields .edd-select,#edd_cc_address .edd-input, #edd_cc_address .edd-select,#edd_payment_mode_select .edd-input, #edd_payment_mode_select .edd-select");"0.00"==c.total_plain?(a("#edd_cc_fields,#edd_cc_address,#edd_payment_mode_select").slideUp(),d.removeAttr("required"),a('input[name="edd-gateway"]').val("manual")):(d.is(".card-address-2")||d.attr("required","required"),a("#edd_cc_fields,#edd_cc_address").slideDown()),b.trigger("edd_discount_applied",[c])}else a("#edd-discount-error-wrap").html('<span class="edd_error">'+c.msg+"</span>"),a("#edd-discount-error-wrap").show(),b.trigger("edd_discount_invalid",[c]);else window.console&&window.console.log&&console.log(c),b.trigger("edd_discount_failed",[c]);g.hide()}}).fail(function(a){window.console&&window.console.log&&console.log(a)}),!1}function j(c){var d=a(this),e={action:"edd_remove_discount",code:d.data("code")};return a.ajax({type:"POST",data:e,dataType:"json",url:edd_global_vars.ajaxurl,xhrFields:{withCredentials:!0},success:function(c){var d="0"+edd_global_vars.decimal_separator+"00";a(".edd_cart_amount").each(function(){edd_global_vars.currency_sign+d!=a(this).text()&&d+edd_global_vars.currency_sign!=a(this).text()||window.location.reload(),a(this).text(c.total),a(this).data("total",c.total_plain)}),a(".edd_cart_discount").html(c.html),c.discounts||a(".edd_cart_discount_row").hide(),recalculate_taxes(),a("#edd_cc_fields,#edd_cc_address").slideDown(),b.trigger("edd_discount_removed",[c])}}).fail(function(a){window.console&&window.console.log&&console.log(a)}),!1}function k(c){var d=a(this),e=d.val(),f=d.data("key"),g=d.closest(".edd_cart_item").data("download-id"),h=d.parent().find('input[name="edd-cart-download-'+f+'-options"]').val(),i={action:"edd_update_quantity",quantity:e,download_id:g,options:h};return a.ajax({type:"POST",data:i,dataType:"json",url:edd_global_vars.ajaxurl,xhrFields:{withCredentials:!0},success:function(c){a(".edd_cart_subtotal_amount").each(function(){a(this).text(c.subtotal)}),a(".edd_cart_tax_amount").each(function(){a(this).text(c.taxes)}),a(".edd_cart_amount").each(function(){a(this).text(c.total),b.trigger("edd_quantity_updated",[c])})}}).fail(function(a){window.console&&window.console.log&&console.log(a)}),!1}var b,c,d,e,f;return{init:g,recalculate_taxes:recalculate_taxes}}(window.jQuery),window.jQuery(document).ready(EDD_Checkout.init);
|
easy-digital-downloads.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* Description: The easiest way to sell digital products with WordPress.
|
6 |
* Author: Easy Digital Downloads
|
7 |
* Author URI: https://easydigitaldownloads.com
|
8 |
-
* Version: 2.6.
|
9 |
* Text Domain: easy-digital-downloads
|
10 |
* Domain Path: languages
|
11 |
*
|
@@ -25,7 +25,7 @@
|
|
25 |
* @package EDD
|
26 |
* @category Core
|
27 |
* @author Pippin Williamson
|
28 |
-
* @version 2.6.
|
29 |
*/
|
30 |
|
31 |
// Exit if accessed directly.
|
@@ -196,7 +196,7 @@ final class Easy_Digital_Downloads {
|
|
196 |
|
197 |
// Plugin version.
|
198 |
if ( ! defined( 'EDD_VERSION' ) ) {
|
199 |
-
define( 'EDD_VERSION', '2.6.
|
200 |
}
|
201 |
|
202 |
// Plugin Folder Path.
|
@@ -355,6 +355,7 @@ final class Easy_Digital_Downloads {
|
|
355 |
* @return void
|
356 |
*/
|
357 |
public function load_textdomain() {
|
|
|
358 |
|
359 |
/*
|
360 |
* Due to the introduction of language packs through translate.wordpress.org, loading our textdomain is complex.
|
@@ -381,7 +382,21 @@ final class Easy_Digital_Downloads {
|
|
381 |
$edd_lang_dir = apply_filters( 'edd_languages_directory', $edd_lang_dir );
|
382 |
|
383 |
// Traditional WordPress plugin locale filter.
|
384 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
385 |
$mofile = sprintf( '%1$s-%2$s.mo', 'easy-digital-downloads', $locale );
|
386 |
|
387 |
// Look for wp-content/languages/edd/easy-digital-downloads-{lang}_{country}.mo
|
5 |
* Description: The easiest way to sell digital products with WordPress.
|
6 |
* Author: Easy Digital Downloads
|
7 |
* Author URI: https://easydigitaldownloads.com
|
8 |
+
* Version: 2.6.14
|
9 |
* Text Domain: easy-digital-downloads
|
10 |
* Domain Path: languages
|
11 |
*
|
25 |
* @package EDD
|
26 |
* @category Core
|
27 |
* @author Pippin Williamson
|
28 |
+
* @version 2.6.14
|
29 |
*/
|
30 |
|
31 |
// Exit if accessed directly.
|
196 |
|
197 |
// Plugin version.
|
198 |
if ( ! defined( 'EDD_VERSION' ) ) {
|
199 |
+
define( 'EDD_VERSION', '2.6.14' );
|
200 |
}
|
201 |
|
202 |
// Plugin Folder Path.
|
355 |
* @return void
|
356 |
*/
|
357 |
public function load_textdomain() {
|
358 |
+
global $wp_version;
|
359 |
|
360 |
/*
|
361 |
* Due to the introduction of language packs through translate.wordpress.org, loading our textdomain is complex.
|
382 |
$edd_lang_dir = apply_filters( 'edd_languages_directory', $edd_lang_dir );
|
383 |
|
384 |
// Traditional WordPress plugin locale filter.
|
385 |
+
|
386 |
+
$get_locale = get_locale();
|
387 |
+
|
388 |
+
if ( $wp_version >= 4.7 ) {
|
389 |
+
|
390 |
+
$get_locale = get_user_locale();
|
391 |
+
}
|
392 |
+
|
393 |
+
/**
|
394 |
+
* Defines the plugin language locale used in AffiliateWP.
|
395 |
+
*
|
396 |
+
* @var $get_locale The locale to use. Uses get_user_locale()` in WordPress 4.7 or greater,
|
397 |
+
* otherwise uses `get_locale()`.
|
398 |
+
*/
|
399 |
+
$locale = apply_filters( 'plugin_locale', $get_locale, 'easy-digital-downloads' );
|
400 |
$mofile = sprintf( '%1$s-%2$s.mo', 'easy-digital-downloads', $locale );
|
401 |
|
402 |
// Look for wp-content/languages/edd/easy-digital-downloads-{lang}_{country}.mo
|
includes/EDD_SL_Plugin_Updater.php
CHANGED
@@ -258,7 +258,7 @@ class EDD_SL_Plugin_Updater {
|
|
258 |
)
|
259 |
);
|
260 |
|
261 |
-
$cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data
|
262 |
|
263 |
//Get the transient where we store the api request for this plugin for 24 hours
|
264 |
$edd_api_request_transient = get_site_transient( $cache_key );
|
258 |
)
|
259 |
);
|
260 |
|
261 |
+
$cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] ) );
|
262 |
|
263 |
//Get the transient where we store the api request for this plugin for 24 hours
|
264 |
$edd_api_request_transient = get_site_transient( $cache_key );
|
includes/admin/reporting/class-edd-graph.php
CHANGED
@@ -160,7 +160,6 @@ class EDD_Graph {
|
|
160 |
$yaxis_count = 1;
|
161 |
|
162 |
$this->load_scripts();
|
163 |
-
|
164 |
ob_start();
|
165 |
?>
|
166 |
<script type="text/javascript">
|
160 |
$yaxis_count = 1;
|
161 |
|
162 |
$this->load_scripts();
|
|
|
163 |
ob_start();
|
164 |
?>
|
165 |
<script type="text/javascript">
|
includes/admin/reporting/graphing.php
CHANGED
@@ -85,12 +85,10 @@ function edd_reports_graph() {
|
|
85 |
$hour++;
|
86 |
}
|
87 |
} elseif ( $dates['range'] == 'this_week' || $dates['range'] == 'last_week' ) {
|
88 |
-
$num_of_days = cal_days_in_month( CAL_GREGORIAN, $dates['m_start'], $dates['year'] );
|
89 |
-
|
90 |
$report_dates = array();
|
91 |
$i = 0;
|
92 |
while ( $i <= 6 ) {
|
93 |
-
if ( ( $dates['day'] + $i ) <= $
|
94 |
$report_dates[ $i ] = array(
|
95 |
'day' => (string) $dates['day'] + $i,
|
96 |
'month' => $dates['m_start'],
|
@@ -110,7 +108,7 @@ function edd_reports_graph() {
|
|
110 |
$start_date = $report_dates[0];
|
111 |
$end_date = end( $report_dates );
|
112 |
|
113 |
-
$sales = EDD()->payment_stats->get_sales_by_range( $dates['range'], true, $start_date['year'] . '-' .
|
114 |
|
115 |
$i = 0;
|
116 |
foreach ( $report_dates as $report_date ) {
|
@@ -287,7 +285,12 @@ function edd_reports_graph() {
|
|
287 |
$day_keys = array_keys( $days );
|
288 |
$last_day = end( $day_keys );
|
289 |
|
290 |
-
$consolidated_date =
|
|
|
|
|
|
|
|
|
|
|
291 |
|
292 |
$earnings = array_sum( $days );
|
293 |
$date = mktime( 0, 0, 0, $month, $consolidated_date, $year ) * 1000;
|
85 |
$hour++;
|
86 |
}
|
87 |
} elseif ( $dates['range'] == 'this_week' || $dates['range'] == 'last_week' ) {
|
|
|
|
|
88 |
$report_dates = array();
|
89 |
$i = 0;
|
90 |
while ( $i <= 6 ) {
|
91 |
+
if ( ( $dates['day'] + $i ) <= $dates['day_end'] ) {
|
92 |
$report_dates[ $i ] = array(
|
93 |
'day' => (string) $dates['day'] + $i,
|
94 |
'month' => $dates['m_start'],
|
108 |
$start_date = $report_dates[0];
|
109 |
$end_date = end( $report_dates );
|
110 |
|
111 |
+
$sales = EDD()->payment_stats->get_sales_by_range( $dates['range'], true, $start_date['year'] . '-' . $start_date['month'] . '-' . $start_date['day'], $end_date['year'] . '-' . $end_date['month'] . '-' . $end_date['day'] );
|
112 |
|
113 |
$i = 0;
|
114 |
foreach ( $report_dates as $report_date ) {
|
285 |
$day_keys = array_keys( $days );
|
286 |
$last_day = end( $day_keys );
|
287 |
|
288 |
+
$consolidated_date = 1;
|
289 |
+
if( $day_by_day ) {
|
290 |
+
|
291 |
+
$consolidated_date = $month === end( $month_keys ) ? cal_days_in_month( CAL_GREGORIAN, $month, $year ) : 1;
|
292 |
+
|
293 |
+
}
|
294 |
|
295 |
$earnings = array_sum( $days );
|
296 |
$date = mktime( 0, 0, 0, $month, $consolidated_date, $year ) * 1000;
|
includes/admin/settings/register-settings.php
CHANGED
@@ -1162,22 +1162,22 @@ add_filter( 'edd_settings_sanitize_text', 'edd_sanitize_text_field' );
|
|
1162 |
|
1163 |
/**
|
1164 |
* Sanitize HTML Class Names
|
1165 |
-
*
|
1166 |
* @since 2.6.11
|
1167 |
* @param string|array $class HTML Class Name(s)
|
1168 |
* @return string $class
|
1169 |
*/
|
1170 |
function edd_sanitize_html_class( $class = '' ) {
|
1171 |
-
|
1172 |
if ( is_string( $class ) ) {
|
1173 |
$class = sanitize_html_class( $class );
|
1174 |
} else if ( is_array( $class ) ) {
|
1175 |
$class = array_values( array_map( 'sanitize_html_class', $class ) );
|
1176 |
$class = implode( ' ', array_unique( $class ) );
|
1177 |
}
|
1178 |
-
|
1179 |
return $class;
|
1180 |
-
|
1181 |
}
|
1182 |
|
1183 |
/**
|
@@ -1342,7 +1342,7 @@ function edd_checkbox_callback( $args ) {
|
|
1342 |
} else {
|
1343 |
$name = 'name="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']"';
|
1344 |
}
|
1345 |
-
|
1346 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1347 |
|
1348 |
$checked = ! empty( $edd_option ) ? checked( 1, $edd_option, false ) : '';
|
@@ -1365,7 +1365,7 @@ function edd_checkbox_callback( $args ) {
|
|
1365 |
*/
|
1366 |
function edd_multicheck_callback( $args ) {
|
1367 |
$edd_option = edd_get_option( $args['id'] );
|
1368 |
-
|
1369 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1370 |
|
1371 |
$html = '';
|
@@ -1392,7 +1392,7 @@ function edd_multicheck_callback( $args ) {
|
|
1392 |
*/
|
1393 |
function edd_payment_icons_callback( $args ) {
|
1394 |
$edd_option = edd_get_option( $args['id'] );
|
1395 |
-
|
1396 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1397 |
|
1398 |
$html = '<input type="hidden" name="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']" value="-1" />';
|
@@ -1465,7 +1465,7 @@ function edd_radio_callback( $args ) {
|
|
1465 |
$edd_options = edd_get_option( $args['id'] );
|
1466 |
|
1467 |
$html = '';
|
1468 |
-
|
1469 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1470 |
|
1471 |
foreach ( $args['options'] as $key => $option ) :
|
@@ -1497,7 +1497,7 @@ function edd_radio_callback( $args ) {
|
|
1497 |
*/
|
1498 |
function edd_gateways_callback( $args ) {
|
1499 |
$edd_option = edd_get_option( $args['id'] );
|
1500 |
-
|
1501 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1502 |
|
1503 |
$html = '<input type="hidden" name="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']" value="-1" />';
|
@@ -1527,7 +1527,7 @@ function edd_gateways_callback( $args ) {
|
|
1527 |
*/
|
1528 |
function edd_gateway_select_callback( $args ) {
|
1529 |
$edd_option = edd_get_option( $args['id'] );
|
1530 |
-
|
1531 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1532 |
|
1533 |
$html = '';
|
@@ -1571,7 +1571,7 @@ function edd_text_callback( $args ) {
|
|
1571 |
} else {
|
1572 |
$name = 'name="edd_settings[' . esc_attr( $args['id'] ) . ']"';
|
1573 |
}
|
1574 |
-
|
1575 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1576 |
|
1577 |
$readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
|
@@ -1608,7 +1608,7 @@ function edd_number_callback( $args ) {
|
|
1608 |
} else {
|
1609 |
$name = 'name="edd_settings[' . esc_attr( $args['id'] ) . ']"';
|
1610 |
}
|
1611 |
-
|
1612 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1613 |
|
1614 |
$max = isset( $args['max'] ) ? $args['max'] : 999999;
|
@@ -1640,7 +1640,7 @@ function edd_textarea_callback( $args ) {
|
|
1640 |
} else {
|
1641 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1642 |
}
|
1643 |
-
|
1644 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1645 |
|
1646 |
$html = '<textarea class="' . $class . ' large-text" cols="50" rows="5" id="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']" name="edd_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
|
@@ -1667,7 +1667,7 @@ function edd_password_callback( $args ) {
|
|
1667 |
} else {
|
1668 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1669 |
}
|
1670 |
-
|
1671 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1672 |
|
1673 |
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
@@ -1717,7 +1717,7 @@ function edd_select_callback($args) {
|
|
1717 |
} else {
|
1718 |
$placeholder = '';
|
1719 |
}
|
1720 |
-
|
1721 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1722 |
|
1723 |
if ( isset( $args['chosen'] ) ) {
|
@@ -1755,7 +1755,7 @@ function edd_color_select_callback( $args ) {
|
|
1755 |
} else {
|
1756 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1757 |
}
|
1758 |
-
|
1759 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1760 |
|
1761 |
$html = '<select id="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']" class="' . $class . '" name="edd_settings[' . esc_attr( $args['id'] ) . ']"/>';
|
@@ -1823,7 +1823,7 @@ function edd_upload_callback( $args ) {
|
|
1823 |
} else {
|
1824 |
$value = isset($args['std']) ? $args['std'] : '';
|
1825 |
}
|
1826 |
-
|
1827 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1828 |
|
1829 |
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
@@ -1855,7 +1855,7 @@ function edd_color_callback( $args ) {
|
|
1855 |
}
|
1856 |
|
1857 |
$default = isset( $args['std'] ) ? $args['std'] : '';
|
1858 |
-
|
1859 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1860 |
|
1861 |
$html = '<input type="text" class="' . $class . ' edd-color-picker" id="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']" name="edd_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
|
@@ -1882,19 +1882,19 @@ function edd_shop_states_callback($args) {
|
|
1882 |
} else {
|
1883 |
$placeholder = '';
|
1884 |
}
|
1885 |
-
|
1886 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1887 |
|
1888 |
$states = edd_get_shop_states();
|
1889 |
-
|
1890 |
if ( $args['chosen'] ) {
|
1891 |
$class .= ' edd-chosen';
|
1892 |
}
|
1893 |
-
|
1894 |
if ( empty( $states ) ) {
|
1895 |
$class .= ' edd-no-states';
|
1896 |
}
|
1897 |
-
|
1898 |
$html = '<select id="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']" name="edd_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
|
1899 |
|
1900 |
foreach ( $states as $option => $name ) {
|
@@ -1919,9 +1919,9 @@ function edd_shop_states_callback($args) {
|
|
1919 |
*/
|
1920 |
function edd_tax_rates_callback($args) {
|
1921 |
$rates = edd_get_tax_rates();
|
1922 |
-
|
1923 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1924 |
-
|
1925 |
ob_start(); ?>
|
1926 |
<p><?php echo $args['desc']; ?></p>
|
1927 |
<table id="edd_tax_rates" class="wp-list-table widefat fixed posts <?php echo $class; ?>">
|
@@ -2201,7 +2201,7 @@ if ( ! function_exists( 'edd_license_key_callback' ) ) {
|
|
2201 |
|
2202 |
$license_status = null;
|
2203 |
}
|
2204 |
-
|
2205 |
$class .= ' ' . edd_sanitize_html_class( $args['field_class'] );
|
2206 |
|
2207 |
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
1162 |
|
1163 |
/**
|
1164 |
* Sanitize HTML Class Names
|
1165 |
+
*
|
1166 |
* @since 2.6.11
|
1167 |
* @param string|array $class HTML Class Name(s)
|
1168 |
* @return string $class
|
1169 |
*/
|
1170 |
function edd_sanitize_html_class( $class = '' ) {
|
1171 |
+
|
1172 |
if ( is_string( $class ) ) {
|
1173 |
$class = sanitize_html_class( $class );
|
1174 |
} else if ( is_array( $class ) ) {
|
1175 |
$class = array_values( array_map( 'sanitize_html_class', $class ) );
|
1176 |
$class = implode( ' ', array_unique( $class ) );
|
1177 |
}
|
1178 |
+
|
1179 |
return $class;
|
1180 |
+
|
1181 |
}
|
1182 |
|
1183 |
/**
|
1342 |
} else {
|
1343 |
$name = 'name="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']"';
|
1344 |
}
|
1345 |
+
|
1346 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1347 |
|
1348 |
$checked = ! empty( $edd_option ) ? checked( 1, $edd_option, false ) : '';
|
1365 |
*/
|
1366 |
function edd_multicheck_callback( $args ) {
|
1367 |
$edd_option = edd_get_option( $args['id'] );
|
1368 |
+
|
1369 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1370 |
|
1371 |
$html = '';
|
1392 |
*/
|
1393 |
function edd_payment_icons_callback( $args ) {
|
1394 |
$edd_option = edd_get_option( $args['id'] );
|
1395 |
+
|
1396 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1397 |
|
1398 |
$html = '<input type="hidden" name="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']" value="-1" />';
|
1465 |
$edd_options = edd_get_option( $args['id'] );
|
1466 |
|
1467 |
$html = '';
|
1468 |
+
|
1469 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1470 |
|
1471 |
foreach ( $args['options'] as $key => $option ) :
|
1497 |
*/
|
1498 |
function edd_gateways_callback( $args ) {
|
1499 |
$edd_option = edd_get_option( $args['id'] );
|
1500 |
+
|
1501 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1502 |
|
1503 |
$html = '<input type="hidden" name="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']" value="-1" />';
|
1527 |
*/
|
1528 |
function edd_gateway_select_callback( $args ) {
|
1529 |
$edd_option = edd_get_option( $args['id'] );
|
1530 |
+
|
1531 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1532 |
|
1533 |
$html = '';
|
1571 |
} else {
|
1572 |
$name = 'name="edd_settings[' . esc_attr( $args['id'] ) . ']"';
|
1573 |
}
|
1574 |
+
|
1575 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1576 |
|
1577 |
$readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
|
1608 |
} else {
|
1609 |
$name = 'name="edd_settings[' . esc_attr( $args['id'] ) . ']"';
|
1610 |
}
|
1611 |
+
|
1612 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1613 |
|
1614 |
$max = isset( $args['max'] ) ? $args['max'] : 999999;
|
1640 |
} else {
|
1641 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1642 |
}
|
1643 |
+
|
1644 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1645 |
|
1646 |
$html = '<textarea class="' . $class . ' large-text" cols="50" rows="5" id="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']" name="edd_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
|
1667 |
} else {
|
1668 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1669 |
}
|
1670 |
+
|
1671 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1672 |
|
1673 |
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
1717 |
} else {
|
1718 |
$placeholder = '';
|
1719 |
}
|
1720 |
+
|
1721 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1722 |
|
1723 |
if ( isset( $args['chosen'] ) ) {
|
1755 |
} else {
|
1756 |
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1757 |
}
|
1758 |
+
|
1759 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1760 |
|
1761 |
$html = '<select id="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']" class="' . $class . '" name="edd_settings[' . esc_attr( $args['id'] ) . ']"/>';
|
1823 |
} else {
|
1824 |
$value = isset($args['std']) ? $args['std'] : '';
|
1825 |
}
|
1826 |
+
|
1827 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1828 |
|
1829 |
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
1855 |
}
|
1856 |
|
1857 |
$default = isset( $args['std'] ) ? $args['std'] : '';
|
1858 |
+
|
1859 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1860 |
|
1861 |
$html = '<input type="text" class="' . $class . ' edd-color-picker" id="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']" name="edd_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
|
1882 |
} else {
|
1883 |
$placeholder = '';
|
1884 |
}
|
1885 |
+
|
1886 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1887 |
|
1888 |
$states = edd_get_shop_states();
|
1889 |
+
|
1890 |
if ( $args['chosen'] ) {
|
1891 |
$class .= ' edd-chosen';
|
1892 |
}
|
1893 |
+
|
1894 |
if ( empty( $states ) ) {
|
1895 |
$class .= ' edd-no-states';
|
1896 |
}
|
1897 |
+
|
1898 |
$html = '<select id="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']" name="edd_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
|
1899 |
|
1900 |
foreach ( $states as $option => $name ) {
|
1919 |
*/
|
1920 |
function edd_tax_rates_callback($args) {
|
1921 |
$rates = edd_get_tax_rates();
|
1922 |
+
|
1923 |
$class = edd_sanitize_html_class( $args['field_class'] );
|
1924 |
+
|
1925 |
ob_start(); ?>
|
1926 |
<p><?php echo $args['desc']; ?></p>
|
1927 |
<table id="edd_tax_rates" class="wp-list-table widefat fixed posts <?php echo $class; ?>">
|
2201 |
|
2202 |
$license_status = null;
|
2203 |
}
|
2204 |
+
|
2205 |
$class .= ' ' . edd_sanitize_html_class( $args['field_class'] );
|
2206 |
|
2207 |
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
includes/admin/tracking.php
CHANGED
@@ -101,7 +101,7 @@ class EDD_Tracking {
|
|
101 |
$data['inactive_plugins'] = $plugins;
|
102 |
$data['products'] = wp_count_posts( 'download' )->publish;
|
103 |
$data['download_label'] = edd_get_label_singular( true );
|
104 |
-
$data['locale'] = get_locale();
|
105 |
|
106 |
$this->data = $data;
|
107 |
}
|
101 |
$data['inactive_plugins'] = $plugins;
|
102 |
$data['products'] = wp_count_posts( 'download' )->publish;
|
103 |
$data['download_label'] = edd_get_label_singular( true );
|
104 |
+
$data['locale'] = ( $data['wp_version'] >= 4.7 ) ? get_user_locale() : get_locale();
|
105 |
|
106 |
$this->data = $data;
|
107 |
}
|
includes/cart/functions.php
CHANGED
@@ -137,6 +137,9 @@ function edd_get_cart_quantity() {
|
|
137 |
if ( ! empty( $cart ) ) {
|
138 |
$quantities = wp_list_pluck( $cart, 'quantity' );
|
139 |
$total_quantity = absint( array_sum( $quantities ) );
|
|
|
|
|
|
|
140 |
}
|
141 |
|
142 |
|
@@ -211,7 +214,7 @@ function edd_add_to_cart( $download_id, $options = array() ) {
|
|
211 |
'options' => array(
|
212 |
'price_id' => preg_replace( '/[^0-9\.-]/', '', $price )
|
213 |
),
|
214 |
-
'quantity' => $quantity[ $key ],
|
215 |
);
|
216 |
|
217 |
}
|
137 |
if ( ! empty( $cart ) ) {
|
138 |
$quantities = wp_list_pluck( $cart, 'quantity' );
|
139 |
$total_quantity = absint( array_sum( $quantities ) );
|
140 |
+
if( empty( $total_quantity ) ) {
|
141 |
+
$total_quantity = count( $cart );
|
142 |
+
}
|
143 |
}
|
144 |
|
145 |
|
214 |
'options' => array(
|
215 |
'price_id' => preg_replace( '/[^0-9\.-]/', '', $price )
|
216 |
),
|
217 |
+
'quantity' => is_array( $quantity[ $key ] ) && isset( $quantity[ $key ] ) ? $quantity[ $key ] : $quantity,
|
218 |
);
|
219 |
|
220 |
}
|
includes/cart/template.php
CHANGED
@@ -33,7 +33,9 @@ function edd_checkout_cart() {
|
|
33 |
do_action( 'edd_before_checkout_cart' );
|
34 |
echo '<form id="edd_checkout_cart_form" method="post">';
|
35 |
echo '<div id="edd_checkout_cart_wrap">';
|
|
|
36 |
edd_get_template_part( 'checkout_cart' );
|
|
|
37 |
echo '</div>';
|
38 |
echo '</form>';
|
39 |
do_action( 'edd_after_checkout_cart' );
|
33 |
do_action( 'edd_before_checkout_cart' );
|
34 |
echo '<form id="edd_checkout_cart_form" method="post">';
|
35 |
echo '<div id="edd_checkout_cart_wrap">';
|
36 |
+
do_action( 'edd_checkout_cart_top' );
|
37 |
edd_get_template_part( 'checkout_cart' );
|
38 |
+
do_action( 'edd_checkout_cart_bottom' );
|
39 |
echo '</div>';
|
40 |
echo '</form>';
|
41 |
do_action( 'edd_after_checkout_cart' );
|
includes/discount-functions.php
CHANGED
@@ -384,21 +384,22 @@ function edd_discount_exists( $code_id ) {
|
|
384 |
* @since 2.6.11 Added $update parameter
|
385 |
* @param int $code_id
|
386 |
* @param bool $update Update the discount to expired if an one is found but has an active status
|
|
|
387 |
* @return bool
|
388 |
*/
|
389 |
-
function edd_is_discount_active( $code_id = null, $update = true ) {
|
390 |
$discount = edd_get_discount( $code_id );
|
391 |
$return = false;
|
392 |
|
393 |
if ( $discount ) {
|
394 |
if ( edd_is_discount_expired( $code_id, $update ) ) {
|
395 |
-
if ( defined( 'DOING_AJAX' ) ) {
|
396 |
edd_set_error( 'edd-discount-error', __( 'This discount is expired.', 'easy-digital-downloads' ) );
|
397 |
}
|
398 |
} elseif ( $discount->post_status == 'active' ) {
|
399 |
$return = true;
|
400 |
} else {
|
401 |
-
if( defined( 'DOING_AJAX' ) ) {
|
402 |
edd_set_error( 'edd-discount-error', __( 'This discount is not active.', 'easy-digital-downloads' ) );
|
403 |
}
|
404 |
}
|
@@ -612,9 +613,10 @@ function edd_is_discount_expired( $code_id = null, $update = true ) {
|
|
612 |
*
|
613 |
* @since 1.0
|
614 |
* @param int $code_id Discount ID
|
|
|
615 |
* @return bool Is discount started?
|
616 |
*/
|
617 |
-
function edd_is_discount_started( $code_id = null ) {
|
618 |
$discount = edd_get_discount( $code_id );
|
619 |
$return = false;
|
620 |
|
@@ -627,7 +629,7 @@ function edd_is_discount_started( $code_id = null ) {
|
|
627 |
if ( $start_date < current_time( 'timestamp' ) ) {
|
628 |
// Discount has pased the start date
|
629 |
$return = true;
|
630 |
-
}
|
631 |
edd_set_error( 'edd-discount-error', __( 'This discount is not active yet.', 'easy-digital-downloads' ) );
|
632 |
}
|
633 |
} else {
|
@@ -646,21 +648,33 @@ function edd_is_discount_started( $code_id = null ) {
|
|
646 |
*
|
647 |
* @since 1.0
|
648 |
* @param int $code_id Discount ID
|
|
|
649 |
* @return bool Is discount maxed out?
|
650 |
*/
|
651 |
-
function edd_is_discount_maxed_out( $code_id = null ) {
|
652 |
$discount = edd_get_discount( $code_id );
|
653 |
$return = false;
|
654 |
|
655 |
if ( $discount ) {
|
|
|
656 |
$uses = edd_get_discount_uses( $code_id );
|
|
|
657 |
// Large number that will never be reached
|
658 |
$max_uses = edd_get_discount_max_uses( $code_id );
|
|
|
659 |
// Should never be greater than, but just in case
|
660 |
if ( $uses >= $max_uses && ! empty( $max_uses ) ) {
|
|
|
661 |
// Discount is maxed out
|
662 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
663 |
$return = true;
|
|
|
664 |
}
|
665 |
}
|
666 |
|
@@ -674,9 +688,10 @@ function edd_is_discount_maxed_out( $code_id = null ) {
|
|
674 |
*
|
675 |
* @since 1.1.7
|
676 |
* @param int $code_id Discount ID
|
|
|
677 |
* @return bool $return
|
678 |
*/
|
679 |
-
function edd_discount_is_min_met( $code_id = null ) {
|
680 |
$discount = edd_get_discount( $code_id );
|
681 |
$return = false;
|
682 |
|
@@ -687,7 +702,7 @@ function edd_discount_is_min_met( $code_id = null ) {
|
|
687 |
if ( (float) $cart_amount >= (float) $min ) {
|
688 |
// Minimum has been met
|
689 |
$return = true;
|
690 |
-
}
|
691 |
edd_set_error( 'edd-discount-error', sprintf( __( 'Minimum order of %s not met.', 'easy-digital-downloads' ), edd_currency_filter( edd_format_amount( $min ) ) ) );
|
692 |
}
|
693 |
}
|
@@ -712,9 +727,10 @@ function edd_discount_is_single_use( $code_id = 0 ) {
|
|
712 |
*
|
713 |
* @since 1.5
|
714 |
* @param int $code_id Discount ID
|
|
|
715 |
* @return bool $ret Are required products in the cart?
|
716 |
*/
|
717 |
-
function edd_discount_product_reqs_met( $code_id = null ) {
|
718 |
$product_reqs = edd_get_discount_product_reqs( $code_id );
|
719 |
$condition = edd_get_discount_product_condition( $code_id );
|
720 |
$excluded_ps = edd_get_discount_excluded_products( $code_id );
|
@@ -750,7 +766,13 @@ function edd_discount_product_reqs_met( $code_id = null ) {
|
|
750 |
|
751 |
foreach ( $product_reqs as $download_id ) {
|
752 |
if ( ! edd_item_in_cart( $download_id ) ) {
|
753 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
754 |
$ret = false;
|
755 |
break;
|
756 |
}
|
@@ -768,7 +790,7 @@ function edd_discount_product_reqs_met( $code_id = null ) {
|
|
768 |
|
769 |
}
|
770 |
|
771 |
-
if( ! $ret ) {
|
772 |
|
773 |
edd_set_error( 'edd-discount-error', __( 'The product requirements for this discount are not met.', 'easy-digital-downloads' ) );
|
774 |
|
@@ -786,7 +808,13 @@ function edd_discount_product_reqs_met( $code_id = null ) {
|
|
786 |
if( ! empty( $excluded_ps ) ) {
|
787 |
// Check that there are products other than excluded ones in the cart
|
788 |
if( $cart_ids == $excluded_ps ) {
|
789 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
790 |
$ret = false;
|
791 |
}
|
792 |
}
|
@@ -804,10 +832,11 @@ function edd_discount_product_reqs_met( $code_id = null ) {
|
|
804 |
* @param string $code
|
805 |
* @param string $user
|
806 |
* @param int $code_id (since 1.5) ID of the discount code to check
|
|
|
807 |
*
|
808 |
* @return bool $return
|
809 |
*/
|
810 |
-
function edd_is_discount_used( $code = null, $user = '', $code_id = 0 ) {
|
811 |
|
812 |
$return = false;
|
813 |
|
@@ -890,7 +919,12 @@ function edd_is_discount_used( $code = null, $user = '', $code_id = 0 ) {
|
|
890 |
|
891 |
if( in_array( strtolower( $code ), $discounts ) ) {
|
892 |
|
893 |
-
|
|
|
|
|
|
|
|
|
|
|
894 |
$return = true;
|
895 |
break;
|
896 |
|
@@ -913,11 +947,11 @@ function edd_is_discount_used( $code = null, $user = '', $code_id = 0 ) {
|
|
913 |
* @since 1.0
|
914 |
* @param string $code Discount Code
|
915 |
* @param string $user User info
|
|
|
916 |
* @return bool
|
917 |
*/
|
918 |
function edd_is_discount_valid( $code = '', $user = '', $set_error = true ) {
|
919 |
|
920 |
-
|
921 |
$return = false;
|
922 |
$discount_id = edd_get_discount_id_by_code( $code );
|
923 |
$user = trim( $user );
|
@@ -926,12 +960,12 @@ function edd_is_discount_valid( $code = '', $user = '', $set_error = true ) {
|
|
926 |
|
927 |
if ( $discount_id ) {
|
928 |
if (
|
929 |
-
edd_is_discount_active( $discount_id ) &&
|
930 |
-
edd_is_discount_started( $discount_id ) &&
|
931 |
-
!edd_is_discount_maxed_out( $discount_id ) &&
|
932 |
-
!edd_is_discount_used( $code, $user, $discount_id ) &&
|
933 |
-
edd_discount_is_min_met( $discount_id ) &&
|
934 |
-
edd_discount_product_reqs_met( $discount_id )
|
935 |
) {
|
936 |
$return = true;
|
937 |
}
|
384 |
* @since 2.6.11 Added $update parameter
|
385 |
* @param int $code_id
|
386 |
* @param bool $update Update the discount to expired if an one is found but has an active status
|
387 |
+
* @param bool $set_error Whether an error message be set in session
|
388 |
* @return bool
|
389 |
*/
|
390 |
+
function edd_is_discount_active( $code_id = null, $update = true, $set_error = true ) {
|
391 |
$discount = edd_get_discount( $code_id );
|
392 |
$return = false;
|
393 |
|
394 |
if ( $discount ) {
|
395 |
if ( edd_is_discount_expired( $code_id, $update ) ) {
|
396 |
+
if ( defined( 'DOING_AJAX' ) && $set_error ) {
|
397 |
edd_set_error( 'edd-discount-error', __( 'This discount is expired.', 'easy-digital-downloads' ) );
|
398 |
}
|
399 |
} elseif ( $discount->post_status == 'active' ) {
|
400 |
$return = true;
|
401 |
} else {
|
402 |
+
if( defined( 'DOING_AJAX' ) && $set_error ) {
|
403 |
edd_set_error( 'edd-discount-error', __( 'This discount is not active.', 'easy-digital-downloads' ) );
|
404 |
}
|
405 |
}
|
613 |
*
|
614 |
* @since 1.0
|
615 |
* @param int $code_id Discount ID
|
616 |
+
* @param bool $set_error Whether an error message be set in session
|
617 |
* @return bool Is discount started?
|
618 |
*/
|
619 |
+
function edd_is_discount_started( $code_id = null, $set_error = true ) {
|
620 |
$discount = edd_get_discount( $code_id );
|
621 |
$return = false;
|
622 |
|
629 |
if ( $start_date < current_time( 'timestamp' ) ) {
|
630 |
// Discount has pased the start date
|
631 |
$return = true;
|
632 |
+
} elseif( $set_error ) {
|
633 |
edd_set_error( 'edd-discount-error', __( 'This discount is not active yet.', 'easy-digital-downloads' ) );
|
634 |
}
|
635 |
} else {
|
648 |
*
|
649 |
* @since 1.0
|
650 |
* @param int $code_id Discount ID
|
651 |
+
* @param bool $set_error Whether an error message be set in session
|
652 |
* @return bool Is discount maxed out?
|
653 |
*/
|
654 |
+
function edd_is_discount_maxed_out( $code_id = null, $set_error = true ) {
|
655 |
$discount = edd_get_discount( $code_id );
|
656 |
$return = false;
|
657 |
|
658 |
if ( $discount ) {
|
659 |
+
|
660 |
$uses = edd_get_discount_uses( $code_id );
|
661 |
+
|
662 |
// Large number that will never be reached
|
663 |
$max_uses = edd_get_discount_max_uses( $code_id );
|
664 |
+
|
665 |
// Should never be greater than, but just in case
|
666 |
if ( $uses >= $max_uses && ! empty( $max_uses ) ) {
|
667 |
+
|
668 |
// Discount is maxed out
|
669 |
+
|
670 |
+
if( $set_error ) {
|
671 |
+
|
672 |
+
edd_set_error( 'edd-discount-error', __( 'This discount has reached its maximum usage.', 'easy-digital-downloads' ) );
|
673 |
+
|
674 |
+
}
|
675 |
+
|
676 |
$return = true;
|
677 |
+
|
678 |
}
|
679 |
}
|
680 |
|
688 |
*
|
689 |
* @since 1.1.7
|
690 |
* @param int $code_id Discount ID
|
691 |
+
* @param bool $set_error Whether an error message be set in session
|
692 |
* @return bool $return
|
693 |
*/
|
694 |
+
function edd_discount_is_min_met( $code_id = null, $set_error = true ) {
|
695 |
$discount = edd_get_discount( $code_id );
|
696 |
$return = false;
|
697 |
|
702 |
if ( (float) $cart_amount >= (float) $min ) {
|
703 |
// Minimum has been met
|
704 |
$return = true;
|
705 |
+
} elseif( $set_error ) {
|
706 |
edd_set_error( 'edd-discount-error', sprintf( __( 'Minimum order of %s not met.', 'easy-digital-downloads' ), edd_currency_filter( edd_format_amount( $min ) ) ) );
|
707 |
}
|
708 |
}
|
727 |
*
|
728 |
* @since 1.5
|
729 |
* @param int $code_id Discount ID
|
730 |
+
* @param bool $set_error Whether an error message be set in session
|
731 |
* @return bool $ret Are required products in the cart?
|
732 |
*/
|
733 |
+
function edd_discount_product_reqs_met( $code_id = null, $set_error = true ) {
|
734 |
$product_reqs = edd_get_discount_product_reqs( $code_id );
|
735 |
$condition = edd_get_discount_product_condition( $code_id );
|
736 |
$excluded_ps = edd_get_discount_excluded_products( $code_id );
|
766 |
|
767 |
foreach ( $product_reqs as $download_id ) {
|
768 |
if ( ! edd_item_in_cart( $download_id ) ) {
|
769 |
+
|
770 |
+
if( $set_error ) {
|
771 |
+
|
772 |
+
edd_set_error( 'edd-discount-error', __( 'The product requirements for this discount are not met.', 'easy-digital-downloads' ) );
|
773 |
+
|
774 |
+
}
|
775 |
+
|
776 |
$ret = false;
|
777 |
break;
|
778 |
}
|
790 |
|
791 |
}
|
792 |
|
793 |
+
if( ! $ret && $set_error ) {
|
794 |
|
795 |
edd_set_error( 'edd-discount-error', __( 'The product requirements for this discount are not met.', 'easy-digital-downloads' ) );
|
796 |
|
808 |
if( ! empty( $excluded_ps ) ) {
|
809 |
// Check that there are products other than excluded ones in the cart
|
810 |
if( $cart_ids == $excluded_ps ) {
|
811 |
+
|
812 |
+
if( $set_error ) {
|
813 |
+
|
814 |
+
edd_set_error( 'edd-discount-error', __( 'This discount is not valid for the cart contents.', 'easy-digital-downloads' ) );
|
815 |
+
|
816 |
+
}
|
817 |
+
|
818 |
$ret = false;
|
819 |
}
|
820 |
}
|
832 |
* @param string $code
|
833 |
* @param string $user
|
834 |
* @param int $code_id (since 1.5) ID of the discount code to check
|
835 |
+
* @param bool $set_error Whether an error message be set in session
|
836 |
*
|
837 |
* @return bool $return
|
838 |
*/
|
839 |
+
function edd_is_discount_used( $code = null, $user = '', $code_id = 0, $set_error = true ) {
|
840 |
|
841 |
$return = false;
|
842 |
|
919 |
|
920 |
if( in_array( strtolower( $code ), $discounts ) ) {
|
921 |
|
922 |
+
if( $set_error ) {
|
923 |
+
|
924 |
+
edd_set_error( 'edd-discount-error', __( 'This discount has already been redeemed.', 'easy-digital-downloads' ) );
|
925 |
+
|
926 |
+
}
|
927 |
+
|
928 |
$return = true;
|
929 |
break;
|
930 |
|
947 |
* @since 1.0
|
948 |
* @param string $code Discount Code
|
949 |
* @param string $user User info
|
950 |
+
* @param bool $set_error Whether an error message be set in session
|
951 |
* @return bool
|
952 |
*/
|
953 |
function edd_is_discount_valid( $code = '', $user = '', $set_error = true ) {
|
954 |
|
|
|
955 |
$return = false;
|
956 |
$discount_id = edd_get_discount_id_by_code( $code );
|
957 |
$user = trim( $user );
|
960 |
|
961 |
if ( $discount_id ) {
|
962 |
if (
|
963 |
+
edd_is_discount_active( $discount_id, true, $set_error ) &&
|
964 |
+
edd_is_discount_started( $discount_id, $set_error ) &&
|
965 |
+
! edd_is_discount_maxed_out( $discount_id, $set_error ) &&
|
966 |
+
! edd_is_discount_used( $code, $user, $discount_id, $set_error ) &&
|
967 |
+
edd_discount_is_min_met( $discount_id, $set_error ) &&
|
968 |
+
edd_discount_product_reqs_met( $discount_id, $set_error )
|
969 |
) {
|
970 |
$return = true;
|
971 |
}
|
includes/emails/class-edd-email-tags.php
CHANGED
@@ -427,7 +427,7 @@ function edd_email_tag_download_list( $payment_id ) {
|
|
427 |
if ( $show_links ) {
|
428 |
$download_list .= '<div>';
|
429 |
$file_url = edd_get_download_file_url( $payment_data['key'], $email, $filekey, $item['id'], $price_id );
|
430 |
-
$download_list .= '<a href="' .
|
431 |
$download_list .= '</div>';
|
432 |
} else {
|
433 |
$download_list .= '<div>';
|
427 |
if ( $show_links ) {
|
428 |
$download_list .= '<div>';
|
429 |
$file_url = edd_get_download_file_url( $payment_data['key'], $email, $filekey, $item['id'], $price_id );
|
430 |
+
$download_list .= '<a href="' . esc_url_raw( $file_url ) . '">' . edd_get_file_name( $file ) . '</a>';
|
431 |
$download_list .= '</div>';
|
432 |
} else {
|
433 |
$download_list .= '<div>';
|
includes/payments/class-edd-payment.php
CHANGED
@@ -598,6 +598,9 @@ class EDD_Payment {
|
|
598 |
* @return bool True of the save occurred, false if it failed or wasn't needed
|
599 |
*/
|
600 |
public function save() {
|
|
|
|
|
|
|
601 |
$saved = false;
|
602 |
|
603 |
if ( empty( $this->ID ) ) {
|
@@ -666,27 +669,35 @@ class EDD_Payment {
|
|
666 |
break;
|
667 |
|
668 |
case 'remove':
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
669 |
$log_args = array(
|
670 |
-
'
|
671 |
-
'
|
672 |
-
'
|
673 |
-
'
|
674 |
-
array(
|
675 |
-
'key' => '_edd_log_payment_id',
|
676 |
-
'value' => $this->ID,
|
677 |
-
'compare' => '=',
|
678 |
-
),
|
679 |
-
array(
|
680 |
-
'key' => '_edd_log_price_id',
|
681 |
-
'value' => $item['price_id'],
|
682 |
-
'compare' => '='
|
683 |
-
)
|
684 |
-
)
|
685 |
);
|
686 |
|
687 |
-
$found_logs =
|
688 |
-
|
689 |
-
|
|
|
|
|
|
|
690 |
}
|
691 |
|
692 |
if ( 'publish' === $this->status || 'complete' === $this->status || 'revoked' === $this->status ) {
|
598 |
* @return bool True of the save occurred, false if it failed or wasn't needed
|
599 |
*/
|
600 |
public function save() {
|
601 |
+
|
602 |
+
global $edd_logs;
|
603 |
+
|
604 |
$saved = false;
|
605 |
|
606 |
if ( empty( $this->ID ) ) {
|
669 |
break;
|
670 |
|
671 |
case 'remove':
|
672 |
+
|
673 |
+
$meta_query = array();
|
674 |
+
$meta_query[] = array(
|
675 |
+
'key' => '_edd_log_payment_id',
|
676 |
+
'value' => $this->ID,
|
677 |
+
'compare' => '=',
|
678 |
+
);
|
679 |
+
|
680 |
+
if( ! empty( $item['price_id'] ) || 0 === (int) $item['price_id'] ) {
|
681 |
+
$meta_query[] = array(
|
682 |
+
'key' => '_edd_log_price_id',
|
683 |
+
'value' => (int) $item['price_id'],
|
684 |
+
'compare' => '='
|
685 |
+
);
|
686 |
+
}
|
687 |
+
|
688 |
$log_args = array(
|
689 |
+
'post_parent' => $item['id'],
|
690 |
+
'posts_per_page' => $item['quantity'],
|
691 |
+
'meta_query' => $meta_query,
|
692 |
+
'log_type' => 'sale'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
693 |
);
|
694 |
|
695 |
+
$found_logs = $edd_logs->get_connected_logs( $log_args );
|
696 |
+
|
697 |
+
if( $found_logs ) {
|
698 |
+
foreach ( $found_logs as $log ) {
|
699 |
+
wp_delete_post( $log->ID, true );
|
700 |
+
}
|
701 |
}
|
702 |
|
703 |
if ( 'publish' === $this->status || 'complete' === $this->status || 'revoked' === $this->status ) {
|
includes/payments/functions.php
CHANGED
@@ -52,59 +52,49 @@ function edd_get_payments( $args = array() ) {
|
|
52 |
*/
|
53 |
function edd_get_payment_by( $field = '', $value = '' ) {
|
54 |
|
55 |
-
|
56 |
-
return false;
|
57 |
-
}
|
58 |
|
59 |
-
|
60 |
|
61 |
-
|
62 |
-
$payment = new EDD_Payment( $value );
|
63 |
-
$id = $payment->ID;
|
64 |
|
65 |
-
|
66 |
-
return false;
|
67 |
-
}
|
68 |
|
69 |
-
|
70 |
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
'meta_value' => $value,
|
75 |
-
'posts_per_page' => 1,
|
76 |
-
'fields' => 'ids',
|
77 |
-
) );
|
78 |
|
79 |
-
|
80 |
-
$payment = new EDD_Payment( $payment[0] );
|
81 |
-
}
|
82 |
|
83 |
-
|
|
|
84 |
|
85 |
-
|
86 |
-
$payment = edd_get_payments( array(
|
87 |
-
'meta_key' => '_edd_payment_number',
|
88 |
-
'meta_value' => $value,
|
89 |
-
'posts_per_page' => 1,
|
90 |
-
'fields' => 'ids',
|
91 |
-
) );
|
92 |
|
93 |
-
|
94 |
-
$
|
95 |
-
|
|
|
|
|
|
|
|
|
96 |
|
97 |
-
|
98 |
|
99 |
-
|
100 |
-
|
101 |
-
|
|
|
|
|
|
|
|
|
|
|
102 |
|
103 |
-
if( $payment ) {
|
104 |
-
return $payment;
|
105 |
}
|
106 |
|
107 |
-
return
|
108 |
}
|
109 |
|
110 |
/**
|
@@ -695,11 +685,14 @@ function edd_get_earnings_by_date( $day = null, $month_num, $year = null, $hour
|
|
695 |
'update_post_term_cache' => false,
|
696 |
'include_taxes' => $include_taxes,
|
697 |
);
|
698 |
-
|
|
|
699 |
$args['day'] = $day;
|
|
|
700 |
|
701 |
-
if ( ! empty( $hour ) )
|
702 |
$args['hour'] = $hour;
|
|
|
703 |
|
704 |
$args = apply_filters( 'edd_get_earnings_by_date_args', $args );
|
705 |
$cached = get_transient( 'edd_stats_earnings' );
|
52 |
*/
|
53 |
function edd_get_payment_by( $field = '', $value = '' ) {
|
54 |
|
55 |
+
$payment = false;
|
|
|
|
|
56 |
|
57 |
+
if( ! empty( $field ) && ! empty( $value ) ) {
|
58 |
|
59 |
+
switch( strtolower( $field ) ) {
|
|
|
|
|
60 |
|
61 |
+
case 'id':
|
|
|
|
|
62 |
|
63 |
+
$payment = new EDD_Payment( $value );
|
64 |
|
65 |
+
if( ! $payment->ID > 0 ) {
|
66 |
+
$payment = false;
|
67 |
+
}
|
|
|
|
|
|
|
|
|
68 |
|
69 |
+
break;
|
|
|
|
|
70 |
|
71 |
+
case 'key':
|
72 |
+
case 'payment_number':
|
73 |
|
74 |
+
global $wpdb;
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
+
$meta_key = ( 'key' == $field ) ? '_edd_payment_purchase_key' : '_edd_payment_number';
|
77 |
+
$payment_id = $wpdb->get_var( $wpdb->prepare(
|
78 |
+
"SELECT post_ID FROM {$wpdb->postmeta} WHERE meta_key = %s AND meta_value=%s",
|
79 |
+
$meta_key, $value
|
80 |
+
) );
|
81 |
+
|
82 |
+
if ( $payment_id ) {
|
83 |
|
84 |
+
$payment = new EDD_Payment( $payment_id );
|
85 |
|
86 |
+
if( ! $payment->ID > 0 ) {
|
87 |
+
$payment = false;
|
88 |
+
}
|
89 |
+
|
90 |
+
}
|
91 |
+
|
92 |
+
break;
|
93 |
+
}
|
94 |
|
|
|
|
|
95 |
}
|
96 |
|
97 |
+
return $payment;
|
98 |
}
|
99 |
|
100 |
/**
|
685 |
'update_post_term_cache' => false,
|
686 |
'include_taxes' => $include_taxes,
|
687 |
);
|
688 |
+
|
689 |
+
if ( ! empty( $day ) ) {
|
690 |
$args['day'] = $day;
|
691 |
+
}
|
692 |
|
693 |
+
if ( ! empty( $hour ) || $hour == 0 ) {
|
694 |
$args['hour'] = $hour;
|
695 |
+
}
|
696 |
|
697 |
$args = apply_filters( 'edd_get_earnings_by_date_args', $args );
|
698 |
$cached = get_transient( 'edd_stats_earnings' );
|
includes/process-download.php
CHANGED
@@ -90,6 +90,11 @@ function edd_process_download() {
|
|
90 |
|
91 |
$attached_file = get_attached_file( $attachment_id, false );
|
92 |
|
|
|
|
|
|
|
|
|
|
|
93 |
}
|
94 |
|
95 |
if( $attached_file ) {
|
@@ -110,6 +115,31 @@ function edd_process_download() {
|
|
110 |
// Allow the file to be altered before any headers are sent
|
111 |
$requested_file = apply_filters( 'edd_requested_file', $requested_file, $download_files, $args['file_key'] );
|
112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
// Record this file download in the log
|
114 |
$user_info = array();
|
115 |
$user_info['email'] = $args['email'];
|
@@ -152,24 +182,6 @@ function edd_process_download() {
|
|
152 |
exit;
|
153 |
}
|
154 |
|
155 |
-
if( 'x_sendfile' == $method && ( ! function_exists( 'apache_get_modules' ) || ! in_array( 'mod_xsendfile', apache_get_modules() ) ) ) {
|
156 |
-
// If X-Sendfile is selected but is not supported, fallback to Direct
|
157 |
-
$method = 'direct';
|
158 |
-
}
|
159 |
-
|
160 |
-
$file_details = parse_url( $requested_file );
|
161 |
-
$schemes = array( 'http', 'https' ); // Direct URL schemes
|
162 |
-
|
163 |
-
if ( ( ! isset( $file_details['scheme'] ) || ! in_array( $file_details['scheme'], $schemes ) ) && isset( $file_details['path'] ) && file_exists( $requested_file ) ) {
|
164 |
-
|
165 |
-
/**
|
166 |
-
* Download method is seto to Redirect in settings but an absolute path was provided
|
167 |
-
* We need to switch to a direct download in order for the file to download properly
|
168 |
-
*/
|
169 |
-
$method = 'direct';
|
170 |
-
|
171 |
-
}
|
172 |
-
|
173 |
switch( $method ) :
|
174 |
|
175 |
case 'redirect' :
|
@@ -838,3 +850,48 @@ function edd_set_requested_file_scheme( $requested_file, $download_files, $file_
|
|
838 |
|
839 |
}
|
840 |
add_filter( 'edd_requested_file', 'edd_set_requested_file_scheme', 10, 3 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
|
91 |
$attached_file = get_attached_file( $attachment_id, false );
|
92 |
|
93 |
+
// Confirm the file exists
|
94 |
+
if( ! file_exists( $attached_file ) ) {
|
95 |
+
$attached_file = false;
|
96 |
+
}
|
97 |
+
|
98 |
}
|
99 |
|
100 |
if( $attached_file ) {
|
115 |
// Allow the file to be altered before any headers are sent
|
116 |
$requested_file = apply_filters( 'edd_requested_file', $requested_file, $download_files, $args['file_key'] );
|
117 |
|
118 |
+
if( 'x_sendfile' == $method && ( ! function_exists( 'apache_get_modules' ) || ! in_array( 'mod_xsendfile', apache_get_modules() ) ) ) {
|
119 |
+
// If X-Sendfile is selected but is not supported, fallback to Direct
|
120 |
+
$method = 'direct';
|
121 |
+
}
|
122 |
+
|
123 |
+
$file_details = parse_url( $requested_file );
|
124 |
+
$schemes = array( 'http', 'https' ); // Direct URL schemes
|
125 |
+
|
126 |
+
if ( ( ! isset( $file_details['scheme'] ) || ! in_array( $file_details['scheme'], $schemes ) ) && isset( $file_details['path'] ) && file_exists( $requested_file ) ) {
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Download method is seto to Redirect in settings but an absolute path was provided
|
130 |
+
* We need to switch to a direct download in order for the file to download properly
|
131 |
+
*/
|
132 |
+
$method = 'direct';
|
133 |
+
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Allow extensions to run actions prior to recording the file download log entry
|
138 |
+
*
|
139 |
+
* @since 2.6.14
|
140 |
+
*/
|
141 |
+
do_action( 'edd_process_download_pre_record_log', $requested_file, $args, $method );
|
142 |
+
|
143 |
// Record this file download in the log
|
144 |
$user_info = array();
|
145 |
$user_info['email'] = $args['email'];
|
182 |
exit;
|
183 |
}
|
184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
switch( $method ) :
|
186 |
|
187 |
case 'redirect' :
|
850 |
|
851 |
}
|
852 |
add_filter( 'edd_requested_file', 'edd_set_requested_file_scheme', 10, 3 );
|
853 |
+
|
854 |
+
/**
|
855 |
+
* Perform a head request on file URLs before attempting to download to check if they are accessible.
|
856 |
+
*
|
857 |
+
* @since 2.6.14
|
858 |
+
* @param string $requested_file The Requested File
|
859 |
+
* @param array $args Arguments
|
860 |
+
* @param string $method The download mehtod being sed
|
861 |
+
* @return void
|
862 |
+
*/
|
863 |
+
function edd_check_file_url_head( $requested_file, $args, $method ) {
|
864 |
+
|
865 |
+
// If this is a file URL (not a path), perform a head request to determine if it's valid
|
866 |
+
if( filter_var( $requested_file, FILTER_VALIDATE_URL ) ) {
|
867 |
+
|
868 |
+
$valid = true;
|
869 |
+
$request = wp_remote_head( $requested_file );
|
870 |
+
|
871 |
+
if( is_wp_error( $request ) ) {
|
872 |
+
|
873 |
+
$valid = false;
|
874 |
+
$message = $request;
|
875 |
+
$title = __( 'Invalid file', 'easy-digital-downloads' );
|
876 |
+
|
877 |
+
}
|
878 |
+
|
879 |
+
if( 404 === wp_remote_retrieve_response_code( $request ) ) {
|
880 |
+
|
881 |
+
$valid = false;
|
882 |
+
$message = __( 'The requested file could not be found. Error 404.', 'easy-digital-downloads' );
|
883 |
+
$title = __( 'File not found', 'easy-digital-downloads' );
|
884 |
+
|
885 |
+
}
|
886 |
+
|
887 |
+
if( ! $valid ) {
|
888 |
+
|
889 |
+
do_action( 'edd_check_file_url_head_invalid', $requested_file, $args, $method );
|
890 |
+
wp_die( $message, $title, array( 'response' => 403 ) );
|
891 |
+
|
892 |
+
}
|
893 |
+
|
894 |
+
}
|
895 |
+
|
896 |
+
}
|
897 |
+
add_action( 'edd_process_download_pre_record_log', 'edd_check_file_url_head', 10, 3 );
|
includes/template-functions.php
CHANGED
@@ -189,7 +189,7 @@ function edd_get_purchase_link( $args = array() ) {
|
|
189 |
</span>
|
190 |
</span>
|
191 |
<?php endif; ?>
|
192 |
-
<?php if( ! $download->is_free( $args['price_id'] ) ): ?>
|
193 |
<?php if ( edd_display_tax_rate() && edd_prices_include_tax() ) {
|
194 |
echo '<span class="edd_purchase_tax_rate">' . sprintf( __( 'Includes %1$s% tax', 'easy-digital-downloads' ), edd_get_tax_rate() * 100 ) . '</span>';
|
195 |
} elseif ( edd_display_tax_rate() && ! edd_prices_include_tax() ) {
|
@@ -306,6 +306,31 @@ function edd_purchase_variable_pricing( $download_id = 0, $args = array() ) {
|
|
306 |
}
|
307 |
add_action( 'edd_purchase_link_top', 'edd_purchase_variable_pricing', 10, 2 );
|
308 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
309 |
/**
|
310 |
* Display the quantity field for a variable price when multi-purchase mode is enabled
|
311 |
*
|
189 |
</span>
|
190 |
</span>
|
191 |
<?php endif; ?>
|
192 |
+
<?php if( ! $download->is_free( $args['price_id'] ) && ! edd_download_is_tax_exclusive( $download->ID ) ): ?>
|
193 |
<?php if ( edd_display_tax_rate() && edd_prices_include_tax() ) {
|
194 |
echo '<span class="edd_purchase_tax_rate">' . sprintf( __( 'Includes %1$s% tax', 'easy-digital-downloads' ), edd_get_tax_rate() * 100 ) . '</span>';
|
195 |
} elseif ( edd_display_tax_rate() && ! edd_prices_include_tax() ) {
|
306 |
}
|
307 |
add_action( 'edd_purchase_link_top', 'edd_purchase_variable_pricing', 10, 2 );
|
308 |
|
309 |
+
/**
|
310 |
+
* Output schema markup for single price products.
|
311 |
+
*
|
312 |
+
* @since 2.6.14
|
313 |
+
* @param int $download_id The download being output.
|
314 |
+
* @return void
|
315 |
+
*/
|
316 |
+
function edd_purchase_link_single_pricing_schema( $download_id = 0, $args = array() ) {
|
317 |
+
|
318 |
+
// Bail if the product has variable pricing, or if we aren't showing schema data.
|
319 |
+
if ( edd_has_variable_prices( $download_id ) || ! edd_add_schema_microdata() ) {
|
320 |
+
return;
|
321 |
+
}
|
322 |
+
|
323 |
+
// Grab the information we need.
|
324 |
+
$download = new EDD_Download( $download_id );
|
325 |
+
?>
|
326 |
+
<span itemprop="offers" itemscope itemtype="http://schema.org/Offer">
|
327 |
+
<meta itemprop="price" content="<?php esc_attr_e( $download->price ); ?>" />
|
328 |
+
<meta itemprop="priceCurrency" content="<?php esc_attr_e( edd_get_currency() ); ?>" />
|
329 |
+
</span>
|
330 |
+
<?php
|
331 |
+
}
|
332 |
+
add_action( 'edd_purchase_link_top', 'edd_purchase_link_single_pricing_schema', 10, 2 );
|
333 |
+
|
334 |
/**
|
335 |
* Display the quantity field for a variable price when multi-purchase mode is enabled
|
336 |
*
|
readme.txt
CHANGED
@@ -5,8 +5,8 @@ Contributors: easydigitaldownloads, mordauk, sunnyratilal, chriscct7, section214
|
|
5 |
Donate link: https://easydigitaldownloads.com/donate/
|
6 |
Tags: download, downloads, e-store, eshop, digital downloads, e-commerce, wp-ecommerce, wp ecommerce
|
7 |
Requires at least: 4.0
|
8 |
-
Tested up to: 4.
|
9 |
-
Stable Tag: 2.6.
|
10 |
|
11 |
License: GNU Version 2 or Any Later Version
|
12 |
|
@@ -187,6 +187,23 @@ Yes, through the addition of one or more of the add-on payment gateways, you can
|
|
187 |
|
188 |
== Changelog ==
|
189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
= 2.6.13, November 21, 2016 =
|
191 |
* Fix: Custom payment meta items were not being saved correctly.
|
192 |
|
5 |
Donate link: https://easydigitaldownloads.com/donate/
|
6 |
Tags: download, downloads, e-store, eshop, digital downloads, e-commerce, wp-ecommerce, wp ecommerce
|
7 |
Requires at least: 4.0
|
8 |
+
Tested up to: 4.8
|
9 |
+
Stable Tag: 2.6.14
|
10 |
|
11 |
License: GNU Version 2 or Any Later Version
|
12 |
|
187 |
|
188 |
== Changelog ==
|
189 |
|
190 |
+
= 2.6.14, December 15, 2016 =
|
191 |
+
* New: Added hooks before and after cart on checkout screen
|
192 |
+
* New: Added support for user-specific locales
|
193 |
+
* Tweak: Improved performance of edd_get_payment_by(), making account pages faster
|
194 |
+
* Fix: Quantity not set on cart items when adding multiple price options to the cart at once
|
195 |
+
* Fix: Download links in email receipts over escaped, resulting in failed downloads
|
196 |
+
* Fix: December point plotted improperly on earnings / sales graphs
|
197 |
+
* Fix: Files still downloaded even if the file doesn't exist, resulting in a corrupted download file
|
198 |
+
* Fix: Non-formatted amount not set in data attribute of cart when discount codes applied
|
199 |
+
* Fix: Deleting an item from payment record does not delete the associated sale log
|
200 |
+
* Fix: This Week and Last Week reports not showing sale stats
|
201 |
+
* Fix: Calling edd_is_discount_valid() results in cart errors being set
|
202 |
+
* Fix: Earnings value doubled for Today report
|
203 |
+
* Fix: Price and currency not properly separated in schema microdata
|
204 |
+
* Fix: Tax exempt products still show tax rate on purchase buttons
|
205 |
+
* Fix: check_update() method is called twice in EDD_SL_Plugin_Updater class
|
206 |
+
|
207 |
= 2.6.13, November 21, 2016 =
|
208 |
* Fix: Custom payment meta items were not being saved correctly.
|
209 |
|
templates/history-downloads.php
CHANGED
@@ -52,7 +52,7 @@ if ( $purchases ) :
|
|
52 |
<td class="edd_download_download_files">
|
53 |
<?php
|
54 |
|
55 |
-
if (
|
56 |
|
57 |
if ( $download_files ) :
|
58 |
|
52 |
<td class="edd_download_download_files">
|
53 |
<?php
|
54 |
|
55 |
+
if ( 'publish' == $payment->post_status ) :
|
56 |
|
57 |
if ( $download_files ) :
|
58 |
|