Easy Digital Downloads - Version 2.9.23

Version Description

Download this release

Release Info

Developer cklosows
Plugin Icon 128x128 Easy Digital Downloads
Version 2.9.23
Comparing to
See all releases

Code changes from version 2.9.22 to 2.9.23

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.9.22
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.9.22
29
  */
30
 
31
  // Exit if accessed directly.
@@ -206,7 +206,7 @@ final class Easy_Digital_Downloads {
206
 
207
  // Plugin version.
208
  if ( ! defined( 'EDD_VERSION' ) ) {
209
- define( 'EDD_VERSION', '2.9.22' );
210
  }
211
 
212
  // Plugin Folder Path.
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.9.23
9
  * Text Domain: easy-digital-downloads
10
  * Domain Path: languages
11
  *
25
  * @package EDD
26
  * @category Core
27
  * @author Pippin Williamson
28
+ * @version 2.9.23
29
  */
30
 
31
  // Exit if accessed directly.
206
 
207
  // Plugin version.
208
  if ( ! defined( 'EDD_VERSION' ) ) {
209
+ define( 'EDD_VERSION', '2.9.23' );
210
  }
211
 
212
  // Plugin Folder Path.
includes/admin/upload-functions.php CHANGED
@@ -163,28 +163,3 @@ function edd_get_htaccess_rules( $method = false ) {
163
  $rules = apply_filters( 'edd_protected_directory_htaccess_rules', $rules, $method );
164
  return $rules;
165
  }
166
-
167
-
168
- // For installs on pre WP 3.6
169
- if( ! function_exists( 'wp_is_writable' ) ) {
170
-
171
- /**
172
- * Determine if a directory is writable.
173
- *
174
- * This function is used to work around certain ACL issues
175
- * in PHP primarily affecting Windows Servers.
176
- *
177
- * @see win_is_writable()
178
- *
179
- * @since 3.6.0
180
- *
181
- * @param string $path
182
- * @return bool
183
- */
184
- function wp_is_writable( $path ) {
185
- if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) )
186
- return win_is_writable( $path );
187
- else
188
- return @is_writable( $path );
189
- }
190
- }
163
  $rules = apply_filters( 'edd_protected_directory_htaccess_rules', $rules, $method );
164
  return $rules;
165
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-edd-db-customers.php CHANGED
@@ -374,6 +374,24 @@ class EDD_DB_Customers extends EDD_DB {
374
  return NULL;
375
  }
376
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
377
  if ( 'id' == $field || 'user_id' == $field ) {
378
  // Make sure the value is numeric to avoid casting objects, for example,
379
  // to int 1.
@@ -421,11 +439,31 @@ class EDD_DB_Customers extends EDD_DB {
421
 
422
  $results = $query->query( $args );
423
 
424
- if ( empty( $results ) ) {
425
- return false;
426
- }
427
-
428
- return array_shift( $results );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
429
  }
430
 
431
  /**
374
  return NULL;
375
  }
376
 
377
+ /**
378
+ * Filters the Customer before querying the database.
379
+ *
380
+ * Return a non-null value to bypass the default query and return early.
381
+ *
382
+ * @since 2.9.23
383
+ *
384
+ * @param mixed|null $customer Customer to return instead. Default null to use default method.
385
+ * @param string $field The field to retrieve by.
386
+ * @param mixed $value The value to search by.
387
+ * @param EDD_DB_Customers $edd_customers_db Customer database class.
388
+ */
389
+ $found = apply_filters( 'edd_pre_get_customer', null, $field, $value, $this );
390
+
391
+ if ( null !== $found ) {
392
+ return $found;
393
+ }
394
+
395
  if ( 'id' == $field || 'user_id' == $field ) {
396
  // Make sure the value is numeric to avoid casting objects, for example,
397
  // to int 1.
439
 
440
  $results = $query->query( $args );
441
 
442
+ $customer = ! empty( $results ) ? array_shift( $results ) : false;
443
+
444
+ /**
445
+ * Filters the single Customer retrieved from the database based on field.
446
+ *
447
+ * @since 2.9.23
448
+ *
449
+ * @param object|false $customer Customer query result. False if no Customer is found.
450
+ * @param array $args Arguments used to query the Customer.
451
+ * @param EDD_DB_Customers $edd_customers_db Customer database class.
452
+ */
453
+ $customer = apply_filters( "edd_get_customer_by_{$field}", $customer, $args, $this );
454
+
455
+ /**
456
+ * Filters the single Customer retrieved from the database.
457
+ *
458
+ * @since 2.9.23
459
+ *
460
+ * @param object|false $customer Customer query result. False if no Customer is found.
461
+ * @param array $args Arguments used to query the Customer.
462
+ * @param EDD_DB_Customers $edd_customers_db Customer database class.
463
+ */
464
+ $customer = apply_filters( 'edd_get_customer', $customer, $args, $this );
465
+
466
+ return $customer;
467
  }
468
 
469
  /**
includes/download-functions.php CHANGED
@@ -920,40 +920,45 @@ function edd_is_file_at_download_limit( $download_id = 0, $payment_id = 0, $file
920
  // Assume that the file download limit has not been hit.
921
  $ret = false;
922
  $download_limit = edd_get_file_download_limit( $download_id );
923
- $unlimited_purchase = edd_payment_has_unlimited_downloads( $payment_id );
924
-
925
- if ( ! empty( $download_limit ) && empty( $unlimited_purchase ) ) {
926
-
927
- // Checks to see if at limit
928
- $logs = new EDD_Logging();
929
-
930
- $meta_query = array(
931
- 'relation' => 'AND',
932
- array(
933
- 'key' => '_edd_log_file_id',
934
- 'value' => (int) $file_id
935
- ),
936
- array(
937
- 'key' => '_edd_log_payment_id',
938
- 'value' => (int) $payment_id
939
- ),
940
- array(
941
- 'key' => '_edd_log_price_id',
942
- 'value' => (int) $price_id
943
- )
944
- );
945
 
946
- $download_count = $logs->get_log_count( $download_id, 'file_download', $meta_query );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
947
 
948
- if ( $download_count >= $download_limit ) {
949
- $ret = true;
950
 
951
- // Check to make sure the limit isn't overwritten
952
- // A limit is overwritten when purchase receipt is resent
953
- $limit_override = edd_get_file_download_limit_override( $download_id, $payment_id );
954
 
955
- if ( ! empty( $limit_override ) && $download_count < $limit_override ) {
956
- $ret = false;
 
957
  }
958
  }
959
  }
920
  // Assume that the file download limit has not been hit.
921
  $ret = false;
922
  $download_limit = edd_get_file_download_limit( $download_id );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
923
 
924
+ if ( ! empty( $download_limit ) ) {
925
+
926
+ // The store does not have unlimited downloads, does this payment?
927
+ $unlimited_purchase = edd_payment_has_unlimited_downloads( $payment_id );
928
+
929
+ if ( empty( $unlimited_purchase ) ) {
930
+
931
+ // Get the file download count.
932
+ $logs = new EDD_Logging();
933
+
934
+ $meta_query = array(
935
+ 'relation' => 'AND',
936
+ array(
937
+ 'key' => '_edd_log_file_id',
938
+ 'value' => (int) $file_id,
939
+ ),
940
+ array(
941
+ 'key' => '_edd_log_payment_id',
942
+ 'value' => (int) $payment_id,
943
+ ),
944
+ array(
945
+ 'key' => '_edd_log_price_id',
946
+ 'value' => (int) $price_id,
947
+ )
948
+ );
949
+
950
+ $download_count = $logs->get_log_count( $download_id, 'file_download', $meta_query );
951
 
952
+ if ( $download_count >= $download_limit ) {
953
+ $ret = true;
954
 
955
+ // Check to make sure the limit isn't overwritten.
956
+ // A limit is overwritten when purchase receipt is resent.
957
+ $limit_override = edd_get_file_download_limit_override( $download_id, $payment_id );
958
 
959
+ if ( ! empty( $limit_override ) && $download_count < $limit_override ) {
960
+ $ret = false;
961
+ }
962
  }
963
  }
964
  }
includes/payments/class-edd-payment.php CHANGED
@@ -1412,9 +1412,10 @@ class EDD_Payment {
1412
  $merged_item = array_merge( $current_args, $args );
1413
 
1414
  // Format the item_price correctly now
1415
- $merged_item['item_price'] = edd_sanitize_amount( $merged_item['item_price'] );
1416
- $new_subtotal = floatval( $merged_item['item_price'] ) * $merged_item['quantity'];
1417
- $merged_item['price'] = edd_prices_include_tax() ? $new_subtotal : $new_subtotal + $merged_item['tax'];
 
1418
 
1419
  // Sort the current and new args, and checksum them. If no changes. No need to fire a modification.
1420
  ksort( $current_args );
1412
  $merged_item = array_merge( $current_args, $args );
1413
 
1414
  // Format the item_price correctly now
1415
+ $merged_item['item_price'] = edd_sanitize_amount( $merged_item['item_price'] );
1416
+ $new_subtotal = floatval( $merged_item['item_price'] ) * $merged_item['quantity'];
1417
+ $merged_item['tax'] = edd_sanitize_amount( $merged_item['tax'] );
1418
+ $merged_item['price'] = edd_prices_include_tax() ? $new_subtotal : $new_subtotal + $merged_item['tax'];
1419
 
1420
  // Sort the current and new args, and checksum them. If no changes. No need to fire a modification.
1421
  ksort( $current_args );
includes/template-functions.php CHANGED
@@ -445,7 +445,7 @@ add_action( 'edd_after_price_option', 'edd_variable_price_quantity_field', 10, 3
445
  function edd_before_download_content( $content ) {
446
  global $post;
447
 
448
- if ( $post && $post->post_type == 'download' && is_singular( 'download' ) && is_main_query() && !post_password_required() ) {
449
  ob_start();
450
  do_action( 'edd_before_download_content', $post->ID );
451
  $content = ob_get_clean() . $content;
@@ -1178,7 +1178,7 @@ add_action( 'edd_downloads_list_after', 'edd_downloads_pagination', 10, 3 );
1178
  * Build pagination
1179
  *
1180
  * @since 2.9.8
1181
- *
1182
  * @param array $args The arguments used to build the pagination.
1183
  */
1184
  function edd_pagination( $args = array() ) {
445
  function edd_before_download_content( $content ) {
446
  global $post;
447
 
448
+ if ( $post && $post instanceof WP_Post && 'download' === $post->post_type && is_singular( 'download' ) && is_main_query() && ! post_password_required() ) {
449
  ob_start();
450
  do_action( 'edd_before_download_content', $post->ID );
451
  $content = ob_get_clean() . $content;
1178
  * Build pagination
1179
  *
1180
  * @since 2.9.8
1181
+ *
1182
  * @param array $args The arguments used to build the pagination.
1183
  */
1184
  function edd_pagination( $args = array() ) {
languages/easy-digital-downloads.pot CHANGED
@@ -2,9 +2,9 @@
2
  # This file is distributed under the same license as the Easy Digital Downloads package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Easy Digital Downloads 2.9.22\n"
6
  "Report-Msgid-Bugs-To: https://easydigitaldownloads.com/\n"
7
- "POT-Creation-Date: 2020-03-12 23:02:26+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -93,7 +93,7 @@ msgstr ""
93
  #: includes/cart/class-edd-cart.php:1425 includes/cart/class-edd-cart.php:1439
94
  #: includes/class-edd-license-handler.php:309
95
  #: includes/deprecated-functions.php:517 includes/deprecated-functions.php:532
96
- #: includes/deprecated-functions.php:542 includes/download-functions.php:1261
97
  #: includes/emails/actions.php:53 includes/emails/template.php:243
98
  #: includes/error-tracking.php:40 includes/gateways/functions.php:221
99
  #: includes/gateways/manual.php:33 includes/gateways/paypal-standard.php:168
@@ -6477,7 +6477,7 @@ msgstr ""
6477
  msgid "Sorry but you have hit your download limit for this file."
6478
  msgstr ""
6479
 
6480
- #: includes/deprecated-functions.php:532 includes/download-functions.php:1261
6481
  msgid "Sorry but your download link has expired."
6482
  msgstr ""
6483
 
2
  # This file is distributed under the same license as the Easy Digital Downloads package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Easy Digital Downloads 2.9.23\n"
6
  "Report-Msgid-Bugs-To: https://easydigitaldownloads.com/\n"
7
+ "POT-Creation-Date: 2020-04-20 22:34:54+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
93
  #: includes/cart/class-edd-cart.php:1425 includes/cart/class-edd-cart.php:1439
94
  #: includes/class-edd-license-handler.php:309
95
  #: includes/deprecated-functions.php:517 includes/deprecated-functions.php:532
96
+ #: includes/deprecated-functions.php:542 includes/download-functions.php:1266
97
  #: includes/emails/actions.php:53 includes/emails/template.php:243
98
  #: includes/error-tracking.php:40 includes/gateways/functions.php:221
99
  #: includes/gateways/manual.php:33 includes/gateways/paypal-standard.php:168
6477
  msgid "Sorry but you have hit your download limit for this file."
6478
  msgstr ""
6479
 
6480
+ #: includes/deprecated-functions.php:532 includes/download-functions.php:1266
6481
  msgid "Sorry but your download link has expired."
6482
  msgstr ""
6483
 
readme.txt CHANGED
@@ -7,7 +7,7 @@ Tags: ecommerce, sell, checkout, payments, stripe
7
  Requires at least: 4.4
8
  Tested up to: 5.4
9
  Requires PHP: 5.3
10
- Stable Tag: 2.9.22
11
  License: GNU Version 2 or Any Later Version
12
 
13
  Sell your digital products the simple way. Easily build an online store complete with a cart system, checkout forms, reports, coupons, and more!
@@ -249,6 +249,13 @@ For most stores, we recommend using the Stripe Payment Gateway.
249
  9. Checkout screen
250
 
251
  == Changelog ==
 
 
 
 
 
 
 
252
  = 2.9.22, March 12, 2020 =
253
  * Fix: Corrected an issue that caused custom translation files from being ignored when official translations are loaded.
254
  * Fix: The default return condition when determining if a purchase has reached its download limit was erroneously removed.
7
  Requires at least: 4.4
8
  Tested up to: 5.4
9
  Requires PHP: 5.3
10
+ Stable Tag: 2.9.23
11
  License: GNU Version 2 or Any Later Version
12
 
13
  Sell your digital products the simple way. Easily build an online store complete with a cart system, checkout forms, reports, coupons, and more!
249
  9. Checkout screen
250
 
251
  == Changelog ==
252
+ = 2.9.23, April 20, 2020 =
253
+ * Fix: There was a performance issue that caused file download logs to be queried when they did not need to be.
254
+ * Fix: When using PHP 7.3+, a notice could be thrown related to a non-well formed numeric value.
255
+ * Fix: Removed the legacy (and unused) wp_is_writable shim.
256
+ * Fix: When loading a custom template or post type related to downloads, a PHP notice about getting the post_type of a non-object could be thrown.
257
+ * Dev: Added pre/post filters into the get_customer_by method.
258
+
259
  = 2.9.22, March 12, 2020 =
260
  * Fix: Corrected an issue that caused custom translation files from being ignored when official translations are loaded.
261
  * Fix: The default return condition when determining if a purchase has reached its download limit was erroneously removed.