updated plugin Easy Digital Downloads version 3.1.1.2

This commit is contained in:
2023-03-17 22:34:04 +00:00
committed by Gitium
parent e8a66564bd
commit 19e086d1c4
647 changed files with 20986 additions and 27305 deletions

View File

@ -158,15 +158,9 @@ function _edds_get_purchase_form_user( $valid_data = array() ) {
}
if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) {
// EDD3: Add the customer address if it doesn't already exist.
if ( function_exists( 'edd_maybe_add_customer_address' ) ) {
$customer = edd_get_customer_by( 'user_id', $user['user_id'] );
if ( $customer ) {
edd_maybe_add_customer_address( $customer->id, $user['address'] );
}
} else {
// Store the address in the user's meta so the cart can be pre-populated with it on return purchases.
update_user_meta( $user['user_id'], '_edd_user_address', $user['address'] );
$customer = edd_get_customer_by( 'user_id', $user['user_id'] );
if ( $customer ) {
edd_maybe_add_customer_address( $customer->id, $user['address'] );
}
}
@ -192,6 +186,9 @@ function _edds_get_purchase_form_user( $valid_data = array() ) {
* @since 2.7.0
*/
function _edds_process_purchase_form() {
// Unset any Errors so they aren't left over form other attempts.
edd_clear_errors();
// Catch exceptions at a high level.
try {
// `edd_process_purchase_form()` and subsequent code executions are written
@ -220,7 +217,7 @@ function _edds_process_purchase_form() {
do_action( 'edd_pre_process_purchase' );
// Make sure the cart isn't empty.
if ( ! edd_get_cart_contents() && ! edd_cart_has_fees() ) {
if ( empty( EDD()->cart->contents ) && empty( EDD()->cart->fees) ) {
throw new \Exception( esc_html__( 'Your cart is empty.', 'easy-digital-downloads' ) );
}
@ -305,15 +302,9 @@ function _edds_process_purchase_form() {
);
if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $address ) ) {
// EDD3: Add the customer address if it doesn't already exist.
if ( function_exists( 'edd_maybe_add_customer_address' ) ) {
$customer = edd_get_customer_by( 'user_id', $user['user_id'] );
if ( $customer ) {
edd_maybe_add_customer_address( $customer->id, $user['address'] );
}
} else {
// Store the address in the user's meta so the cart can be pre-populated with it on return purchases.
update_user_meta( $user['user_id'], '_edd_user_address', $user['address'] );
$customer = edd_get_customer_by( 'user_id', $user['user_id'] );
if ( $customer ) {
edd_maybe_add_customer_address( $customer->id, $user['address'] );
}
}
@ -389,53 +380,72 @@ function _edds_process_purchase_form() {
add_action( 'wp_ajax_edds_process_purchase_form', '_edds_process_purchase_form' );
add_action( 'wp_ajax_nopriv_edds_process_purchase_form', '_edds_process_purchase_form' );
if ( ! function_exists( 'edd_is_dev_environment' ) ) {
/**
* WordPress core function polyfill for WordPress 5.4.
*
* @since 2.9.0
*/
if ( ! function_exists( 'wp_get_environment_type' ) ) {
/**
* Check the network site URL for signs of being a development environment.
* Retrieves the current environment type.
*
* @since 3.0
* The type can be set via the `WP_ENVIRONMENT_TYPE` global system variable,
* or a constant of the same name.
*
* @return bool $retval True if dev, false if not.
* Possible values are 'local', 'development', 'staging', and 'production'.
* If not set, the type defaults to 'production'.
*
* @return string The current environment type.
*/
function edd_is_dev_environment() {
function wp_get_environment_type() {
static $current_env = '';
// Assume not a development environment
$retval = false;
if ( ! defined( 'WP_RUN_CORE_TESTS' ) && $current_env ) {
return $current_env;
}
// Get this one time and use it below
$network_url = network_site_url( '/' );
// Possible strings
$strings = array(
// Popular port suffixes
':8888', // This is common with MAMP on OS X
// Popular development TLDs
'.dev', // VVV
'.local', // Local
'.test', // IETF
'.example', // IETF
'.invalid', // IETF
'.localhost', // IETF
// Popular development subdomains
'dev.',
// Popular development domains
'localhost',
'example.com',
$wp_environments = array(
'local',
'development',
'staging',
'production',
);
// Loop through all strings
foreach ( $strings as $string ) {
if ( stristr( $network_url, $string ) ) {
$retval = $string;
break;
// Add a note about the deprecated WP_ENVIRONMENT_TYPES constant.
if ( defined( 'WP_ENVIRONMENT_TYPES' ) && function_exists( '_deprecated_argument' ) ) {
if ( function_exists( '__' ) ) {
/* translators: %s: WP_ENVIRONMENT_TYPES */
$message = sprintf( __( 'The %s constant is no longer supported.' ), 'WP_ENVIRONMENT_TYPES' );
} else {
$message = sprintf( 'The %s constant is no longer supported.', 'WP_ENVIRONMENT_TYPES' );
}
_deprecated_argument(
'define()',
'5.5.1',
$message
);
}
// Check if the environment variable has been set, if `getenv` is available on the system.
if ( function_exists( 'getenv' ) ) {
$has_env = getenv( 'WP_ENVIRONMENT_TYPE' );
if ( false !== $has_env ) {
$current_env = $has_env;
}
}
// Filter & return
return apply_filters( 'edd_is_dev_environment', $retval );
// Fetch the environment from a constant, this overrides the global system variable.
if ( defined( 'WP_ENVIRONMENT_TYPE' ) && WP_ENVIRONMENT_TYPE ) {
$current_env = WP_ENVIRONMENT_TYPE;
}
// Make sure the environment is an allowed one, and not accidentally set to an invalid value.
if ( ! in_array( $current_env, $wp_environments, true ) ) {
$current_env = 'production';
}
return $current_env;
}
}