Skip to content

Commit

Permalink
Merge pull request #9655 from awesomemotive/release/3.1.3
Browse files Browse the repository at this point in the history
Adding 3.1.3 release changes in advance of the release
  • Loading branch information
cklosowski authored Jun 28, 2023
2 parents a77bb39 + d25a9e1 commit ac99f24
Show file tree
Hide file tree
Showing 38 changed files with 816 additions and 488 deletions.
6 changes: 6 additions & 0 deletions assets/css/admin/downloads/_duplicate.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#edd-duplicate-action {
& ~ #publishing-action {
position: relative;
top: -10px;
}
}
1 change: 1 addition & 0 deletions assets/css/admin/downloads/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
@import "product_settings";
@import "repeatable_row";
@import "upload";
@import "duplicate";
2 changes: 1 addition & 1 deletion assets/css/edd-admin-rtl.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/css/edd-admin.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/edd-ajax.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/edd-checkout-global.js

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions assets/js/frontend/checkout/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,16 @@ export function recalculateTaxes( state ) {
return;
} // Taxes not enabled

let tax_amount_row = document.getElementsByClassName( 'edd_cart_tax' );
const cart = document.getElementById( 'edd_checkout_cart' );
let tax_amount_row = cart.getElementsByClassName( 'edd_cart_tax' );

// See if the tax_amount_row has an edd-loading-ajax child before adding another one.
if ( tax_amount_row.length > 0 && ! tax_amount_row[0].querySelector( '.edd-recalculate-taxes-loading' ) ) {
tax_amount_row = tax_amount_row[0];
const taxes_loading = document.createElement('span');
const current_tax_amount = document.getElementsByClassName( 'edd_cart_tax_amount' );
if ( current_tax_amount.length > 0 ) {
tax_amount_row.removeChild( current_tax_amount[0] );
const current_tax_amount = tax_amount_row.getElementsByClassName( 'edd_cart_tax_amount' );
for ( let i = 0; i < current_tax_amount.length; i++ ) {
current_tax_amount[ i ].remove();
}
taxes_loading.classList.add( 'edd-loading-ajax', 'edd-recalculate-taxes-loading', 'edd-loading' );
tax_amount_row.appendChild( taxes_loading );
Expand Down
4 changes: 2 additions & 2 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: 3.1.2
* Version: 3.1.3
* Text Domain: easy-digital-downloads
* Domain Path: /languages
* Requires at least: 5.4
Expand All @@ -27,7 +27,7 @@
* @package EDD
* @category Core
* @author Easy Digital Downloads
* @version 3.1.2
* @version 3.1.3
*/

// Exit if accessed directly.
Expand Down
32 changes: 24 additions & 8 deletions includes/admin/reporting/export/class-batch-export-sales.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public function csv_cols() {
'download' => edd_get_label_singular(),
'quantity' => __( 'Quantity', 'easy-digital-downloads' ),
'amount' => __( 'Item Amount', 'easy-digital-downloads' ),
'payment_id' => __( 'Payment ID', 'easy-digital-downloads' ),
'currency' => __( 'Currency', 'easy-digital-downloads' ),
'order_id' => __( 'Order ID', 'easy-digital-downloads' ),
'price_id' => __( 'Price ID', 'easy-digital-downloads' ),
'date' => __( 'Date', 'easy-digital-downloads' ),
);
Expand All @@ -72,17 +73,31 @@ public function get_data() {
$args = array_merge(
$this->get_order_item_args(),
array(
'number' => 30,
'offset' => ( $this->step * 30 ) - 30,
'order' => 'ASC',
'number' => 30,
'offset' => ( $this->step * 30 ) - 30,
'order' => 'ASC'
)
);

$items = edd_get_order_items( $args );

foreach ( $items as $item ) {

if ( 'refunded' === $item->status ) {
continue;
}

/** @var EDD\Orders\Order_Item $item */
$order = edd_get_order( $item->order_id );
$order = edd_get_order( $item->order_id );

// If the item has been partially refunded, we need to calculate the amount
$amount = array_reduce(
$item->get_refunded_items(),
function( $total, $refund_item ) {
return $total + $refund_item->total;
},
$item->total
);

$data[] = array(
'ID' => $item->product_id,
Expand All @@ -92,8 +107,9 @@ public function get_data() {
'name' => edd_get_customer_field( $order->customer_id, 'name' ),
'download' => $item->product_name,
'quantity' => $item->quantity,
'amount' => $order->total,
'payment_id' => $order->id,
'amount' => edd_format_amount( $amount ),
'currency' => $order->currency,
'order_id' => $order->id,
'price_id' => $item->price_id,
'date' => $order->date_created,
);
Expand Down Expand Up @@ -155,7 +171,7 @@ private function get_order_item_args() {

public function set_properties( $request ) {
$this->start = isset( $request['sales-export-start'] ) ? sanitize_text_field( $request['sales-export-start'] ) : '';
$this->end = isset( $request['sales-export-end'] ) ? sanitize_text_field( $request['sales-export-end'] ) . ' 23:59:59' : '';
$this->end = isset( $request['sales-export-end'] ) ? sanitize_text_field( $request['sales-export-end'] ) : '';
$this->download_id = isset( $request['download_id'] ) ? absint( $request['download_id'] ) : 0;
$this->orders = $this->get_orders();
}
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/settings/register-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -2800,7 +2800,7 @@ function edd_recapture_callback($args) {
* @return void
*/
function edd_tax_rates_callback( $args ) {
$rates = edd_get_tax_rates( array( 'number' => 9999 ), OBJECT );
$rates = edd_get_tax_rates( array(), OBJECT );

wp_enqueue_script( 'edd-admin-tax-rates' );
wp_enqueue_style( 'edd-admin-tax-rates' );
Expand Down
2 changes: 1 addition & 1 deletion includes/class-easy-digital-downloads.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ private function setup_constants() {

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

// Make sure CAL_GREGORIAN is defined.
Expand Down
2 changes: 1 addition & 1 deletion includes/class-edd-download.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public function get_prices() {
* @param array $prices The array of variables prices.
* @param int|string The ID of the download.
*/
return (array) apply_filters( 'edd_get_variable_prices', $this->prices, $this->ID );
return array_filter( (array) apply_filters( 'edd_get_variable_prices', $this->prices, $this->ID ) );
}

/**
Expand Down
10 changes: 6 additions & 4 deletions includes/class-edd-html-elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,12 @@ public function product_dropdown( $args = array() ) {
// If showing variations, add them to the list.
if ( $args['variations'] ) {
$prices = edd_get_variable_prices( $product->ID );
foreach ( $prices as $key => $value ) {
$name = ! empty( $value['name'] ) ? $value['name'] : '';
if ( $name ) {
$options[ absint( $product->ID ) . '_' . $key ] = esc_html( $product->post_title . ': ' . $name );
if ( ! empty( $prices ) ) {
foreach ( $prices as $key => $value ) {
$name = ! empty( $value['name'] ) ? $value['name'] : '';
if ( $name ) {
$options[ absint( $product->ID ) . '_' . $key ] = esc_html( $product->post_title . ': ' . $name );
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions includes/class-edd-license-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ public function settings( $settings ) {
'is_valid_license_option' => $this->item_shortname . '_license_active',
'item_id' => $this->item_id,
'api_url' => $this->api_url,
'file' => $this->file,
),
'size' => 'regular',
)
Expand Down
25 changes: 20 additions & 5 deletions includes/discount-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,28 +406,43 @@ function edd_has_active_discounts() {
*
* @internal This method exists for backwards compatibility. `edd_add_discount()` should be used.
*
* @since 1.0
* @since 2.7 Updated to use EDD_Discount object.
* @since 3.0 Updated to use new query class.
* @since 1.0
* @since 2.7 Updated to use EDD_Discount object.
* @since 3.0 Updated to use new query class.
* @deprecated 3.0 Use edd_add_discount()
*
* @param array $details Discount args.
* @param int $discount_id Discount ID.
* @return mixed bool|int The discount ID of the discount code, or false on failure.
*/
function edd_store_discount( $details, $discount_id = null ) {

edd_debug_log(
sprintf(
__( '%1$s is deprecated since Easy Digital Downloads version %2$s! Use %3$s instead.', 'easy-digital-downloads' ),
__FUNCTION__,
'3.0',
'edd_add_discount()'
),
true
);

// Set default return value to false.
$return = false;

// Back-compat for start date.
if ( isset( $details['start'] ) && strstr( $details['start'], '/' ) ) {
$details['start_date'] = date( 'Y-m-d', strtotime( $details['start'] ) ) . ' 00:00:00';
$time_format = date( 'H:i:s', strtotime( $details['start'] ) );
$date_format = date( 'Y-m-d', strtotime( $details['start'] ) ) . ' ' . $time_format;
$details['start_date'] = edd_get_utc_equivalent_date( EDD()->utils->date( $date_format, edd_get_timezone_id(), false ));
unset( $details['start'] );
}

// Back-compat for end date.
if ( isset( $details['expiration'] ) && strstr( $details['expiration'], '/' ) ) {
$details['end_date'] = date( 'Y-m-d', strtotime( $details['expiration'] ) ) . ' 23:59:59';
$time_format = date( 'H:i:s', strtotime( $details['expiration'] ) );
$date_format = date( 'Y-m-d', strtotime( $details['expiration'] ) ) . ' ' . ( '00:00:00' !== $time_format ? $time_format : '23:59:59' );
$details['end_date'] = edd_get_utc_equivalent_date( EDD()->utils->date( $date_format, edd_get_timezone_id(), false ) );
unset( $details['expiration'] );
}

Expand Down
3 changes: 2 additions & 1 deletion includes/emails/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
*/
function edd_trigger_purchase_receipt( $payment_id = 0, $payment = null, $customer = null ) {
// Make sure we don't send a purchase receipt while editing a payment
if ( isset( $_POST['edd-action'] ) && 'edit_payment' == $_POST['edd-action'] ) {
$action = filter_input( INPUT_POST, 'edd_action', FILTER_SANITIZE_STRING );
if ( 'update_payment_details' === $action ) {
return;
}
if ( null === $payment ) {
Expand Down
28 changes: 17 additions & 11 deletions includes/orders/functions/orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -1007,17 +1007,20 @@ function edd_build_order( $order_data = array() ) {
foreach ( $item['fees'] as $fee_id => $fee ) {

$adjustment_subtotal = floatval( $fee['amount'] );
$tax_rate_amount = empty( $tax_rate->amount ) ? false : $tax_rate->amount;
$tax = EDD()->fees->get_calculated_tax( $fee, $tax_rate_amount );
$adjustment_total = floatval( $fee['amount'] ) + $tax;
$adjustment_data = array(
$adjustment_total = floatval( $fee['amount'] );
$adjustment_tax = 0;
if ( ! empty( $tax_rate->amount ) && empty( $fee['no_tax'] ) ) {
$adjustment_tax = EDD()->fees->get_calculated_tax( $fee, $tax_rate->amount );
$adjustment_total = floatval( $fee['amount'] ) + $adjustment_tax;
}
$adjustment_data = array(
'object_id' => $order_item_id,
'object_type' => 'order_item',
'type_key' => $fee_id,
'type' => 'fee',
'description' => $fee['label'],
'subtotal' => $adjustment_subtotal,
'tax' => $tax,
'tax' => $adjustment_tax,
'total' => $adjustment_total,
);

Expand Down Expand Up @@ -1054,10 +1057,13 @@ function edd_build_order( $order_data = array() ) {

add_filter( 'edd_prices_include_tax', '__return_false' );

$fee_subtotal = floatval( $fee['amount'] );
$tax_rate_amount = empty( $tax_rate->amount ) ? false : $tax_rate->amount;
$tax = EDD()->fees->get_calculated_tax( $fee, $tax_rate_amount );
$fee_total = floatval( $fee['amount'] ) + $tax;
$fee_subtotal = floatval( $fee['amount'] );
$fee_total = floatval( $fee['amount'] );
$fee_tax = 0;
if ( ! empty( $tax_rate->amount ) && empty( $fee['no_tax'] ) ) {
$fee_tax = EDD()->fees->get_calculated_tax( $fee, $tax_rate->amount );
$fee_total = floatval( $fee['amount'] ) + $fee_tax;
}

remove_filter( 'edd_prices_include_tax', '__return_false' );

Expand All @@ -1068,15 +1074,15 @@ function edd_build_order( $order_data = array() ) {
'type' => 'fee',
'description' => $fee['label'],
'subtotal' => $fee_subtotal,
'tax' => $tax,
'tax' => $fee_tax,
'total' => $fee_total,
);

// Add the adjustment.
$adjustment_id = edd_add_order_adjustment( $args );

$total_fees += (float) $fee['amount'];
$total_tax += $tax;
$total_tax += $fee_tax;
}
}

Expand Down
4 changes: 0 additions & 4 deletions includes/process-purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1310,10 +1310,6 @@ function edd_check_purchase_email_length( $valid_data, $posted_data ) {
*/
function edd_process_straight_to_gateway( $data ) {

if ( empty( $data['edd_straight_to_gateway'] ) || ! wp_verify_nonce( $data['edd_straight_to_gateway'], 'edd_straight_to_gateway' ) ) {
return;
}

$download_id = $data['download_id'];
$options = isset( $data['edd_options'] ) ? $data['edd_options'] : array();
$quantity = isset( $data['edd_download_quantity'] ) ? $data['edd_download_quantity'] : 1;
Expand Down
32 changes: 17 additions & 15 deletions includes/shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -797,8 +797,8 @@ function edd_process_profile_editor_updates( $data ) {

// Fetch customer record.
$customer = edd_get_customer_by( 'user_id', $user_id );
if ( empty( $customer->user_id ) || $customer->user_id != $user_id ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
return false;
if ( ! empty( $customer->user_id ) && $customer->user_id != $user_id ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
edd_set_error( 'customer_mismatch', __( 'Your profile could not be updated. Please contact a site administrator.', 'easy-digital-downloads' ) );
}

$display_name = isset( $data['edd_display_name'] ) ? sanitize_text_field( $data['edd_display_name'] ) : $old_user_data->display_name;
Expand All @@ -817,16 +817,16 @@ function edd_process_profile_editor_updates( $data ) {
'first_name' => $first_name,
'last_name' => $last_name,
'display_name' => $display_name,
'user_email' => $email
'user_email' => $email,
);

$address = array(
'line1' => $line1,
'line2' => $line2,
'city' => $city,
'state' => $state,
'zip' => $zip,
'country' => $country
'line1' => $line1,
'line2' => $line2,
'city' => $city,
'state' => $state,
'zip' => $zip,
'country' => $country,
);

do_action( 'edd_pre_update_user_profile', $user_id, $userdata );
Expand Down Expand Up @@ -874,12 +874,14 @@ function edd_process_profile_editor_updates( $data ) {
// Update user.
$updated = wp_update_user( $userdata );

// If the current user does not have an associated customer record, create one.
// If the current user does not have an associated customer record, create one so that all of the customer's data is stored.
if ( ! $customer && $updated ) {
$customer_id = edd_add_customer( array(
'user_id' => $updated,
'email' => $email,
) );
$customer_id = edd_add_customer(
array(
'user_id' => $updated,
'email' => $email,
)
);

$customer = edd_get_customer_by( 'id', $customer_id );
}
Expand All @@ -893,7 +895,7 @@ function edd_process_profile_editor_updates( $data ) {
'type' => 'billing',
'is_primary' => 1,
'number' => 1,
'fields' => 'ids'
'fields' => 'ids',
) );

// Try updating the address if it exists.
Expand Down
2 changes: 1 addition & 1 deletion includes/tax-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function edd_get_tax_rates( $args = array(), $output = ARRAY_N ) {

// Parse args
$r = wp_parse_args( $args, array(
'number' => 30,
'number' => 9999,
'type' => 'tax_rate',
'orderby' => 'date_created',
'order' => 'ASC',
Expand Down
Loading

0 comments on commit ac99f24

Please sign in to comment.