updated plugin `Easy Digital Downloads` version 3.1.3

This commit is contained in:
KawaiiPunk 2023-07-03 14:52:54 +00:00 committed by Gitium
parent 19f5bf5875
commit a7f6efbebb
26 changed files with 612 additions and 380 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -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
@ -27,7 +27,7 @@
* @package EDD
* @category Core
* @author Easy Digital Downloads
* @version 3.1.2
* @version 3.1.3
*/
// Exit if accessed directly.

View File

@ -52,7 +52,8 @@ class EDD_Batch_Sales_Export extends EDD_Batch_Export {
'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' ),
);
@ -72,17 +73,31 @@ class EDD_Batch_Sales_Export extends EDD_Batch_Export {
$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,
@ -92,8 +107,9 @@ class EDD_Batch_Sales_Export extends EDD_Batch_Export {
'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,
);
@ -155,7 +171,7 @@ class EDD_Batch_Sales_Export extends EDD_Batch_Export {
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();
}

View File

@ -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' );

View File

@ -355,7 +355,7 @@ final class Easy_Digital_Downloads {
// Plugin version.
if ( ! defined( 'EDD_VERSION' ) ) {
define( 'EDD_VERSION', '3.1.2' );
define( 'EDD_VERSION', '3.1.3' );
}
// Make sure CAL_GREGORIAN is defined.

View File

@ -306,7 +306,7 @@ class EDD_Download {
* @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 ) );
}
/**

View File

@ -110,10 +110,12 @@ class EDD_HTML_Elements {
// 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 );
}
}
}
}

View File

@ -220,6 +220,7 @@ class EDD_License {
'is_valid_license_option' => $this->item_shortname . '_license_active',
'item_id' => $this->item_id,
'api_url' => $this->api_url,
'file' => $this->file,
),
'size' => 'regular',
)

View File

@ -406,9 +406,10 @@ 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.
@ -416,18 +417,32 @@ function edd_has_active_discounts() {
*/
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'] );
}

View File

@ -25,7 +25,8 @@ defined( 'ABSPATH' ) || exit;
*/
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 ) {

View File

@ -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,
);
@ -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' );
@ -1068,7 +1074,7 @@ function edd_build_order( $order_data = array() ) {
'type' => 'fee',
'description' => $fee['label'],
'subtotal' => $fee_subtotal,
'tax' => $tax,
'tax' => $fee_tax,
'total' => $fee_total,
);
@ -1076,7 +1082,7 @@ function edd_build_order( $order_data = array() ) {
$adjustment_id = edd_add_order_adjustment( $args );
$total_fees += (float) $fee['amount'];
$total_tax += $tax;
$total_tax += $fee_tax;
}
}

View File

@ -1310,10 +1310,6 @@ add_action( 'edd_checkout_error_checks', 'edd_check_purchase_email_length', 10,
*/
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;

View File

@ -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;
@ -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 );
@ -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 );
}
@ -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.

View File

@ -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',

View File

@ -2,16 +2,16 @@
# This file is distributed under the same license as the Easy Digital Downloads plugin.
msgid ""
msgstr ""
"Project-Id-Version: Easy Digital Downloads 3.1.2\n"
"Project-Id-Version: Easy Digital Downloads 3.1.3\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/easy-digital-downloads\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2023-06-07T21:13:39+00:00\n"
"POT-Creation-Date: 2023-06-26T22:38:18+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.7.1\n"
"X-Generator: WP-CLI 2.8.1\n"
#. Plugin Name of the plugin
#. Author of the plugin
@ -133,7 +133,7 @@ msgstr ""
#: includes/admin/payments/actions.php:77
#: includes/admin/payments/actions.php:279
#: includes/admin/payments/actions.php:309
#: includes/emails/actions.php:59
#: includes/emails/actions.php:60
msgid "You do not have permission to edit this payment record"
msgstr ""
@ -201,14 +201,14 @@ msgstr ""
#: includes/blocks/includes/forms/recaptcha.php:180
#: includes/cart/class-edd-cart.php:1452
#: includes/cart/class-edd-cart.php:1466
#: includes/class-edd-license-handler.php:475
#: includes/class-edd-license-handler.php:476
#: includes/deprecated-functions.php:488
#: includes/deprecated-functions.php:505
#: includes/deprecated-functions.php:513
#: includes/deprecated-functions.php:915
#: includes/download-functions.php:1498
#: includes/EDD_SL_Plugin_Updater.php:486
#: includes/emails/actions.php:59
#: includes/emails/actions.php:60
#: includes/emails/template.php:241
#: includes/error-tracking.php:60
#: includes/gateways/functions.php:320
@ -849,7 +849,7 @@ msgstr ""
#: includes/admin/reporting/export/class-batch-export-file-downloads.php:43
#: includes/admin/reporting/export/class-batch-export-payments.php:62
#: includes/admin/reporting/export/class-batch-export-sales-and-earnings.php:59
#: includes/admin/reporting/export/class-batch-export-sales.php:57
#: includes/admin/reporting/export/class-batch-export-sales.php:58
#: includes/admin/reporting/export/class-batch-export-taxed-orders.php:62
#: includes/admin/tools.php:632
#: includes/blocks/views/orders/totals.php:38
@ -1005,12 +1005,12 @@ msgstr ""
#: includes/admin/import/import-functions.php:106
#: includes/admin/reporting/export/export-actions.php:24
#: includes/api/class-edd-api.php:2030
#: includes/class-edd-license-handler.php:475
#: includes/class-edd-license-handler.php:476
msgid "Nonce verification failed"
msgstr ""
#: includes/admin/customers/customer-actions.php:325
#: includes/shortcodes.php:987
#: includes/shortcodes.php:989
msgid "Email address %s removed by %s"
msgstr ""
@ -1853,7 +1853,7 @@ msgid "You do not have permission to delete discount codes"
msgstr ""
#: includes/admin/discounts/discount-codes.php:56
#: includes/class-edd-html-elements.php:442
#: includes/class-edd-html-elements.php:444
#: includes/post-types.php:125
msgid "Search Discounts"
msgstr ""
@ -2006,7 +2006,7 @@ msgid "You do not have permission to view this data."
msgstr ""
#: includes/admin/downloads/dashboard-columns.php:244
#: includes/class-edd-html-elements.php:518
#: includes/class-edd-html-elements.php:520
msgctxt "plural: Example: \"All Categories\""
msgid "All %s"
msgstr ""
@ -3511,6 +3511,7 @@ msgstr ""
#: includes/admin/reporting/class-export-payments.php:69
#: includes/admin/reporting/export/class-batch-export-payments.php:55
#: includes/admin/reporting/export/class-batch-export-sales.php:55
#: includes/admin/reporting/export/class-batch-export-taxed-orders.php:64
#: includes/admin/settings/register-settings.php:468
#: includes/admin/settings/register-settings.php:476
@ -3764,6 +3765,7 @@ msgid "Gross Amount"
msgstr ""
#: includes/admin/reporting/export/class-batch-export-payments.php:41
#: includes/admin/reporting/export/class-batch-export-sales.php:56
#: includes/admin/reporting/export/class-batch-export-taxed-orders.php:41
#: includes/privacy-functions.php:868
msgid "Order ID"
@ -3802,12 +3804,7 @@ msgstr ""
msgid "Product ID"
msgstr ""
#: includes/admin/reporting/export/class-batch-export-sales.php:55
#: includes/emails/tags.php:221
msgid "Payment ID"
msgstr ""
#: includes/admin/reporting/export/class-batch-export-sales.php:56
#: includes/admin/reporting/export/class-batch-export-sales.php:57
msgid "Price ID"
msgstr ""
@ -4309,7 +4306,7 @@ msgid "Select Region"
msgstr ""
#: includes/admin/reporting/views/export-taxed-orders.php:62
#: includes/class-edd-html-elements.php:656
#: includes/class-edd-html-elements.php:658
msgid "All Regions"
msgstr ""
@ -6478,7 +6475,7 @@ msgid "Orders placed through the Amazon gateway must be refunded through Amazon.
msgstr ""
#: includes/admin/views/tmpl-order-adjustment-discount.php:27
#: includes/discount-functions.php:1350
#: includes/discount-functions.php:1365
msgid "Remove discount"
msgstr ""
@ -6488,7 +6485,7 @@ msgstr ""
#: includes/blocks/views/checkout/discount.php:16
#: includes/blocks/views/orders/discounts.php:7
#: includes/checkout/template.php:741
#: includes/discount-functions.php:1314
#: includes/discount-functions.php:1329
#: templates/shortcode-receipt.php:87
msgid "Discount"
msgid_plural "Discounts"
@ -6679,7 +6676,7 @@ msgstr ""
#: includes/ajax-functions.php:712
#: includes/ajax-functions.php:850
#: includes/class-edd-html-elements.php:379
#: includes/class-edd-html-elements.php:381
msgid "No users found"
msgstr ""
@ -7823,7 +7820,7 @@ msgid "%d customers created in %d seconds"
msgstr ""
#: includes/class-edd-cli.php:307
#: includes/class-edd-html-elements.php:307
#: includes/class-edd-html-elements.php:309
msgid "No customers found"
msgstr ""
@ -7913,7 +7910,7 @@ msgid " Product: %s - %s"
msgstr ""
#: includes/class-edd-cli.php:424
#: includes/class-edd-html-elements.php:475
#: includes/class-edd-html-elements.php:477
#: includes/shortcodes.php:259
msgid "No discounts found"
msgstr ""
@ -8358,7 +8355,7 @@ msgid "This discount has already been redeemed."
msgstr ""
#: includes/class-edd-discount.php:1617
#: includes/discount-functions.php:918
#: includes/discount-functions.php:933
msgctxt "error for when a discount is invalid based on its configuration"
msgid "This discount is invalid."
msgstr ""
@ -8385,73 +8382,73 @@ msgstr ""
msgid "All Price Options"
msgstr ""
#: includes/class-edd-html-elements.php:283
#: includes/class-edd-html-elements.php:285
msgid "Choose a Customer"
msgstr ""
#: includes/class-edd-html-elements.php:287
#: includes/class-edd-html-elements.php:289
msgid "Search Customers"
msgstr ""
#: includes/class-edd-html-elements.php:289
#: includes/class-edd-html-elements.php:291
msgid "No customer attached"
msgstr ""
#: includes/class-edd-html-elements.php:357
#: includes/class-edd-html-elements.php:359
msgid "Select a User"
msgstr ""
#: includes/class-edd-html-elements.php:361
#: includes/class-edd-html-elements.php:363
msgid "Search Users"
msgstr ""
#: includes/class-edd-html-elements.php:437
#: includes/class-edd-html-elements.php:439
msgid "Choose a Discount"
msgstr ""
#: includes/class-edd-html-elements.php:438
#: includes/class-edd-html-elements.php:440
#: includes/post-types.php:123
msgid "All Discounts"
msgstr ""
#: includes/class-edd-html-elements.php:617
#: includes/class-edd-html-elements.php:619
msgid "Choose a Country"
msgstr ""
#: includes/class-edd-html-elements.php:618
#: includes/class-edd-html-elements.php:620
msgid "All Countries"
msgstr ""
#: includes/class-edd-html-elements.php:655
#: includes/class-edd-html-elements.php:657
msgid "Choose a Region"
msgstr ""
#: includes/class-edd-html-elements.php:688
#: includes/class-edd-html-elements.php:690
msgctxt "all dropdown items"
msgid "All"
msgstr ""
#: includes/class-edd-html-elements.php:689
#: includes/class-edd-html-elements.php:691
msgctxt "no dropdown items"
msgid "None"
msgstr ""
#: includes/class-edd-html-elements.php:987
#: includes/class-edd-html-elements.php:989
msgid "Enter Username"
msgstr ""
#: includes/class-edd-html-elements.php:1017
#: includes/class-edd-html-elements.php:1019
#: includes/blocks/build/register/index.js:1
msgid "Required"
msgstr ""
#. translators: 1. opening anchor tag; 2. closing anchor tag
#: includes/class-edd-license-handler.php:299
#: includes/class-edd-license-handler.php:300
#: src/Extensions/Handler.php:263
msgid "You have invalid or expired license keys for Easy Digital Downloads. %1$sActivate License(s)%2$s"
msgstr ""
#: includes/class-edd-license-handler.php:321
#: includes/class-edd-license-handler.php:322
#: src/Extensions/Handler.php:282
msgid "Enter valid license key for automatic updates."
msgstr ""
@ -9268,6 +9265,10 @@ msgstr ""
msgid "Would you like to enable reviews for this product? Check out our <a target=\"_blank\" href=\"%s\">Product Reviews</a> extension."
msgstr ""
#: includes/discount-functions.php:422
msgid "%1$s is deprecated since Easy Digital Downloads version %2$s! Use %3$s instead."
msgstr ""
#: includes/download-functions.php:605
msgid "Single Product"
msgstr ""
@ -9499,6 +9500,10 @@ msgstr ""
msgid "The price of the purchase before taxes."
msgstr ""
#: includes/emails/tags.php:221
msgid "Payment ID"
msgstr ""
#: includes/emails/tags.php:222
msgid "The unique identifier for this purchase."
msgstr ""
@ -12441,7 +12446,7 @@ msgstr ""
msgid "Your email address must be shorter than 100 characters."
msgstr ""
#: includes/process-purchase.php:1336
#: includes/process-purchase.php:1332
msgid "There was an error completing your purchase. Please try again."
msgstr ""
@ -12761,6 +12766,10 @@ msgstr ""
msgid "Receipt could not be retrieved, your purchase session has expired."
msgstr ""
#: includes/shortcodes.php:801
msgid "Your profile could not be updated. Please contact a site administrator."
msgstr ""
#: includes/shortcodes.php:837
msgid "The passwords you entered do not match. Please try again."
msgstr ""
@ -12774,7 +12783,7 @@ msgstr ""
msgid "This email address is not available."
msgstr ""
#: includes/shortcodes.php:991
#: includes/shortcodes.php:993
msgid "Error removing email address from profile. Please try again later."
msgstr ""
@ -13621,23 +13630,23 @@ msgstr ""
msgid "Already purchased? Simply enter your license key to enable EDD (Pro)."
msgstr ""
#: src/Admin/Pass_Manager.php:362
#: src/Admin/Pass_Manager.php:363
msgid "Personal Pass"
msgstr ""
#: src/Admin/Pass_Manager.php:363
#: src/Admin/Pass_Manager.php:364
msgid "Extended Pass"
msgstr ""
#: src/Admin/Pass_Manager.php:364
#: src/Admin/Pass_Manager.php:365
msgid "Professional Pass"
msgstr ""
#: src/Admin/Pass_Manager.php:365
#: src/Admin/Pass_Manager.php:366
msgid "All Access Pass"
msgstr ""
#: src/Admin/Pass_Manager.php:366
#: src/Admin/Pass_Manager.php:367
msgid "Lifetime All Access Pass"
msgstr ""
@ -13949,8 +13958,8 @@ msgid "Easy Digital Downloads &mdash; Customized Templates"
msgstr ""
#: src/Licensing/Ajax.php:50
#: src/Licensing/Ajax.php:135
#: src/Licensing/Ajax.php:177
#: src/Licensing/Ajax.php:136
#: src/Licensing/Ajax.php:178
msgid "You do not have permission to manage this extension."
msgstr ""
@ -13959,119 +13968,149 @@ msgstr ""
msgid "No key provided."
msgstr ""
#: src/Licensing/Ajax.php:91
#: src/Licensing/Ajax.php:92
msgid "Your license key could not be activated."
msgstr ""
#: src/Licensing/Ajax.php:161
#: src/Licensing/Messages.php:178
#: src/Licensing/Ajax.php:162
#: src/Licensing/Messages.php:130
msgid "Your license key has been deactivated."
msgstr ""
#: src/Licensing/Ajax.php:189
#: src/Licensing/Ajax.php:190
msgid "License key deleted."
msgstr ""
#: src/Licensing/Messages.php:62
#: src/Licensing/Messages.php:89
msgid "license key"
msgstr ""
#. translators: 1. license expiration date; 2. opening link tag; 3. closing link tag.
#: src/Licensing/Messages.php:81
msgid "Your license key expired on %1$s. Please %2$srenew your license key%3$s."
msgstr ""
#. translators: 1. opening link tag; 2. closing link tag.
#: src/Licensing/Messages.php:89
msgid "Your license key has expired. Please %1$srenew your license key%2$s."
msgstr ""
#. translators: 1. opening link tag; 2. closing link tag.
#: src/Licensing/Messages.php:107
msgid "Your license key has been disabled. Please %1$scontact support%2$s for more information."
msgstr ""
#. translators: 1. opening link tag; 2. closing link tag.
#: src/Licensing/Messages.php:123
msgid "Invalid license. Please %1$svisit your account page%2$s and verify it."
msgstr ""
#. translators: 1. the extension name; 2. opening link tag; 3. closing link tag.
#: src/Licensing/Messages.php:139
msgid "Your %1$s is not active for this URL. Please %2$svisit your account page%3$s to manage your license keys."
msgstr ""
#. translators: the extension name.
#: src/Licensing/Messages.php:152
#: src/Licensing/Messages.php:116
msgid "This appears to be an invalid license key for %s."
msgstr ""
#. translators: 1. opening link tag; 2 closing link tag.
#: src/Licensing/Messages.php:167
msgid "Your license key has reached its activation limit. %1$sView possible upgrades%2$s now."
msgstr ""
#: src/Licensing/Messages.php:174
#: src/Licensing/Messages.php:126
msgid "The key you entered belongs to a bundle, please use the product specific license key."
msgstr ""
#: src/Licensing/Messages.php:189
#: src/Licensing/Messages.php:141
msgid "Unlicensed: currently not receiving updates."
msgstr ""
#: src/Licensing/Messages.php:204
#: src/Licensing/Messages.php:156
msgid "License key never expires."
msgstr ""
#. translators: the license expiration date.
#: src/Licensing/Messages.php:210
#: src/Licensing/Messages.php:162
msgid "Your license key expires soon! It expires on %s."
msgstr ""
#. translators: the license expiration date.
#: src/Licensing/Messages.php:217
#: src/Licensing/Messages.php:169
msgid "Your license key expires on %s."
msgstr ""
#: src/Licensing/Messages.php:230
#: src/Licensing/Messages.php:182
msgid "Your license subscription is active and will automatically renew."
msgstr ""
#. translators: the license subscription status.
#: src/Licensing/Messages.php:235
#: src/Licensing/Messages.php:187
msgid "Your license subscription is %s and will not automatically renew."
msgstr ""
#: src/Licensing/Messages.php:249
msgid "pending"
#. translators: 1. license expiration date.
#: src/Licensing/Messages.php:204
msgid "Your license key expired on %1$s. Please renew your license key."
msgstr ""
#: src/Licensing/Messages.php:250
msgid "active"
#: src/Licensing/Messages.php:209
msgid "Your license key has expired. Please renew your license key."
msgstr ""
#: src/Licensing/Messages.php:251
msgid "cancelled"
#. translators: 1. license expiration date; 2. opening link tag; 3. closing link tag.
#: src/Licensing/Messages.php:228
msgid "Your license key expired on %1$s. Please %2$srenew your license key%3$s."
msgstr ""
#. translators: 1. opening link tag; 2. closing link tag.
#: src/Licensing/Messages.php:237
msgid "Your license key has expired. Please %1$srenew your license key%2$s."
msgstr ""
#: src/Licensing/Messages.php:252
msgid "Your license key has been disabled."
msgstr ""
#. translators: 1. opening link tag; 2. closing link tag.
#: src/Licensing/Messages.php:267
msgid "Your license key has been disabled. Please %1$scontact support%2$s for more information."
msgstr ""
#: src/Licensing/Messages.php:282
msgid "Your license key has reached its activation limit."
msgstr ""
#. translators: 1. opening link tag; 2 closing link tag.
#: src/Licensing/Messages.php:297
msgid "Your license key has reached its activation limit. %1$sView possible upgrades%2$s now."
msgstr ""
#: src/Licensing/Messages.php:312
msgid "Your license key is not active for this URL."
msgstr ""
#. translators: 1. opening link tag; 2. closing link tag.
#: src/Licensing/Messages.php:328
msgid "Your license key is not active for this URL. Please %1$svisit your account page%2$s to manage your license keys."
msgstr ""
#. translators: 1. the extension name; 2. opening link tag; 3. closing link tag.
#: src/Licensing/Messages.php:336
msgid "Your %1$s license key is not active for this URL. Please %2$svisit your account page%3$s to manage your license keys."
msgstr ""
#: src/Licensing/Messages.php:351
msgid "Invalid license. Please verify it."
msgstr ""
#. translators: 1. opening link tag; 2. closing link tag.
#: src/Licensing/Messages.php:364
msgid "Invalid license. Please %1$svisit your account page%2$s and verify it."
msgstr ""
#: src/Licensing/Messages.php:379
msgid "pending"
msgstr ""
#: src/Licensing/Messages.php:380
msgid "active"
msgstr ""
#: src/Licensing/Messages.php:381
msgid "cancelled"
msgstr ""
#: src/Licensing/Messages.php:382
msgid "expired"
msgstr ""
#: src/Licensing/Messages.php:253
#: src/Licensing/Messages.php:383
msgid "trialling"
msgstr ""
#: src/Licensing/Messages.php:254
#: src/Licensing/Messages.php:384
msgid "failing"
msgstr ""
#: src/Licensing/Messages.php:255
#: src/Licensing/Messages.php:385
msgid "completed"
msgstr ""
#. translators: the all acess pass name.
#: src/Licensing/Traits/Controls.php:193
#: src/Licensing/Traits/Controls.php:200
msgid "Your %s gives you access to this extension."
msgstr ""

View File

@ -1,12 +1,12 @@
=== Easy Digital Downloads - Simple eCommerce for Selling Digital Files ===
Author URI: https://easydigitaldownloads.com
Plugin URI: https://easydigitaldownloads.com
Contributors: easydigitaldownloads, am, cklosows, littlerchicken, smub, mordauk, sunnyratilal, chriscct7, section214, sumobi, sdavis2702, mindctrl, sksmatt, SpencerFinnell, johnstonphilip, brashrebel, drewapicture, johnjamesjacoby, nosegraze, lisacee, zkawesome
Contributors: easydigitaldownloads, am, cklosows, littlerchicken, achchu93, smub, mordauk, sunnyratilal, chriscct7, section214, sumobi, sdavis2702, mindctrl, sksmatt, SpencerFinnell, johnstonphilip, brashrebel, drewapicture, johnjamesjacoby, nosegraze, lisacee, zkawesome
Tags: ecommerce, payments, sell, digital store, stripe
Requires at least: 5.4
Tested up to: 6.2
Requires PHP: 7.1
Stable Tag: 3.1.2
Stable Tag: 3.1.3
License: GNU Version 2 or Any Later Version
Sell your digital products with the #1 eCommerce plugin written for digital creators by digital creators.
@ -226,131 +226,23 @@ Yes, with an Extended Pass you get access to [Recurring Payments](https://easydi
== Changelog ==
= 3.1.2 =
* New: The EDD "System Info" has been retired and instead our data is registered with WordPress Core's Site Health.
* Improvement: We've drastically reduced the possibility of a collision when using Sequential Order Numbers.
* Improvement: We've changed the 'Default' item in the Product Type dropdown to 'Single Product' to avoid confusion.
* Improvement: Gateways can now inform EDD if they are properly set up, and prevent enabling them if they are not configured.
* Improvement: The PayPal Commerce onboarding process has been revamped for speed and reliability.
* Improvement: The EDD 3.x migration process has been updated to defer all customer and product calculations until the migration is complete, with improved messaging.
* Improvement - Stripe: We've added a filter to allow users to remove the 'Terms' text that shows below card fields.
* Improvement - Stripe: When a user disconnects from Stripe Connect, Stripe is unchecked as an 'active' gateway.
* Improvement - Blocks: When no downloads are created, download related blocks were not correctly showing the button to add a new download.
* Improvement - Blocks: EDD's blocks were not respecting custom Download labels.
* Fix: Pass license keys did not always hold their activation status on multisite installs.
* Fix: In some edge cases, it was possible to produce a fatal error in PHP 8.0 when adding items to the cart.
* Fix: Improved capability checks and nonce detection on some actions.
* Fix: Item fees could fail validation in some cases, resulting in missed fees.
* Fix: The Payments Query class was incorrectly passing the `id__not_in` as `id__in`.
* Fix: The AJAX cart content response was not using the new method of getting cart item names.
* Fix: A more user friendly error message is shown to non-privileged users if no gateways are enabled.
* Fix: The Login URL in user registration emails was not correct when the purchase was made with Stripe.
* Fix: The calculated fees could differ from the fees that are displayed in the cart contents.
* Fix: When importing downloads, in some cases, the images were not identified as local files.
* Fix: The Download Tag taxonomy admin area was not being identified as an EDD Admin area.
* Fix: There was a possibility of an undefined variable when requesting a password reset.
* Fix - Stripe: The Recurring Payments update form could load incorrectly if split fields was enabled prior to swtiching to Payment Elements.
* Fix - Stripe: Multiple improvements to the Stripe form load states when cart recalculations are being run.
* Fix - Stripe: In some cases, the purchase form was not re-enabled after fixing HTML5 validation errors.
* Fix - Stripe: Customers updating the payment method for a failing subscription could see an error message when the failed invoice was voided, even though the subscription was updated successfully.
* Fix - Blocks: The reCAPTCHA key field is now a Password field type.
* Fix - Blocks: The User Downloads blocks could show duplicate items.
* Fix - Blocks: Extensions which added data to the cart could display without styling.
* Dev: The functions to get the lowest & highest price options have been abstracted, improved, and now have unit tests.
* Dev: Upgrade routines prior to 3.0 have been deprecated.
* Dev: A new CLI command, `recalculate_customer_values` has been registered to recalculate sales and earnings for all customers.
* Dev - Stripe: It is now possible to force 'Card Fields' to be available on new installs, by switching on EDD's Debug Mode.
= 3.1.3 =
* Improvement: Licensing messages for third party extensions no longer link to the main EDD site.
* Improvement: The default number of tax rates to query has been increased.
* Fix: Using a custom `straight_to_gateway` link did not add a product to the cart.
* Fix: Products which are marked as having variable prices, but which don't have any prices, could cause a PHP notice or error.
* Fix: Duplicate purchase receipt emails could be sent when editing an order.
* Fix: The product sales export was not respecting the end date when set.
* Fix: The product sales export was showing incorrect amounts for orders with multiple items, or partially refunded orders.
* Fix: For stores which collect sales tax, tax exempt fees sometimes had tax applied.
* Fix: `edd_store_discount` now accepts times for start/expiration dates.
* Fix: Users who are not also customers were unable to update their profile using the EDD profile editor.
* Fix: The pass ID for pro licenses could be incorrect in some cases.
* Fix: If EDD settings were removed, the telemetry data could cause a PHP notice.
* Fix: Prevent a JavaScript error that could occur if the cart widget was present on the checkout page when taxes are enabled.
* Dev: Third party developers who use EDD's licensing screen can now customize licensing messages.
View the full changelog at [https://easydigitaldownloads.com/changelog/](https://easydigitaldownloads.com/changelog/?utm_medium=readme&utm_source=wporg&utm_campaign=edd-plugin&utm_term=description)
= 3.1.1.4.2 =
* Security: Improved validation for edd hooks.
= 3.1.1.4.1 =
* Fix - Blocks: Harden blocks loader to verify files exist before requiring them.
= 3.1.1.4 =
* Improvement: Removed a possible unsupported PHP configuration from the email summaries.
* Improvement: The edd_get_users_purchases function has been updated to account for customer email address changes.
* Improvement: Reports have been updated to more accurately account for timezones and date ranges.
* Improvement: The onboarding wizard loading was not allowing a close and exit after the first step.
* Improvement: License key handling for 3rd party extensions has been accounted for.
* Improvement: When using sequential order numbers, searching has been updated to account for order number.
* Improvement - Stripe: The Payment Element has been improved to handle failed 3DS challenges.
* Improvement - Stripe: Failed payment attempts are now more reliably accounted for.
* Improvement - Stripe: The Payment Element billing fields can now be filtered.
* Improvement - Stripe: The Payment Element now supports mandates, improving multi-regional payments.
* Improvement - Stripe: The 'Card Name' field is re-introduced for regions that require it.
* Improvement - Blocks: Better support for custom fields with the Checkout Block.
* Improvement - Blocks: Developers can now register custom columns for the User Downloads block.
* Improvement - Blocks: The Buy Now button can now have its behavior defined as Add to Cart or Buy Now.
* Fix: Discounts with high value amounts were not saving correctly.
* Fix: Bulk Editing prices was not working with WordPress 6.1+.
* Fix: Exporting product sales was not always respecting the date range filters.
* Fix: Exports with date queries were not always accounting for timezones accurately.
* Fix - Blocks: Cart section headings were not always displayed when reloading the section via AJAX.
* Dev: New custom hooks in database row transitions have been added.
= 3.1.1.3 =
* Improvement: The orders list table in the admin now sorts orders by date as the default.
* Improvement: Removed unnecessary options in the onboarding wizard.
* Improvement - Stripe: Store owners can now [control which payment methods to accept within their Stripe account](https://easydigitaldownloads.com/docs/stripe/#how-to-manage-payment-methods).
* Improvement - Stripe: We've added a better explanation for the Restrict Stripe Assets setting.
* Change: Translations are now always managed by WordPress.org.
* Fix: Existing tables might not have been updated correctly.
* Fix: Attempting to update the default email address from the profile editor could fail in some circumstances.
= 3.1.1.2 =
* Improvement: The order details screen in the admin has been updated to use the Currency class to be consistent with customer receipts.
* Improvement: Determining whether a plugin is a core extension for telemetry data has been improved.
* Fix: Enabling/disabling the sequential order numbers setting no longer prompts an upgrade notice, since that setting does not affect past orders.
* Fix: When exiting the onboarding wizard, the double overlay has been removed.
* Fix: The typos in the pro eligibility pointer notice have been corrected.
* Fix: The user verification email could cause a fatal error with some translations.
* Fix - Stripe: Improve custom Payment Element rules to merge with existing.
* Fix - Stripe: Single price products purchased through "Buy Now" no longer have a price ID assigned in the order items table.
* Dev: Using `get_page_by_title` has been deprecated in WordPress 6.2; our importer has been updated accordingly.
* Dev - Stripe: Unneeded source files are no longer included in the release.
= 3.1.1.1 =
* Fix: Ensure that Stripe only tries to verify the domain for Apple Pay when Stripe is connected.
* Fix: PHP 7.1 Compatibility with Stripe.
* Improvement: Avoid a race condition when updating where a function might not be available for a moment.
= 3.1.1 =
* New: New installations will be directed to an onboarding wizard to help set up key features and get new stores up and running more quickly.
* New: Users with an active pass can manage extensions with one license key and easily upgrade to Easy Digital Downloads (Pro).
* New - Stripe: Our Stripe integration now uses the Universal Payment Elements and Link support. Legacy users are encouraged to opt in.
* New - Blocks: A new EDD User Downloads block has been registered to show users the files they can download.
* Improvement: Trashed orders can now be deleted in bulk.
* Improvement: EDD's metaboxes have been moved up in priority when editing a download.
* Improvement: Reports styling has been updated to account for different graph types.
* Improvement: The Product Sales export tool has been added back to the Reports > Export screen.
* Improvement: EDD telemetry tracking has been completely rewritten to anonymize data collection.
* Improvement: The extensions licensing screen has been updated to improve messaging and the license management experience.
* Improvement: Querying for a customer by email address has been improved to include all email addresses.
* Improvement: The PayPal Commerce connection error messaging has been updated to give users more information to help troubleshoot before contacting support.
* Improvement: Improved performance when using order related functions which have been updated to accept the order object directly.
* Improvement: EDD admin screens now show only EDD notices.
* Improvement - Blocks: New installs will automatically use the checkout block instead of the legacy shortcode.
* Improvement - Blocks: The Login Page and Login Redirect Page settings have been reordered.
* Improvement - Blocks: When adding the EDD Buy Button to a download, the current download is set as the default.
* Improvement - Blocks: Additional security has been added to the checkout, login, and register blocks.
* Fix: Report charts could group orders by date incorrectly when dates spanned a change in Daylight Savings.
* Fix: In some cases, the customer database table was not getting the updates needed.
* Fix: An additional security check has been added to the system info file download form.
* Fix: The ajax spinner could be duplicated on the checkout screen for stores which collect taxes.
* Fix: Stores with quantities enabled could experience unexpected behavior on checkout.
* Fix - Stripe: Support links have been updated.
* Fix - Blocks: Some themes/plugins caused the checkout forms script to not be enqueued.
* Dev: The new minimum WordPress version is 5.4.
* Dev: The new minimum PHP version is 7.1.
* Dev: The `edd_sanitize_amount` function has been updated for PHP8 compatibility.
* Dev: Notifications are now registered as an EDD component.
* Dev: Notifications can now be registered locally.
* Dev: Additional debugging has been added if a legacy payment cannot be migrated due to invalid payment metadata.
* Dev: The discounts HTML is now always filterable, even if there are no discounts applied.
* Dev: Code for the legacy WordPress media loader has been removed.
== Upgrade Notice ==
IMPORTANT: Upgrading from Easy Digital Downloads 2.9.x to 3.0+ is a major release that includes many improvements and changes. You will be asked to perform database maintenance once installed. Please ensure you make a backup of your site prior to upgrading. Your site should remain functional during this maintenance, but as with all updates, it is best to make a backup of your site prior to updating.

View File

@ -0,0 +1,66 @@
<?php
/**
* Pass Handler related cron events.
*
* @package EDD
*/
namespace EDD\Admin\PassHandler;
use \EDD\EventManagement\SubscriberInterface;
class Cron implements SubscriberInterface {
/**
* Gets the array of subscribed events.
*
* @return array
*/
public static function get_subscribed_events() {
if ( is_multisite() && ! is_main_site() ) {
return array();
}
return array(
'edd_weekly_scheduled_events' => 'weekly_license_check',
);
}
/**
* Check if license key is valid once per week
*
* @since 3.1.1
* @return void
*/
public function weekly_license_check() {
if ( ! edd_doing_cron() ) {
return;
}
$handler = new \EDD\Admin\PassHandler\Handler();
$license = $handler->get_pro_license();
if ( empty( $license->key ) ) {
return;
}
// data to send in our API request
$api_params = array(
'edd_action' => 'check_license',
'license' => $license->key,
'item_id' => $license->item_id,
'item_name' => $license->item_name,
'pass_id' => $license->item_id,
'url' => network_home_url(),
);
$api_handler = new \EDD\Licensing\API();
$license_data = $api_handler->make_request( $api_params );
if ( ! $license_data ) {
return false;
}
$pass_manager = new \EDD\Admin\Pass_Manager();
$pass_manager->maybe_set_pass_flag( $license->key, $license_data );
$handler->update_pro_license( $license_data );
}
}

View File

@ -105,8 +105,10 @@ class Pass_Manager {
$this->pro_license = $this->get_pro_license();
if ( ! empty( $this->pro_license->license ) && 'valid' === $this->pro_license->license ) {
$this->highest_license_key = $this->pro_license->key;
$this->highest_pass_id = $this->pro_license->item_id;
$this->has_pass_data = true;
$this->highest_pass_id = $this->get_pass_id_from_pro_license();
if ( $this->highest_pass_id ) {
$this->has_pass_data = true;
}
} else {
// Set up the highest pass data.
$pass_data = get_option( 'edd_pass_licenses' );
@ -301,14 +303,13 @@ class Pass_Manager {
* @param string $comparison Comparison operator.
*
* @return bool
* @throws \InvalidArgumentException
*/
public static function pass_compare( $pass_1, $pass_2, $comparison = '>' ) {
if ( ! array_key_exists( $pass_1, self::$pass_hierarchy ) ) {
throw new \InvalidArgumentException( 'Invalid pass 1: ' . $pass_1 );
return false;
}
if ( ! array_key_exists( $pass_2, self::$pass_hierarchy ) ) {
throw new \InvalidArgumentException( 'Invalid pass 2: ' . $pass_2 );
return false;
}
return version_compare( self::$pass_hierarchy[ $pass_1 ], self::$pass_hierarchy[ $pass_2 ], $comparison );
@ -419,4 +420,24 @@ class Pass_Manager {
update_option( 'edd_pass_licenses', json_encode( $passes ) );
}
/**
* Gets the pass ID from the pro license.
*
* @since 3.1.3
* @return int|null
*/
private function get_pass_id_from_pro_license() {
// A valid pro pass should always have a pass ID.
if ( ! empty( $this->pro_license->pass_id ) && array_key_exists( $this->pro_license->pass_id, self::$pass_hierarchy ) ) {
return $this->pro_license->pass_id;
}
// If the pro license is for a pass, but doesn't have a pass ID, we can try the item ID, if it's in the pass hierarchy
if ( array_key_exists( $this->pro_license->item_id, self::$pass_hierarchy ) ) {
return $this->pro_license->item_id;
}
return null;
}
}

View File

@ -20,6 +20,7 @@ class Core extends EventManagement\Subscribers {
new Admin\PassHandler\Ajax( $this->pass_handler ),
new Admin\Extensions\Extension_Manager(),
new Customers\Recalculations(),
new Admin\PassHandler\Cron(),
);
}

View File

@ -84,6 +84,7 @@ class Ajax implements SubscriberInterface {
'expires' => ! empty( $license_data->expires ) ? $license_data->expires : false,
'name' => $this->name,
'subscription' => ! empty( $license_data->subscription ) ? $license_data->subscription : null,
'api_url' => $custom_api,
)
);
$message = $messages->get_message();

View File

@ -39,6 +39,8 @@ class Messages {
'name' => '',
'license_key' => '',
'subscription' => false,
'api_url' => null,
'uri' => null,
)
);
$this->now = current_time( 'timestamp' );
@ -59,88 +61,50 @@ class Messages {
*/
public function get_message() {
$name = $this->license_data['name'] ?: __( 'license key', 'easy-digital-downloads' );
$message = $this->build_message();
if ( ! $this->is_third_party_license() || empty( $this->license_data['name'] ) ) {
return $message;
}
$name = $this->sanitize_third_party_name();
/**
* Filters the message for a third-party license.
*
* Example: If your plugin name is "My Extension for Easy Digital Downloads" you
* would use the filter edd_licensing_third_party_message_my_extension_for_easy_digital_downloads
* @since 3.1.3
* @param string $message The message.
* @param array $data The license data.
*/
return apply_filters( "edd_licensing_third_party_message_{$name}", $message, $this->license_data );
}
/**
* Builds the message based on the license data.
*
* @sinc 3.1.3
* @return string
*/
private function build_message() {
$name = $this->license_data['name'] ?: __( 'license key', 'easy-digital-downloads' ); // phpcs:ignore WordPress.PHP.DisallowShortTernary.Found
switch ( $this->license_data['status'] ) {
case 'expired':
$args = array(
'utm_medium' => 'license-notice',
'utm_content' => 'expired',
);
if ( ! empty( $this->license_data['license_key'] ) ) {
$args['license_key'] = $this->license_data['license_key'];
}
$url = edd_link_helper(
'https://easydigitaldownloads.com/checkout/',
$args
);
if ( $this->expiration ) {
$message = sprintf(
/* translators: 1. license expiration date; 2. opening link tag; 3. closing link tag. */
__( 'Your license key expired on %1$s. Please %2$srenew your license key%3$s.', 'easy-digital-downloads' ),
edd_date_i18n( $this->expiration ),
'<a href="' . $url . '" target="_blank">',
'</a>'
);
} else {
$message = sprintf(
/* translators: 1. opening link tag; 2. closing link tag. */
__( 'Your license key has expired. Please %1$srenew your license key%2$s.', 'easy-digital-downloads' ),
'<a href="' . $url . '" target="_blank">',
'</a>'
);
}
$message = $this->get_expired_message();
break;
case 'revoked':
case 'disabled':
$url = edd_link_helper(
'https://easydigitaldownloads.com/support/',
array(
'utm_medium' => 'license-notice',
'utm_content' => 'revoked',
)
);
$message = sprintf(
/* translators: 1. opening link tag; 2. closing link tag. */
__( 'Your license key has been disabled. Please %1$scontact support%2$s for more information.', 'easy-digital-downloads' ),
'<a href="' . $url . '" target="_blank">',
'</a>'
);
$message = $this->get_disabled_message();
break;
case 'missing':
$url = edd_link_helper(
'https://easydigitaldownloads.com/your-account/',
array(
'utm_medium' => 'license-notice',
'utm_content' => 'missing',
)
);
$message = sprintf(
/* translators: 1. opening link tag; 2. closing link tag. */
__( 'Invalid license. Please %1$svisit your account page%2$s and verify it.', 'easy-digital-downloads' ),
'<a href="' . $url . '" target="_blank">',
'</a>'
);
$message = $this->get_missing_message();
break;
case 'site_inactive':
$url = edd_link_helper(
'https://easydigitaldownloads.com/your-account/',
array(
'utm_medium' => 'license-notice',
'utm_content' => 'inactive',
)
);
$message = sprintf(
/* translators: 1. the extension name; 2. opening link tag; 3. closing link tag. */
__( 'Your %1$s is not active for this URL. Please %2$svisit your account page%3$s to manage your license keys.', 'easy-digital-downloads' ),
esc_html( $name ),
'<a href="' . $url . '" target="_blank">',
'</a>'
);
$message = $this->get_inactive_message();
break;
case 'invalid':
@ -155,19 +119,7 @@ class Messages {
break;
case 'no_activations_left':
$url = edd_link_helper(
'https://easydigitaldownloads.com/your-account/',
array(
'utm_medium' => 'license-notice',
'utm_content' => 'at-limit',
)
);
$message = sprintf(
/* translators: 1. opening link tag; 2 closing link tag. */
__( 'Your license key has reached its activation limit. %1$sView possible upgrades%2$s now.', 'easy-digital-downloads' ),
'<a href="' . $url . '">',
'</a>'
);
$message = $this->get_no_activations_message();
break;
case 'license_not_activable':
@ -237,6 +189,184 @@ class Messages {
);
}
/**
* Gets the message for an expired license.
*
* @since 3.1.3
* @return string
*/
private function get_expired_message() {
$url = $this->get_plugin_uri();
if ( empty( $url ) && $this->is_third_party_license() ) {
if ( $this->expiration ) {
return sprintf(
/* translators: 1. license expiration date. */
__( 'Your license key expired on %1$s. Please renew your license key.', 'easy-digital-downloads' ),
edd_date_i18n( $this->expiration )
);
}
return __( 'Your license key has expired. Please renew your license key.', 'easy-digital-downloads' );
}
if ( empty( $url ) ) {
$args = array(
'utm_medium' => 'license-notice',
'utm_content' => 'expired',
);
if ( ! empty( $this->license_data['license_key'] ) ) {
$args['license_key'] = $this->license_data['license_key'];
}
$url = edd_link_helper(
'https://easydigitaldownloads.com/checkout/',
$args
);
}
if ( $this->expiration ) {
return sprintf(
/* translators: 1. license expiration date; 2. opening link tag; 3. closing link tag. */
__( 'Your license key expired on %1$s. Please %2$srenew your license key%3$s.', 'easy-digital-downloads' ),
edd_date_i18n( $this->expiration ),
'<a href="' . $url . '" target="_blank">',
'</a>'
);
}
return sprintf(
/* translators: 1. opening link tag; 2. closing link tag. */
__( 'Your license key has expired. Please %1$srenew your license key%2$s.', 'easy-digital-downloads' ),
'<a href="' . $url . '" target="_blank">',
'</a>'
);
}
/**
* Gets the message for a disabled license.
*
* @since 3.1.3
* @return string
*/
private function get_disabled_message() {
$url = $this->get_plugin_uri();
if ( empty( $url ) && $this->is_third_party_license() ) {
return __( 'Your license key has been disabled.', 'easy-digital-downloads' );
}
if ( empty( $url ) ) {
$url = edd_link_helper(
'https://easydigitaldownloads.com/support/',
array(
'utm_medium' => 'license-notice',
'utm_content' => 'revoked',
)
);
}
return sprintf(
/* translators: 1. opening link tag; 2. closing link tag. */
__( 'Your license key has been disabled. Please %1$scontact support%2$s for more information.', 'easy-digital-downloads' ),
'<a href="' . $url . '" target="_blank">',
'</a>'
);
}
/**
* Gets the message for a license at its activation limit.
*
* @since 3.1.3
* @return string
*/
private function get_no_activations_message() {
$url = $this->get_plugin_uri();
if ( empty( $url ) && $this->is_third_party_license() ) {
return __( 'Your license key has reached its activation limit.', 'easy-digital-downloads' );
}
if ( empty( $url ) ) {
$url = edd_link_helper(
'https://easydigitaldownloads.com/your-account/',
array(
'utm_medium' => 'license-notice',
'utm_content' => 'at-limit',
)
);
}
return sprintf(
/* translators: 1. opening link tag; 2 closing link tag. */
__( 'Your license key has reached its activation limit. %1$sView possible upgrades%2$s now.', 'easy-digital-downloads' ),
'<a href="' . $url . '">',
'</a>'
);
}
/**
* Gets the message for an inactive license.
*
* @since 3.1.3
* @return string
*/
private function get_inactive_message() {
$url = $this->get_plugin_uri();
if ( empty( $url ) && $this->is_third_party_license() ) {
return __( 'Your license key is not active for this URL.', 'easy-digital-downloads' );
}
if ( empty( $url ) ) {
$url = edd_link_helper(
'https://easydigitaldownloads.com/your-account/',
array(
'utm_medium' => 'license-notice',
'utm_content' => 'inactive',
)
);
}
if ( empty( $this->license_data['name'] ) ) {
return sprintf(
/* translators: 1. opening link tag; 2. closing link tag. */
__( 'Your license key is not active for this URL. Please %1$svisit your account page%2$s to manage your license keys.', 'easy-digital-downloads' ),
'<a href="' . $url . '" target="_blank">',
'</a>'
);
}
return sprintf(
/* translators: 1. the extension name; 2. opening link tag; 3. closing link tag. */
__( 'Your %1$s license key is not active for this URL. Please %2$svisit your account page%3$s to manage your license keys.', 'easy-digital-downloads' ),
esc_html( $this->license_data['name'] ),
'<a href="' . $url . '" target="_blank">',
'</a>'
);
}
/**
* Gets the message for a missing license.
*
* @since 3.1.3
* @return string
*/
private function get_missing_message() {
if ( $this->is_third_party_license() ) {
return __( 'Invalid license. Please verify it.', 'easy-digital-downloads' );
}
$url = edd_link_helper(
'https://easydigitaldownloads.com/your-account/',
array(
'utm_medium' => 'license-notice',
'utm_content' => 'missing',
)
);
return sprintf(
/* translators: 1. opening link tag; 2. closing link tag. */
__( 'Invalid license. Please %1$svisit your account page%2$s and verify it.', 'easy-digital-downloads' ),
'<a href="' . $url . '" target="_blank">',
'</a>'
);
}
/**
* Gets the subscription status label as a translatable string.
*
@ -257,4 +387,36 @@ class Messages {
return array_key_exists( $status, $statii ) ? $statii[ $status ] : $status;
}
/**
* Whether the license is a third-party license.
*
* @since 3.1.3
* @return bool
*/
private function is_third_party_license() {
return ! empty( $this->license_data['api_url'] );
}
/**
* Gets the custom plugin URI for a third-party license.
*
* @since 3.1.3
* @return string
*/
private function get_plugin_uri() {
return $this->is_third_party_license() && ! empty( $this->license_data['uri'] ) ? $this->license_data['uri'] : '';
}
/**
* Sanitizes the third-party license name for use as a hook.
*
* @since <next-version>
* @return string
*/
private function sanitize_third_party_name() {
$name = str_replace( ' ', '_', strtolower( $this->license_data['name'] ) );
return preg_replace( '/[^a-zA-Z0-9_]/', '', $name );
}
}

View File

@ -151,16 +151,23 @@ trait Controls {
$class = 'empty';
$license_status = null;
$status = $this->license->license;
$messages = new \EDD\Licensing\Messages(
array(
'status' => $status,
'license_key' => $this->license_key,
'expires' => ! empty( $this->license->expires ) ? $this->license->expires : '',
'name' => $this->name,
)
$args = array(
'status' => $this->license->license,
'license_key' => $this->license_key,
'expires' => ! empty( $this->license->expires ) ? $this->license->expires : '',
'name' => $this->name,
);
$message = $messages->get_message();
if ( ! empty( $this->args['options']['api_url'] ) ) {
$args['api_url'] = $this->args['options']['api_url'];
if ( ! empty( $this->args['options']['file'] ) && function_exists( 'get_plugin_data' ) ) {
$plugin_data = get_plugin_data( $this->args['options']['file'] );
if ( ! empty( $plugin_data['PluginURI'] ) ) {
$args['uri'] = $plugin_data['PluginURI'];
}
}
}
$messages = new \EDD\Licensing\Messages( $args );
$message = $messages->get_message();
if ( ! empty( $this->license ) ) {
$now = current_time( 'timestamp' );

View File

@ -90,6 +90,10 @@ class Settings {
*/
private function can_include_setting( $setting ) {
if ( empty( $setting ) ) {
return false;
}
// If the setting is marked readonly then it's not really a setting.
if ( ! empty( $setting['args']['readonly'] ) ) {
return false;