Skip to content

Commit

Permalink
Merge pull request #7764 from easydigitaldownloads/release/2.9.23
Browse files Browse the repository at this point in the history
Release/2.9.23
  • Loading branch information
cklosowski committed Apr 20, 2020
2 parents 8781ddd + 89b619a commit dfd13fc
Show file tree
Hide file tree
Showing 9 changed files with 197 additions and 111 deletions.
6 changes: 3 additions & 3 deletions easy-digital-downloads.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: The easiest way to sell digital products with WordPress.
* Author: Easy Digital Downloads
* Author URI: https://easydigitaldownloads.com
* Version: 2.9.22
* Version: 2.9.23
* Text Domain: easy-digital-downloads
* Domain Path: languages
*
Expand All @@ -25,7 +25,7 @@
* @package EDD
* @category Core
* @author Pippin Williamson
* @version 2.9.22
* @version 2.9.23
*/

// Exit if accessed directly.
Expand Down Expand Up @@ -206,7 +206,7 @@ private function setup_constants() {

// Plugin version.
if ( ! defined( 'EDD_VERSION' ) ) {
define( 'EDD_VERSION', '2.9.22' );
define( 'EDD_VERSION', '2.9.23' );
}

// Plugin Folder Path.
Expand Down
25 changes: 0 additions & 25 deletions includes/admin/upload-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,28 +163,3 @@ function edd_get_htaccess_rules( $method = false ) {
$rules = apply_filters( 'edd_protected_directory_htaccess_rules', $rules, $method );
return $rules;
}


// For installs on pre WP 3.6
if( ! function_exists( 'wp_is_writable' ) ) {

/**
* Determine if a directory is writable.
*
* This function is used to work around certain ACL issues
* in PHP primarily affecting Windows Servers.
*
* @see win_is_writable()
*
* @since 3.6.0
*
* @param string $path
* @return bool
*/
function wp_is_writable( $path ) {
if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) )
return win_is_writable( $path );
else
return @is_writable( $path );
}
}
48 changes: 43 additions & 5 deletions includes/class-edd-db-customers.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,24 @@ public function get_customer_by( $field = 'id', $value = 0 ) {
return NULL;
}

/**
* Filters the Customer before querying the database.
*
* Return a non-null value to bypass the default query and return early.
*
* @since 2.9.23
*
* @param mixed|null $customer Customer to return instead. Default null to use default method.
* @param string $field The field to retrieve by.
* @param mixed $value The value to search by.
* @param EDD_DB_Customers $edd_customers_db Customer database class.
*/
$found = apply_filters( 'edd_pre_get_customer', null, $field, $value, $this );

if ( null !== $found ) {
return $found;
}

if ( 'id' == $field || 'user_id' == $field ) {
// Make sure the value is numeric to avoid casting objects, for example,
// to int 1.
Expand Down Expand Up @@ -421,11 +439,31 @@ public function get_customer_by( $field = 'id', $value = 0 ) {

$results = $query->query( $args );

if ( empty( $results ) ) {
return false;
}

return array_shift( $results );
$customer = ! empty( $results ) ? array_shift( $results ) : false;

/**
* Filters the single Customer retrieved from the database based on field.
*
* @since 2.9.23
*
* @param object|false $customer Customer query result. False if no Customer is found.
* @param array $args Arguments used to query the Customer.
* @param EDD_DB_Customers $edd_customers_db Customer database class.
*/
$customer = apply_filters( "edd_get_customer_by_{$field}", $customer, $args, $this );

/**
* Filters the single Customer retrieved from the database.
*
* @since 2.9.23
*
* @param object|false $customer Customer query result. False if no Customer is found.
* @param array $args Arguments used to query the Customer.
* @param EDD_DB_Customers $edd_customers_db Customer database class.
*/
$customer = apply_filters( 'edd_get_customer', $customer, $args, $this );

return $customer;
}

/**
Expand Down
65 changes: 35 additions & 30 deletions includes/download-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -920,40 +920,45 @@ function edd_is_file_at_download_limit( $download_id = 0, $payment_id = 0, $file
// Assume that the file download limit has not been hit.
$ret = false;
$download_limit = edd_get_file_download_limit( $download_id );
$unlimited_purchase = edd_payment_has_unlimited_downloads( $payment_id );

if ( ! empty( $download_limit ) && empty( $unlimited_purchase ) ) {

// Checks to see if at limit
$logs = new EDD_Logging();

$meta_query = array(
'relation' => 'AND',
array(
'key' => '_edd_log_file_id',
'value' => (int) $file_id
),
array(
'key' => '_edd_log_payment_id',
'value' => (int) $payment_id
),
array(
'key' => '_edd_log_price_id',
'value' => (int) $price_id
)
);

$download_count = $logs->get_log_count( $download_id, 'file_download', $meta_query );
if ( ! empty( $download_limit ) ) {

// The store does not have unlimited downloads, does this payment?
$unlimited_purchase = edd_payment_has_unlimited_downloads( $payment_id );

if ( empty( $unlimited_purchase ) ) {

// Get the file download count.
$logs = new EDD_Logging();

$meta_query = array(
'relation' => 'AND',
array(
'key' => '_edd_log_file_id',
'value' => (int) $file_id,
),
array(
'key' => '_edd_log_payment_id',
'value' => (int) $payment_id,
),
array(
'key' => '_edd_log_price_id',
'value' => (int) $price_id,
)
);

$download_count = $logs->get_log_count( $download_id, 'file_download', $meta_query );

if ( $download_count >= $download_limit ) {
$ret = true;
if ( $download_count >= $download_limit ) {
$ret = true;

// Check to make sure the limit isn't overwritten
// A limit is overwritten when purchase receipt is resent
$limit_override = edd_get_file_download_limit_override( $download_id, $payment_id );
// Check to make sure the limit isn't overwritten.
// A limit is overwritten when purchase receipt is resent.
$limit_override = edd_get_file_download_limit_override( $download_id, $payment_id );

if ( ! empty( $limit_override ) && $download_count < $limit_override ) {
$ret = false;
if ( ! empty( $limit_override ) && $download_count < $limit_override ) {
$ret = false;
}
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions includes/payments/class-edd-payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -1412,9 +1412,10 @@ public function modify_cart_item( $cart_index = false, $args = array() ) {
$merged_item = array_merge( $current_args, $args );

// Format the item_price correctly now
$merged_item['item_price'] = edd_sanitize_amount( $merged_item['item_price'] );
$new_subtotal = floatval( $merged_item['item_price'] ) * $merged_item['quantity'];
$merged_item['price'] = edd_prices_include_tax() ? $new_subtotal : $new_subtotal + $merged_item['tax'];
$merged_item['item_price'] = edd_sanitize_amount( $merged_item['item_price'] );
$new_subtotal = floatval( $merged_item['item_price'] ) * $merged_item['quantity'];
$merged_item['tax'] = edd_sanitize_amount( $merged_item['tax'] );
$merged_item['price'] = edd_prices_include_tax() ? $new_subtotal : $new_subtotal + $merged_item['tax'];

// Sort the current and new args, and checksum them. If no changes. No need to fire a modification.
ksort( $current_args );
Expand Down
4 changes: 2 additions & 2 deletions includes/template-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ function edd_variable_price_quantity_field( $key, $price, $download_id ) {
function edd_before_download_content( $content ) {
global $post;

if ( $post && $post->post_type == 'download' && is_singular( 'download' ) && is_main_query() && !post_password_required() ) {
if ( $post && $post instanceof WP_Post && 'download' === $post->post_type && is_singular( 'download' ) && is_main_query() && ! post_password_required() ) {
ob_start();
do_action( 'edd_before_download_content', $post->ID );
$content = ob_get_clean() . $content;
Expand Down Expand Up @@ -1178,7 +1178,7 @@ function edd_downloads_pagination( $atts, $downloads, $query ) {
* Build pagination
*
* @since 2.9.8
*
*
* @param array $args The arguments used to build the pagination.
*/
function edd_pagination( $args = array() ) {
Expand Down
8 changes: 4 additions & 4 deletions languages/easy-digital-downloads.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# This file is distributed under the same license as the Easy Digital Downloads package.
msgid ""
msgstr ""
"Project-Id-Version: Easy Digital Downloads 2.9.22\n"
"Project-Id-Version: Easy Digital Downloads 2.9.23\n"
"Report-Msgid-Bugs-To: https://easydigitaldownloads.com/\n"
"POT-Creation-Date: 2020-03-12 23:02:26+00:00\n"
"POT-Creation-Date: 2020-04-20 18:58:41+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
Expand Down Expand Up @@ -93,7 +93,7 @@ msgstr ""
#: includes/cart/class-edd-cart.php:1425 includes/cart/class-edd-cart.php:1439
#: includes/class-edd-license-handler.php:309
#: includes/deprecated-functions.php:517 includes/deprecated-functions.php:532
#: includes/deprecated-functions.php:542 includes/download-functions.php:1261
#: includes/deprecated-functions.php:542 includes/download-functions.php:1266
#: includes/emails/actions.php:53 includes/emails/template.php:243
#: includes/error-tracking.php:40 includes/gateways/functions.php:221
#: includes/gateways/manual.php:33 includes/gateways/paypal-standard.php:168
Expand Down Expand Up @@ -6477,7 +6477,7 @@ msgstr ""
msgid "Sorry but you have hit your download limit for this file."
msgstr ""

#: includes/deprecated-functions.php:532 includes/download-functions.php:1261
#: includes/deprecated-functions.php:532 includes/download-functions.php:1266
msgid "Sorry but your download link has expired."
msgstr ""

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "easy-digital-downloads",
"version": "2.9.22",
"version": "2.9.23",
"private": true,
"devDependencies": {
"grunt": "^1.0.4",
Expand Down
Loading

0 comments on commit dfd13fc

Please sign in to comment.