updated plugin Easy Digital Downloads version 3.1.4

This commit is contained in:
2023-07-19 21:08:59 +00:00
committed by Gitium
parent a7f6efbebb
commit 9a42dc17d2
109 changed files with 12446 additions and 5563 deletions

View File

@ -89,8 +89,9 @@ function edd_maybe_add_store_mode_admin_bar_menu( $wp_admin_bar ) {
$wp_admin_bar->add_menu( array(
'parent' => 'edd-store-menu',
'id' => 'edd-store-prodcuts',
/* translators: plural downlaods label */
'title' => sprintf( __( 'All %1$s', 'easy-digital-downloads' ), edd_get_label_plural() ),
'href' => edd_get_admin_url(),
'href' => edd_get_admin_url(),
) );
// String.
@ -106,8 +107,9 @@ function edd_maybe_add_store_mode_admin_bar_menu( $wp_admin_bar ) {
$wp_admin_bar->add_menu( array(
'parent' => 'edd-store-menu',
'id' => 'edd-store-status',
/* translators: %s: store status ("Test Mode" or "Live Mode") */
'title' => sprintf( __( 'Store Status: %s', 'easy-digital-downloads' ), '<span class="edd-mode edd-mode-' . esc_attr( $mode ) . '">' . $text . '</span>' ),
'href' => edd_get_admin_url(
'href' => edd_get_admin_url(
array(
'page' => 'edd-settings',
'tab' => 'gateways',
@ -140,9 +142,10 @@ function edd_maybe_add_store_mode_admin_bar_menu( $wp_admin_bar ) {
if ( ! empty( $is_dev ) ) {
$wp_admin_bar->add_menu( array(
'id' => 'edd-is-dev',
/* translators: %s: Whether this is a development domain (1 for true, 0 for false) */
'title' => sprintf( __( 'Development Domain %s', 'easy-digital-downloads' ), '<span class="edd-mode">' . $is_dev . '</span>' ),
'parent' => 'edd-store-menu',
'href' => edd_get_admin_url(
'href' => edd_get_admin_url(
array(
'page' => 'edd-settings',
'tab' => 'gateways',

View File

@ -23,8 +23,10 @@ if( !defined( 'ABSPATH' ) ) exit;
function edd_admin_rate_us( $footer_text ) {
global $typenow;
if ( $typenow == 'download' ) {
$rate_text = sprintf( __( 'Thank you for using <a href="%1$s" target="_blank">Easy Digital Downloads</a>! Please <a href="%2$s" target="_blank">rate us on WordPress.org</a>', 'easy-digital-downloads' ),
if ( 'download' === $typenow ) {
$rate_text = sprintf(
/* translators: 1. link to EDD site; 2. link to wordpress.org to review */
__( 'Thank you for using <a href="%1$s" target="_blank">Easy Digital Downloads</a>! Please <a href="%2$s" target="_blank">rate us on WordPress.org</a>', 'easy-digital-downloads' ),
'https://easydigitaldownloads.com',
'https://wordpress.org/support/plugin/easy-digital-downloads/reviews/?rate=5#new-post'
);

View File

@ -269,9 +269,10 @@ class EDD_Notices {
if ( empty( $purchase_page ) || ( 'trash' === get_post_status( $purchase_page ) ) ) {
$this->add_notice( array(
'id' => 'edd-no-purchase-page',
/* translators: %s: URL to the settings page */
'message' => sprintf( __( 'No checkout page is configured. Set one in <a href="%s">Settings</a>.', 'easy-digital-downloads' ), esc_url( edd_get_admin_url( array( 'page' => 'edd-settings', 'tab' => 'general', 'section' => 'pages' ) ) ) ),
'class' => 'error',
'is_dismissible' => false
'is_dismissible' => false,
) );
}
}
@ -324,8 +325,10 @@ class EDD_Notices {
'class' => 'error',
'is_dismissible' => false,
'message' => array(
/* translators: %s: Uploads directory */
sprintf( __( 'The files in %s are not currently protected.', 'easy-digital-downloads' ), '<code>' . $upload_directory . '</code>' ),
__( 'To protect them, you must add this <a href="https://easydigitaldownloads.com/docs/download-files-not-protected-on-nginx/">NGINX redirect rule</a>.', 'easy-digital-downloads' ),
/* translators: %s: Dismiss notice URL */
sprintf( __( 'If you have already done this, or it does not apply to your site, you may permenently %s.', 'easy-digital-downloads' ), '<a href="' . esc_url( $dismiss_notice_url ) . '">' . __( 'dismiss this notice', 'easy-digital-downloads' ) . '</a>' )
)
) );
@ -366,7 +369,8 @@ class EDD_Notices {
'class' => 'error',
'is_dismissible' => false,
'message' => sprintf(
__( 'Easy Digital Downloads 2.5 contains a <a href="%s">built in recount tool</a>. Please <a href="%s">deactivate the Easy Digital Downloads - Recount Earnings plugin</a>', 'easy-digital-downloads' ),
/* translators: 1. link to the recount tool; 2. link to the plugins screen. */
__( 'Easy Digital Downloads 2.5 contains a <a href="%1$s">built in recount tool</a>. Please <a href="%2$s">deactivate the Easy Digital Downloads - Recount Earnings plugin</a>', 'easy-digital-downloads' ),
esc_url( edd_get_admin_url( array( 'page' => 'edd-tools', 'tab' => 'general' ) ) ),
esc_url( admin_url( 'plugins.php' ) )
)
@ -433,6 +437,24 @@ class EDD_Notices {
)
);
}
if ( 'accounting' === filter_input( INPUT_GET, 'section', FILTER_SANITIZE_STRING ) ) {
if ( ! empty( edd_get_option( 'sequential_start_update_failed', false ) ) ) {
$order_number = new \EDD\Orders\Number();
$this->add_notice(
array(
'id' => 'edd-sequential-order-numbers-not-updated',
'message' => sprintf(
/* translators: %s: Next order number */
__( 'The sequential starting number could not be updated because it could conflict with existing orders. The next assigned order number is %s.', 'easy-digital-downloads' ),
'<code>' . $order_number->format( (int) get_option( 'edd_next_order_number' ) ) . '</code>'
),
'class' => 'error',
)
);
edd_delete_option( 'sequential_start_update_failed' );
}
}
}
/**

View File

@ -66,12 +66,14 @@ function edd_edit_customer( $args = array() ) {
// Make sure we don't already have this user attached to a customer
if ( ! empty( $customer_info['user_id'] ) && false !== edd_get_customer_by( 'user_id', $customer_info['user_id'] ) ) {
/* translators: %d: user ID */
edd_set_error( 'edd-invalid-customer-user_id', sprintf( __( 'The User ID %d is already associated with a different customer.', 'easy-digital-downloads' ), $customer_info['user_id'] ) );
}
// Make sure it's actually a user
$user = get_user_by( 'id', $customer_info['user_id'] );
if ( ! empty( $customer_info['user_id'] ) && false === $user ) {
/* translators: %d: user ID */
edd_set_error( 'edd-invalid-user_id', sprintf( __( 'The User ID %d does not exist. Please assign an existing user.', 'easy-digital-downloads' ), $customer_info['user_id'] ) );
}
}
@ -98,6 +100,7 @@ function edd_edit_customer( $args = array() ) {
if ( $user ) {
$user_id = $user->ID;
} else {
/* translators: %s: user login or email address */
edd_set_error( 'edd-invalid-user-string', sprintf( __( 'Failed to attach user. The login or email address %s was not found.', 'easy-digital-downloads' ), $customer_info['user_login'] ) );
}
}
@ -259,13 +262,15 @@ function edd_add_customer_email( $args = array() ) {
'redirect' => $redirect . '#edd_general_emails',
);
$user = wp_get_current_user();
$user_login = ! empty( $user->user_login ) ? $user->user_login : edd_get_bot_name();
$customer_note = sprintf( __( 'Email address %s added by %s', 'easy-digital-downloads' ), $email, $user_login );
$user = wp_get_current_user();
$user_login = ! empty( $user->user_login ) ? $user->user_login : edd_get_bot_name();
/* translators: 1. email address; 2. username */
$customer_note = sprintf( __( 'Email address %1$s added by %2$s', 'easy-digital-downloads' ), $email, $user_login );
$customer->add_note( $customer_note );
if ( $primary ) {
$customer_note = sprintf( __( 'Email address %s set as primary by %s', 'easy-digital-downloads' ), $email, $user_login );
/* translators: 1. email address; 2. username */
$customer_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'easy-digital-downloads' ), $email, $user_login );
$customer->add_note( $customer_note );
}
}
@ -320,9 +325,10 @@ function edd_remove_customer_email() {
'edd-message' => 'email-removed',
)
);
$user = wp_get_current_user();
$user_login = ! empty( $user->user_login ) ? $user->user_login : edd_get_bot_name();
$customer_note = sprintf( __( 'Email address %s removed by %s', 'easy-digital-downloads' ), sanitize_email( $_GET['email'] ), $user_login );
$user = wp_get_current_user();
$user_login = ! empty( $user->user_login ) ? $user->user_login : edd_get_bot_name();
/* translators: 1. email address; 2. username */
$customer_note = sprintf( __( 'Email address %1$s removed by %2$s', 'easy-digital-downloads' ), sanitize_email( $_GET['email'] ), $user_login );
$customer->add_note( $customer_note );
} else {

View File

@ -104,8 +104,9 @@ function edd_maybe_remove_menu_profile_links() {
if ( edd_user_pending_verification() ) {
if( defined( 'IS_PROFILE_PAGE' ) && true === IS_PROFILE_PAGE ) {
$url = esc_url( edd_get_user_verification_request_url() );
if ( defined( 'IS_PROFILE_PAGE' ) && true === IS_PROFILE_PAGE ) {
$url = esc_url( edd_get_user_verification_request_url() );
/* translators: link to send an email */
$message = sprintf( __( 'Your account is pending verification. Please click the link in your email to activate your account. No email? <a href="%s">Click here</a> to send a new activation code.', 'easy-digital-downloads' ), esc_url( $url ) );
$title = __( 'Account Pending Verification', 'easy-digital-downloads' );
$args = array(

View File

@ -256,6 +256,7 @@ function edd_customers_list( $active_tab = 'customers' ) {
<form id="edd-customers-filter" method="get" action="<?php echo esc_url( $action_url ); ?>">
<?php
$customers_table->views();
/* translators: the active screen, eg "Search Customers" or "Search Customer Email Addresses" */
$customers_table->search_box( sprintf( __( 'Search %s', 'easy-digital-downloads' ), $name ), 'edd-customers' );
$customers_table->display();
?>
@ -560,6 +561,7 @@ function edd_customers_view( $customer = null ) {
<span data-key="user_id">
<?php if ( empty( $user_login ) ) :
/* translators: %s: user id */
printf( __( 'User %s missing', 'easy-digital-downloads' ), '<code>' . esc_html( $user_id ) . '</code>');
endif; ?>
<a href="<?php echo esc_url( admin_url( 'user-edit.php?user_id=' . absint( $user_id ) ) ); ?>"><?php echo esc_html( $user_login ); ?></a>
@ -776,7 +778,12 @@ function edd_customers_view( $customer = null ) {
</tbody>
</table>
<h3><?php printf( __( 'Purchased %s', 'easy-digital-downloads' ), edd_get_label_plural() ); ?></h3>
<h3>
<?php
/* translators: %s: plural downloads label */
printf( esc_html__( 'Purchased %s', 'easy-digital-downloads' ), esc_html( edd_get_label_plural() ) );
?>
</h3>
<table class="wp-list-table widefat striped customer-downloads">
<thead>
<tr>
@ -796,7 +803,12 @@ function edd_customers_view( $customer = null ) {
<?php else: ?>
<tr><td class="no-items"><?php printf( __( 'No %s Found', 'easy-digital-downloads' ), edd_get_label_plural() ); ?></td></tr>
<tr><td class="no-items">
<?php
/* translators: %s: plural downloads label */
printf( esc_html__( 'No %s Found', 'easy-digital-downloads' ), esc_html( edd_get_label_plural() ) );
?>
</td></tr>
<?php endif; ?>
</tbody>

View File

@ -96,9 +96,13 @@ function edd_admin_add_discount( $data = array() ) {
? intval( $data['start_date_minute'] )
: '00';
$start_date_string = EDD()->utils->get_date_string(
$start_date,
$start_date_hour,
$start_date_minute
);
// The start date is entered in the user's WP timezone. We need to convert it to UTC prior to saving now.
$date = edd_get_utc_equivalent_date( EDD()->utils->date( $start_date . ' ' . $start_date_hour . ':' . $start_date_minute . ':00', edd_get_timezone_id(), false ) );
$to_add['start_date'] = $date->format( 'Y-m-d H:i:s' );
$to_add['start_date'] = edd_get_utc_date_string( $start_date_string );
}
// End date.
@ -111,9 +115,13 @@ function edd_admin_add_discount( $data = array() ) {
? intval( $data['end_date_minute'] )
: '59';
$end_date_string = EDD()->utils->get_date_string(
$end_date,
$end_date_hour,
$end_date_minute,
);
// The end date is entered in the user's WP timezone. We need to convert it to UTC prior to saving now.
$date = edd_get_utc_equivalent_date( EDD()->utils->date( $end_date . ' ' . $end_date_hour . ':' . $end_date_minute . ':00', edd_get_timezone_id(), false ) );
$to_add['end_date'] = $date->format( 'Y-m-d H:i:s' );
$to_add['end_date'] = edd_get_utc_date_string( $end_date_string );
}
// Meta values.
@ -229,9 +237,14 @@ function edd_admin_edit_discount( $data = array() ) {
? intval( $data['start_date_minute'] )
: '00';
$start_date_string = EDD()->utils->get_date_string(
$start_date,
$start_date_hour,
$start_date_minute,
);
// The start date is entered in the user's WP timezone. We need to convert it to UTC prior to saving now.
$date = edd_get_utc_equivalent_date( EDD()->utils->date( $start_date . ' ' . $start_date_hour . ':' . $start_date_minute . ':00', edd_get_timezone_id(), false ) );
$to_update['start_date'] = $date->format( 'Y-m-d H:i:s' );
$to_update['start_date'] = edd_get_utc_date_string( $start_date_string );
} else {
$to_update['start_date'] = null;
}
@ -246,9 +259,14 @@ function edd_admin_edit_discount( $data = array() ) {
? intval( $data['end_date_minute'] )
: '59';
$end_date_string = EDD()->utils->get_date_string(
$end_date,
$end_date_hour,
$end_date_minute
);
// The end date is entered in the user's WP timezone. We need to convert it to UTC prior to saving now.
$date = edd_get_utc_equivalent_date( EDD()->utils->date( $end_date . ' ' . $end_date_hour . ':' . $end_date_minute . ':00', edd_get_timezone_id(), false ) );
$to_update['end_date'] = $date->format( 'Y-m-d H:i:s' );
$to_update['end_date'] = edd_get_utc_date_string( $end_date_string );
} else {
$to_update['end_date'] = null;
}

View File

@ -94,10 +94,7 @@ function edd_update_payment_details( $data = array() ) {
);
// The date is entered in the WP timezone. We need to convert it to UTC prior to saving now.
$date = edd_get_utc_equivalent_date( EDD()->utils->date( $date_string, edd_get_timezone_id(), false ) );
$date = $date->format( 'Y-m-d H:i:s' );
$order_update_args['date_created'] = $date;
$order_update_args['date_created'] = edd_get_utc_date_string( $date_string );
// Customer
$curr_customer_id = sanitize_text_field( $data['current-customer-id'] );

View File

@ -879,24 +879,18 @@ class EDD_Payment_History_Table extends List_Table {
// Start (of day)
if ( ! empty( $start_date ) ) {
$start_date_obj = EDD()->utils->date( $start_date, edd_get_timezone_id(), false )->copy()->startOfDay();
$query_start_date = edd_get_utc_equivalent_date( $start_date_obj->copy() );
$args['date_query'][] = array(
'column' => 'date_created',
'after' => $query_start_date->format( 'mysql' ),
'after' => edd_get_utc_date_string( $start_date, 'mysql' ),
);
}
// End (of day)
if ( ! empty( $end_date ) ) {
$end_date_obj = EDD()->utils->date( $end_date, edd_get_timezone_id(), false )->copy()->endOfDay();
$query_end_date = edd_get_utc_equivalent_date( $end_date_obj->copy() );
$end_date_string = EDD()->utils->get_date_string( $end_date, 23, 59, 59 );
$args['date_query'][] = array(
'column' => 'date_created',
'before' => $query_end_date->format( 'mysql' ),
'column' => 'date_created',
'before' => edd_get_utc_date_string( $end_date_string, 'mysql' ),
);
}
}

View File

@ -307,6 +307,10 @@ function edd_order_details_email( $order ) {
$customer = edd_get_customer( $order->customer_id );
$all_emails = array( 'primary' => $customer->email );
if ( $customer->email !== $order->email ) {
$all_emails['order'] = $order->email;
}
foreach ( $customer->emails as $key => $email ) {
if ( $customer->email === $email ) {
continue;
@ -315,59 +319,63 @@ function edd_order_details_email( $order ) {
$all_emails[ $key ] = $email;
}
$help = __( 'Send a new copy of the purchase receipt to the email address used for this order. If download URLs were included in the original receipt, new ones will be included.', 'easy-digital-downloads' );
$help = sprintf(
/* translators: email type */
__('Send a new copy of the purchase receipt to the %s email address. If download URLs were included in the original receipt, new ones will be included.', 'easy-digital-downloads' ),
count( $all_emails ) > 1 ? __( 'selected', 'easy-digital-downloads' ) : __( 'customer', 'easy-digital-downloads' )
);
$is_multiselect = count( $all_emails ) > 1;
$label_text = $is_multiselect ? __( 'Send email receipt to', 'easy-digital-downloads' ) : __( 'Email Address', 'easy-digital-downloads' );
?>
<div>
<?php
if ( ! empty( $customer->emails ) && count( (array) $customer->emails ) > 1 ) : ?>
<fieldset class="edd-form-group">
<legend class="edd-form-group__label">
<?php _e( 'Send email receipt to', 'easy-digital-downloads' ); ?>
</legend>
<div class="edd-form-group">
<label class="edd-form-group__label <?php echo esc_attr( ! $is_multiselect ? 'screen-reader-text' : '' ); ?>"
for="edd-order-receipt-email"
>
<?php echo esc_html( $label_text ); ?>
</label>
<?php foreach ( $all_emails as $key => $email ) : ?>
<div class="edd-form-group__control is-radio">
<input id="<?php echo rawurlencode( sanitize_email( $email ) ); ?>" class="edd-form-group__input edd-order-resend-receipt-email" name="edd-order-resend-receipt-address" type="radio" value="<?php echo rawurlencode( sanitize_email( $email ) ); ?>" <?php checked( true, ( 'primary' === $key ) ); ?> />
<label for="<?php echo rawurlencode( sanitize_email( $email ) ); ?>">
<?php echo esc_attr( $email ); ?>
</label>
</div>
<?php endforeach; ?>
<p class="edd-form-group__help description">
<?php echo esc_html( $help ); ?>
</p>
</fieldset>
<?php else : ?>
<div class="edd-form-group">
<label class="edd-form-group__label screen-reader-text" for="<?php echo esc_attr( $order->email ); ?>">
<?php esc_html_e( 'Email Address', 'easy-digital-downloads' ); ?>
</label>
<div class="edd-form-group__control">
<input readonly type="email" id="<?php echo esc_attr( $order->email ); ?>" class="edd-form-group__input regular-text" value="<?php echo esc_attr( $order->email ); ?>" />
</div>
<p class="edd-form-group__help description">
<?php echo esc_html( $help ); ?>
</p>
<div class="edd-form-group__control">
<?php if ( $is_multiselect ) : ?>
<select class="edd-form-group__input edd-order-resend-receipt-email" name="edd-select-receipt-email" id="edd-order-receipt-email">
<?php foreach ( $all_emails as $key => $email ) : ?>
<option
value="<?php echo rawurlencode( sanitize_email( $email ) ); ?>"
<?php selected( 'primary', $key ); ?>
>
<?php
echo sprintf(
'%1$s (%2$s)',
esc_attr( $email ),
esc_html(
$key === 'primary' ? __( 'Customer Primary', 'easy-digital-downloads' ) :
(
$key === 'order' ? __( 'Order Email', 'easy-digital-downloads' ) :
__( 'Customer Email', 'easy-digital-downloads' )
)
)
);
?>
</option>
<?php endforeach; ?>
</select>
<?php else : ?>
<input readonly type="email" id="edd-order-receipt-email" class="edd-form-group__input regular-text" value="<?php echo esc_attr( $order->email ); ?>" />
<?php endif; ?>
</div>
<?php endif; ?>
<p class="edd-form-group__help description">
<?php echo esc_html( $help ); ?>
</p>
</div>
<p>
<a href="<?php echo esc_url( add_query_arg( array(
'edd-action' => 'email_links',
'purchase_id' => absint( $order->id ),
) ) ); ?>" id="<?php if ( ! empty( $customer->emails ) && count( (array) $customer->emails ) > 1 ) {
echo esc_attr( 'edd-select-receipt-email' );
} else {
echo esc_attr( 'edd-resend-receipt' );
} ?>" class="button button-secondary"><?php esc_html_e( 'Resend Receipt', 'easy-digital-downloads' ); ?></a>
) ) ); ?>" id="<?php echo esc_attr( 'edd-resend-receipt' ); ?>" class="button button-secondary"><?php esc_html_e( 'Resend Receipt', 'easy-digital-downloads' ); ?></a>
</p>
<?php do_action( 'edd_view_order_details_resend_receipt_after', $order->id ); ?>
@ -1121,21 +1129,45 @@ function edd_is_add_order_page() {
* @return string
*/
function edd_get_order_status_badge( $order_status ) {
switch( $order_status ) {
case 'refunded' :
$icon = '<span class="edd-admin-order-status-badge__icon dashicons dashicons-undo"></span>';
$icon = '';
$status = $order_status;
switch ( $order_status ) {
case 'refunded':
$icon = 'undo';
break;
case 'failed' :
$icon = '<span class="edd-admin-order-status-badge__icon dashicons dashicons-no-alt"></span>';
case 'failed':
$icon = 'no-alt';
$status = 'error';
break;
case 'complete' :
$icon = '<span class="edd-admin-order-status-badge__icon dashicons dashicons-yes"></span>';
case 'complete':
case 'partially_refunded':
$icon = 'yes';
$status = 'success';
break;
case 'pending':
$status = 'warning';
break;
default:
$icon = '';
}
/**
* Filters the arguments for the order status badge.
*
* @since 3.1.4
* @param array $status_badge_args Array of arguments for the status badge.
* @param string $order_status Order status slug.
*/
$status_badge_args = apply_filters(
'edd_get_order_status_badge_args',
array(
'status' => $status,
'label' => edd_get_payment_status_label( $order_status ),
'icon' => $icon,
'class' => "edd-admin-order-status-badge--{$order_status}",
),
$order_status
);
$status_badge = new EDD\Utils\StatusBadge( $status_badge_args );
/**
* Filters the markup for the order status badge icon.
*
@ -1143,54 +1175,7 @@ function edd_get_order_status_badge( $order_status ) {
*
* @param string $icon Icon HTML markup.
*/
$icon = apply_filters( 'edd_get_order_status_badge_icon', $icon, $order_status );
$icon = apply_filters( 'edd_get_order_status_badge_icon', $status_badge->get_icon(), $order_status );
ob_start();
?>
<span class="edd-admin-order-status-badge edd-admin-order-status-badge--<?php echo esc_attr( $order_status ); ?>">
<span class="edd-admin-order-status-badge__text">
<?php echo edd_get_payment_status_label( $order_status ); ?>
</span>
<span class="edd-admin-order-status-badge__icon">
<?php
echo wp_kses(
$icon,
array(
'span' => array(
'class' => true,
),
'svg' => array(
'class' => true,
'xmlns' => true,
'width' => true,
'height' => true,
'viewbox' => true,
'aria-hidden' => true,
'role' => true,
'focusable' => true,
),
'path' => array(
'fill' => true,
'fill-rule' => true,
'd' => true,
'transform' => true,
),
'polygon' => array(
'fill' => true,
'fill-rule' => true,
'points' => true,
'transform' => true,
'focusable' => true,
),
)
);
?>
</span>
</span>
<?php
return ob_get_clean();
return $status_badge->get( $icon );
}

View File

@ -149,8 +149,9 @@ class EDD_File_Downloads_Log_Table extends EDD_Base_Log_List_Table {
*/
$file_id = apply_filters( 'edd_log_file_download_file_id', $file_id, $log );
$file_name = '';
if ( ! empty( $files ) && is_numeric( $file_id ) && isset( $files[ $file_id ] ) ) {
$file_name = edd_get_file_download_log_meta( $log->id, 'file_name', true );
if ( empty( $file_name ) && is_array( $files ) && isset( $files[ $file_id ] ) ) {
$file_name = ! empty( $files[ $file_id ]['name'] )
? $files[ $file_id ]['name']
: edd_get_file_name( $files[ $file_id ] );

View File

@ -328,7 +328,6 @@ class EDD_Batch_Export extends EDD_Export {
* @return array
*/
protected function get_date_query() {
$time_zone = edd_get_timezone_id();
$date_query = array(
'after' => '',
'before' => '',
@ -336,13 +335,13 @@ class EDD_Batch_Export extends EDD_Export {
);
if ( $this->start ) {
$date = edd_get_utc_equivalent_date( EDD()->utils->date( $this->start . '00:00:00', $time_zone, false ) );
$date_query['after'] = $date->format( 'Y-m-d H:i:s' );
$start_date_string = EDD()->utils->get_date_string( $this->start );
$date_query['after'] = edd_get_utc_date_string( $start_date_string );
}
if ( $this->end ) {
$date = edd_get_utc_equivalent_date( EDD()->utils->date( $this->end . '23:59:59', $time_zone, false ) );
$date_query['before'] = $date->format( 'Y-m-d H:i:s' );
$end_date_string = EDD()->utils->get_date_string( $this->end, 23, 59, 59 );
$date_query['before'] = edd_get_utc_date_string( $end_date_string );
}
return array( $date_query );

View File

@ -27,6 +27,7 @@ function edd_media_button() {
// Setup the icon
$icon = '<span class="wp-media-buttons-icon dashicons dashicons-download" id="edd-media-button"></span>';
/* translators: singular download label */
$text = sprintf( __( 'Insert %s', 'easy-digital-downloads' ), edd_get_label_singular() );
// Output the thickbox button

View File

@ -152,9 +152,19 @@ function edd_tools_recount_stats_display() {
<option data-type="recount-store"
value="EDD_Tools_Recount_Store_Earnings"><?php esc_html_e( 'Recount Store Earnings and Sales', 'easy-digital-downloads' ); ?></option>
<option data-type="recount-download"
value="EDD_Tools_Recount_Download_Stats"><?php printf( __( 'Recount Earnings and Sales for a %s', 'easy-digital-downloads' ), edd_get_label_singular( true ) ); ?></option>
value="EDD_Tools_Recount_Download_Stats">
<?php
/* translators: %s: Singular download label, lowercase */
printf( esc_html__( 'Recount Earnings and Sales for a %s', 'easy-digital-downloads' ), esc_html( edd_get_label_singular( true ) ) );
?>
</option>
<option data-type="recount-all"
value="EDD_Tools_Recount_All_Stats"><?php printf( __( 'Recount Earnings and Sales for All %s', 'easy-digital-downloads' ), edd_get_label_plural( true ) ); ?></option>
value="EDD_Tools_Recount_All_Stats">
<?php
/* translators: %s: Plural download label, lowercase */
printf( esc_html__( 'Recount Earnings and Sales for All %s', 'easy-digital-downloads' ), esc_html( edd_get_label_plural( true ) ) );
?>
</option>
<option data-type="recount-customer-stats"
value="EDD_Tools_Recount_Customer_Stats"><?php esc_html_e( 'Recount Customer Stats', 'easy-digital-downloads' ); ?></option>
<?php do_action( 'edd_recount_tool_options' ); ?>
@ -180,11 +190,21 @@ function edd_tools_recount_stats_display() {
<span class="edd-recount-stats-descriptions">
<span id="recount-store"><?php _e( 'Recalculates the total store earnings and sales.', 'easy-digital-downloads' ); ?></span>
<span id="recount-download"><?php printf( __( 'Recalculates the earnings and sales stats for a specific %s.', 'easy-digital-downloads' ), edd_get_label_singular( true ) ); ?></span>
<span id="recount-all"><?php printf( __( 'Recalculates the earnings and sales stats for all %s.', 'easy-digital-downloads' ), edd_get_label_plural( true ) ); ?></span>
<span id="recount-customer-stats"><?php _e( 'Recalculates the lifetime value and purchase counts for all customers.', 'easy-digital-downloads' ); ?></span>
<span id="recount-download">
<?php
/* translators: %s: Singular wownload label, lowercase */
printf( esc_html__( 'Recalculates the earnings and sales stats for a specific %s.', 'easy-digital-downloads' ), esc_html( edd_get_label_singular( true ) ) );
?>
</span>
<span id="recount-all">
<?php
/* translators: %s: Pural download label, lowercase */
printf( esc_html__( 'Recalculates the earnings and sales stats for all %s.', 'easy-digital-downloads' ), esc_html( edd_get_label_plural( true ) ) );
?>
</span>
<span id="recount-customer-stats"><?php esc_html_e( 'Recalculates the lifetime value and purchase counts for all customers.', 'easy-digital-downloads' ); ?></span>
<?php do_action( 'edd_recount_tool_descriptions' ); ?>
<span id="reset-stats"><?php _e( '<strong>Deletes</strong> all payment records, customers, and related log entries.', 'easy-digital-downloads' ); ?></span>
<span id="reset-stats"><?php echo wp_kses_post( __( '<strong>Deletes</strong> all payment records, customers, and related log entries.', 'easy-digital-downloads' ) ); ?></span>
</span>
<span class="spinner"></span>
@ -270,12 +290,16 @@ function edd_tools_api_keys_display() {
<p>
<?php
printf(
__( 'These API keys allow you to use the <a href="%s">EDD REST API</a> to retrieve store data in JSON or XML for external applications or devices, such as the <a href="%s">EDD mobile app</a>.', 'easy-digital-downloads' ),
$docs_link,
$ios_link
wp_kses_post(
/* translators: %1$s: API documentation linktag , %2$s: iOS app link tag, %3$s: closing link tag */
__( 'These API keys allow you to use the %1$sEDD REST API%3$s to retrieve store data in JSON or XML for external applications or devices, such as the %2$sEDD mobile app%3$s.', 'easy-digital-downloads' )
),
'<a href="' . esc_url( $docs_link ) . '">',
'<a href="' . esc_url( $ios_link ) . '">',
'</a>'
);
?>
</p>
</p>
<?php
do_action( 'edd_tools_api_keys_after' );
@ -315,7 +339,12 @@ function edd_tools_betas_display() {
<input type="checkbox" name="enabled_betas[<?php echo esc_attr( $slug ); ?>]"
id="enabled_betas[<?php echo esc_attr( $slug ); ?>]"<?php echo checked( $checked, true, false ); ?>
value="1"/>
<label for="enabled_betas[<?php echo esc_attr( $slug ); ?>]"><?php printf( __( 'Get updates for pre-release versions of %s', 'easy-digital-downloads' ), esc_html( $product ) ); ?></label>
<label for="enabled_betas[<?php echo esc_attr( $slug ); ?>]">
<?php
/* translators: %s: Product name */
printf( esc_html__( 'Get updates for pre-release versions of %s', 'easy-digital-downloads' ), esc_html( $product ) );
?>
</label>
</td>
</tr>
<?php endforeach; ?>
@ -483,7 +512,7 @@ function edd_tools_import_export_display() {
<input name="edd-import-file" id="edd-payments-import-file" type="file" accept=".csv" required/>
</p>
<span>
<input type="submit" value="<?php _e( 'Import CSV', 'easy-digital-downloads' ); ?>"
<input type="submit" value="<?php esc_html_e( 'Import CSV', 'easy-digital-downloads' ); ?>"
class="button-secondary"/>
<span class="spinner"></span>
</span>
@ -494,8 +523,12 @@ function edd_tools_import_export_display() {
<p>
<?php
printf(
__( 'Each column loaded from the CSV needs to be mapped to an order field. Select the column that should be mapped to each field below. Any columns not needed can be ignored. See <a href="%s" target="_blank">this guide</a> for assistance with importing payment records.', 'easy-digital-downloads' ),
'https://easydigitaldownloads.com/docs/importing-exporting-orders/'
wp_kses_post(
/* translators: %1$s opening anchor tag, %2$s closing anchor tag */
__( 'Each column loaded from the CSV needs to be mapped to an order field. Select the column that should be mapped to each field below. Any columns not needed can be ignored. See %1$sthis guide%2$s for assistance with importing payment records.', 'easy-digital-downloads' )
),
'<a href="https://easydigitaldownloads.com/docs/importing-exporting-orders/" target="_blank">',
'</a>'
);
?>
</p>
@ -809,8 +842,12 @@ function edd_tools_import_export_display() {
<p>
<?php
printf(
__( 'Each column loaded from the CSV needs to be mapped to a Download product field. Select the column that should be mapped to each field below. Any columns not needed can be ignored. See <a href="%s" target="_blank">this guide</a> for assistance with importing Download products.', 'easy-digital-downloads' ),
'https://easydigitaldownloads.com/docs/importing-exporting-products/'
wp_kses_post(
/* translators: %1$s and %2$s opening and closing anchor tags respectively */
__( 'Each column loaded from the CSV needs to be mapped to a Download product field. Select the column that should be mapped to each field below. Any columns not needed can be ignored. See %1$sthis guide%2$s for assistance with importing Download products.', 'easy-digital-downloads' ),
'<a href="https://easydigitaldownloads.com/docs/importing-exporting-products/" target="_blank">',
'</a>'
)
);
?>
</p>
@ -1005,13 +1042,18 @@ function edd_tools_import_export_display() {
<p>
<?php
printf(
__( 'To export shop data (purchases, customers, etc), visit the <a href="%s">Reports</a> page.', 'easy-digital-downloads' ),
esc_url( edd_get_admin_url(
array(
'page' => 'edd-reports',
'view' => 'export',
wp_kses_post(
/* translators: %s: Reports page URL */
__( 'To export shop data (purchases, customers, etc), visit the <a href="%s">Reports</a> page.', 'easy-digital-downloads' )
),
esc_url(
edd_get_admin_url(
array(
'page' => 'edd-reports',
'view' => 'export',
)
)
) )
)
);
?>
</p>
@ -1188,23 +1230,36 @@ function edd_tools_debug_log_display() {
: esc_html__( 'No File', 'easy-digital-downloads' );
$log_output = ! empty( $log )
? wp_normalize_path( $log )
: esc_html__( 'Log is Empty', 'easy-digital-downloads' ); ?>
: esc_html__( 'Log is Empty', 'easy-digital-downloads' );
?>
<div class="postbox">
<h3><span><?php esc_html_e( 'Debug Log', 'easy-digital-downloads' ); ?></span></h3>
<div class="inside">
<form id="edd-debug-log" method="post">
<p><?php _e( 'When debug mode is enabled, specific information will be logged here. (<a href="https://github.com/easydigitaldownloads/easy-digital-downloads/blob/master/includes/class-edd-logging.php">Learn how</a> to use <code>EDD_Logging</code> in your own code.)', 'easy-digital-downloads' ); ?></p>
<textarea
<div class="postbox">
<h3><span><?php esc_html_e( 'Debug Log', 'easy-digital-downloads' ); ?></span></h3>
<div class="inside">
<form id="edd-debug-log" method="post">
<p>
<?php
printf(
wp_kses_post(
/* translators: 1. opening anchor tag, do not translate; 2. function name, do not translate; 3. closing anchor tag, do not translate */
__( 'When debug mode is enabled, specific information will be logged here. (%1$sLearn how to use %2$s in your own code.%3$s)', 'easy-digital-downloads' )
),
'<a href="https://easydigitaldownloads.com/docs/edd-debug-log">',
'<code>edd_debug_log</code>',
'</a>'
);
?>
</p>
<textarea
readonly="readonly"
class="edd-tools-textarea"
rows="15"
name="edd-debug-log-contents"><?php echo esc_textarea( $log_output ); ?></textarea>
<p>
<input type="hidden" name="edd_action" value="submit_debug_log"/>
<p>
<input type="hidden" name="edd_action" value="submit_debug_log"/>
<?php
submit_button( __( 'Download Debug Log File', 'easy-digital-downloads' ), 'primary', 'edd-download-debug-log', false );
submit_button( __( 'Copy to Clipboard', 'easy-digital-downloads' ), 'secondary edd-inline-button', 'edd-copy-debug-log', false, array( 'onclick' => "this.form['edd-debug-log-contents'].focus();this.form['edd-debug-log-contents'].select();document.execCommand('copy');return false;" ) );
submit_button( __( 'Download Debug Log File', 'easy-digital-downloads' ), 'primary', 'edd-download-debug-log', false );
submit_button( __( 'Copy to Clipboard', 'easy-digital-downloads' ), 'secondary edd-inline-button', 'edd-copy-debug-log', false, array( 'onclick' => "this.form['edd-debug-log-contents'].focus();this.form['edd-debug-log-contents'].select();document.execCommand('copy');return false;" ) );
// Only show the "Clear Log" button if there is a log to clear
if ( ! empty( $log ) ) {
@ -1212,16 +1267,16 @@ function edd_tools_debug_log_display() {
}
?>
</p>
</p>
<?php wp_nonce_field( 'edd-debug-log-action' ); ?>
</form>
</form>
<p>
<?php _e( 'Log file', 'easy-digital-downloads' ); ?>:
<code><?php echo esc_html( $path_output ); ?></code>
<p>
<?php esc_html_e( 'Log file', 'easy-digital-downloads' ); ?>:
<code><?php echo esc_html( $path_output ); ?></code>
</p>
</div><!-- .inside -->
</div><!-- .postbox -->
</div><!-- .inside -->
</div><!-- .postbox -->
<?php
}

View File

@ -1,6 +1,8 @@
<?php
/**
* Upgrade Functions
* Note: Do not move, rename, or delete this file as many extensions will attempt
* to require it during an installation or upgrade process.
*
* @package EDD
* @subpackage Admin/Upgrades
@ -12,28 +14,7 @@
// Exit if accessed directly
defined( 'ABSPATH' ) || exit;
/**
* Perform automatic database upgrades when necessary
*
* @since 2.6
* @return void
*/
function edd_do_automatic_upgrades() {
$edd_version = edd_get_db_version();
if ( version_compare( $edd_version, EDD_VERSION, '>=' ) ) {
return;
}
// Existing stores should set the upgraded version and the onboarding wizard as complete.
if ( ! empty( $edd_version ) ) {
update_option( 'edd_version_upgraded_from', $edd_version, false );
if ( ! get_option( 'edd_onboarding_completed', false ) && ! get_option( 'edd_onboarding_started', false ) ) {
update_option( 'edd_onboarding_completed', true, false );
}
}
edd_update_db_version();
}
// edd_do_automatic upgrades is defined in includes/upgrades/functions.php
add_action( 'admin_init', 'edd_do_automatic_upgrades' );
/**
@ -214,7 +195,7 @@ function edd_show_upgrade_notices() {
* NOTICE:
*
* When adding new upgrade notices, please be sure to put the action
* into the upgrades array during install: /includes/install.php @ Appox Line 156
* into the upgrades array in `edd_get_all_upgrades`.
*/
// End 'Stepped' upgrade process notices
@ -269,80 +250,8 @@ function edd_maybe_resume_upgrade() {
return $doing_upgrade;
}
/**
* Adds an upgrade action to the completed upgrades array
*
* @since 2.3
* @param string $upgrade_action The action to add to the copmleted upgrades array
* @return bool If the function was successfully added
*/
function edd_set_upgrade_complete( $upgrade_action = '' ) {
if ( empty( $upgrade_action ) ) {
return false;
}
$completed_upgrades = edd_get_completed_upgrades();
$completed_upgrades[] = $upgrade_action;
// Remove any blanks, and only show uniques
$completed_upgrades = array_unique( array_values( $completed_upgrades ) );
return update_option( 'edd_completed_upgrades', $completed_upgrades );
}
/** 3.0 Upgrades *************************************************************/
/**
* Returns an array of upgrades for 3.0
*
* Key is the name of the upgrade, which can be used in `edd_has_upgrade_completed()` completed functions.
* The value is the name of the associated batch processor class for that upgrade.
*
* @since 3.0
* @return array
*/
function edd_get_v30_upgrades() {
return array(
'migrate_tax_rates' => array(
'name' => __( 'Tax Rates', 'easy-digital-downloads' ),
'class' => 'EDD\\Admin\\Upgrades\\v3\\Tax_Rates'
),
'migrate_discounts' => array(
'name' => __( 'Discounts', 'easy-digital-downloads' ),
'class' => 'EDD\\Admin\\Upgrades\\v3\\Discounts'
),
'migrate_orders' => array(
'name' => __( 'Orders', 'easy-digital-downloads' ),
'class' => 'EDD\\Admin\\Upgrades\\v3\\Orders'
),
'migrate_customer_addresses' => array(
'name' => __( 'Customer Addresses', 'easy-digital-downloads' ),
'class' => 'EDD\\Admin\\Upgrades\\v3\\Customer_Addresses'
),
'migrate_customer_email_addresses' => array(
'name' => __( 'Customer Email Addresses', 'easy-digital-downloads' ),
'class' => 'EDD\\Admin\\Upgrades\\v3\\Customer_Email_Addresses'
),
'migrate_customer_notes' => array(
'name' => __( 'Customer Notes', 'easy-digital-downloads' ),
'class' => 'EDD\\Admin\\Upgrades\\v3\\Customer_Notes'
),
'migrate_logs' => array(
'name' => __( 'Logs', 'easy-digital-downloads' ),
'class' => 'EDD\\Admin\\Upgrades\\v3\\Logs'
),
'migrate_order_notes' => array(
'name' => __( 'Order Notes', 'easy-digital-downloads' ),
'class' => 'EDD\\Admin\\Upgrades\\v3\\Order_Notes'
),
'v30_legacy_data_removed' => array(
'name' => __( 'Remove Legacy Data', 'easy-digital-downloads' ),
'class' => 'EDD\\Admin\\Upgrades\\v3\\Remove_Legacy_Data'
)
);
}
/**
* Render 3.0 upgrade page.
*

View File

@ -10,7 +10,7 @@
*/
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
defined( 'ABSPATH' ) || exit;
/**
* Builds the Cart by providing hooks and calling all the hooks for the Cart
@ -20,13 +20,20 @@ if ( !defined( 'ABSPATH' ) ) exit;
*/
function edd_checkout_cart() {
if ( function_exists( '\\EDD\\Blocks\\Checkout\\Functions\\checkout_has_blocks' ) && \EDD\Blocks\Checkout\Functions\checkout_has_blocks() ) {
$cart_items = edd_get_cart_contents();
include EDD_BLOCKS_DIR . 'views/checkout/cart/cart.php';
return;
}
// Check if the Update cart button should be shown
if( edd_item_quantities_enabled() ) {
if ( edd_item_quantities_enabled() ) {
add_action( 'edd_cart_footer_buttons', 'edd_update_cart_button' );
}
// Check if the Save Cart button should be shown
if( ! edd_is_cart_saving_disabled() ) {
if ( ! edd_is_cart_saving_disabled() ) {
add_action( 'edd_cart_footer_buttons', 'edd_save_cart_button' );
}

View File

@ -799,7 +799,7 @@ function edd_terms_agreement() {
?>
<div class="edd-terms-agreement">
<input name="edd_agree_to_terms" class="required" type="checkbox" id="edd_agree_to_terms" value="1"/>
<input name="edd_agree_to_terms" class="required" type="checkbox" id="edd_agree_to_terms" value="1" required/>
<label for="edd_agree_to_terms"><?php echo stripslashes( $agree_label ); ?></label>
</div>
</fieldset>
@ -874,7 +874,7 @@ function edd_privacy_agreement() {
if ( '1' === $show_privacy_policy_checkbox ) {
?>
<div class="edd-privacy-policy-agreement">
<input name="edd_agree_to_privacy_policy" class="required" type="checkbox" id="edd-agree-to-privacy-policy" value="1"/>
<input name="edd_agree_to_privacy_policy" class="required" type="checkbox" id="edd-agree-to-privacy-policy" value="1" required/>
<label for="edd-agree-to-privacy-policy"><?php echo stripslashes( $agree_label ); ?></label>
</div>
<?php

View File

@ -355,7 +355,7 @@ final class Easy_Digital_Downloads {
// Plugin version.
if ( ! defined( 'EDD_VERSION' ) ) {
define( 'EDD_VERSION', '3.1.3' );
define( 'EDD_VERSION', '3.1.4' );
}
// Make sure CAL_GREGORIAN is defined.
@ -723,9 +723,6 @@ final class Easy_Digital_Downloads {
require_once EDD_PLUGIN_DIR . 'includes/emails/email-summary/class-edd-email-summary.php';
require_once EDD_PLUGIN_DIR . 'includes/emails/email-summary/class-edd-email-summary-blurb.php';
// Structured Data
require_once EDD_PLUGIN_DIR . 'includes/class-structured-data.php';
// Stats
require_once EDD_PLUGIN_DIR . 'includes/class-stats.php';
@ -778,6 +775,7 @@ final class Easy_Digital_Downloads {
require_once EDD_PLUGIN_DIR . 'includes/users/register.php';
require_once EDD_PLUGIN_DIR . 'includes/shortcodes.php';
require_once EDD_PLUGIN_DIR . 'includes/install.php';
require_once EDD_PLUGIN_DIR . 'includes/upgrades/functions.php';
// Admin files to load globally (cron, bar, etc...)
require_once EDD_PLUGIN_DIR . 'includes/admin/tracking.php';

View File

@ -2138,16 +2138,15 @@ class EDD_CLI extends WP_CLI_Command {
$file_id_key = array_rand( $download_ids_with_files[ $product_id ], 1 );
$file_key = $download_ids_with_files[ $product_id ][ $file_id_key ];
edd_add_file_download_log( array(
'product_id' => absint( $product_id ),
'file_id' => absint( $file_key ),
'order_id' => absint( $order_id ),
'price_id' => absint( $price_id ),
'customer_id' => $order->customer_id,
'ip' => edd_get_ip(),
'user_agent' => 'EDD; WPCLI; download_logs;',
'date_created' => $order->date_completed,
) );
edd_record_download_in_log(
absint( $product_id ),
absint( $file_key ),
array(),
edd_get_ip(),
absint( $order_id ),
absint( $price_id ),
'EDD; WPCLI; download_logs;'
);
$progress->tick();
$i ++;

View File

@ -1,291 +0,0 @@
<?php
/**
* Structured Data Object.
*
* @package EDD
* @subpackage StructuredData
* @copyright Copyright (c) 2018, Easy Digital Downloads, LLC
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 3.0
*/
namespace EDD;
// Exit if accessed directly
defined( 'ABSPATH' ) || exit;
/**
* EDD_Structured_Data Class.
*
* @since 3.0
*/
class Structured_Data {
/**
* Structured data.
*
* @var array
*/
private $data = array();
/**
* Constructor.
*
* @since 3.0
*/
public function __construct() {
$this->hooks();
}
/**
* Register the hooks.
*
* @since 3.0
*/
private function hooks() {
add_action( 'wp_footer', array( $this, 'output_structured_data' ) );
}
/**
* Get raw data. This data is not formatted in any way.
*
* @access public
* @since 3.0
*
* @return array Raw data.
*/
public function get_data() {
return $this->data;
}
/**
* Set structured data. This is then output in `wp_footer`.
*
* @access private
* @since 3.0
*
* @param array $data JSON-LD structured data.
*
* @return bool True if data was set, false otherwise.
*/
private function set_data( $data = null ) {
if ( is_null( $data ) || empty( $data ) || ! is_array( $data ) ) {
return false;
}
// Ensure the type exists and matches the format expected.
if ( ! isset( $data['@type'] ) || ! preg_match( '|^[a-zA-Z]{1,20}$|', $data['@type'] ) ) {
return false;
}
$this->data[] = $data;
return true;
}
/**
* Generate the structured data for a given context.
*
* @access public
* @since 3.0
*
* @param mixed string|false $context Default empty as the class figures out what the context is automatically.
* @param mixed $args Arguments that can be passed to the generators.
*
* @return string
*/
public function generate_structured_data( $context = false, $args = null ) {
if ( is_singular( 'download' ) || 'download' === $context ) {
$this->generate_download_data( $args );
}
/**
* Allow actions to fire here to allow for different types of structured data.
*
* @since 3.0
*
* @param EDD_Structured_Data Instance of the object.
* @param mixed string|bool $context Context.
*/
do_action( 'edd_generate_structured_data', $this, $context );
}
/**
* Generate structured data for a download.
*
* @access public
* @since 3.0
*
* @param mixed int|EDD_Download Download ID or EDD_Download object to generate data for.
*
* @return bool True if data generated successfully, false otherwise.
*/
public function generate_download_data( $download = false ) {
if ( false === $download || is_null( $download ) ) {
global $post;
$download = edd_get_download( $post->ID );
} elseif ( is_int( $download ) ) {
$download = edd_get_download( $download );
} else {
return false;
}
// Return false if a download object could not be retrieved.
if ( ! $download instanceof \EDD_Download ) {
return false;
}
$data = array(
'@type' => 'Product',
'name' => $download->post_title,
'url' => get_permalink( $download->ID ),
'brand' => array(
'@type' => 'Thing',
'name' => get_bloginfo( 'name' ),
),
'sku' => '-' === $download->get_sku()
? $download->ID
: $download->get_sku(),
);
// Add image if it exists.
$image_url = wp_get_attachment_image_url( get_post_thumbnail_id( $download->ID ) );
if ( false !== $image_url ) {
$data['image'] = esc_url( $image_url );
}
// Add description if it is not blank.
if ( '' !== $download->post_excerpt ) {
$data['description'] = $download->post_excerpt;
}
if ( $download->has_variable_prices() ) {
$variable_prices = $download->get_prices();
$offers = array();
foreach ( $variable_prices as $price ) {
$offers[] = array(
'@type' => 'Offer',
'price' => $price['amount'],
'priceCurrency' => edd_get_currency(),
'priceValidUntil' => date( 'c', time() + YEAR_IN_SECONDS ),
'itemOffered' => $data['name'] . ' - ' . $price['name'],
'url' => $data['url'],
'availability' => 'http://schema.org/InStock',
'seller' => array(
'@type' => 'Organization',
'name' => get_bloginfo( 'name' ),
),
);
}
$data['offers'] = $offers;
} else {
$data['offers'] = array(
'@type' => 'Offer',
'price' => $download->get_price(),
'priceCurrency' => edd_get_currency(),
'priceValidUntil' => null,
'url' => $data['url'],
'availability' => 'http://schema.org/InStock',
'seller' => array(
'@type' => 'Organization',
'name' => get_bloginfo( 'name' ),
),
);
}
$download_categories = wp_get_post_terms( $download->ID, 'download_category' );
if ( is_array( $download_categories ) && ! empty( $download_categories ) ) {
$download_categories = wp_list_pluck( $download_categories, 'name' );
$data['category'] = implode( ', ', $download_categories );
}
/**
* Filter the structured data for a download.
*
* @since 3.0
*
* @param array $data Structured data for a download.
*/
$data = apply_filters( 'edd_generate_download_structured_data', $data );
$this->set_data( $data );
return true;
}
/**
* Sanitize the structured data.
*
* @access private
* @since 3.0
*
* @param array $data Data to be sanitized.
*
* @return array Sanitized data.
*/
private function sanitize_data( $data ) {
$sanitized = array();
// Bail with an empty array if data does not exist.
if ( ! $data || ! is_array( $data ) ) {
return $sanitized;
}
foreach ( $data as $key => $value ) {
$key = sanitize_text_field( $key );
$sanitized[ $key ] = is_array( $value )
? $this->sanitize_data( $value )
: sanitize_text_field( $value );
}
return $sanitized;
}
/**
* Encode the data, ready for output.
*
* @access private
* @since 3.0
*/
private function encoded_data() {
$this->generate_structured_data();
// Bail if no data was generated.
if ( empty( $this->data ) ) {
return;
}
$structured_data = $this->get_data();
foreach ( $structured_data as $k => $v ) {
$structured_data[ $k ]['@context'] = 'http://schema.org/';
}
return wp_json_encode( $structured_data );
}
/**
* Output the structured data.
*
* @access public
* @since 3.0
*
* @return bool True by default, false if structured data does not exist.
*/
public function output_structured_data() {
$this->data = $this->sanitize_data( $this->data );
$output_data = $this->encoded_data();
if ( empty( $output_data ) ) {
return false;
}
echo '<script type="application/ld+json">' . $output_data . '</script>';
return true;
}
}

View File

@ -283,3 +283,15 @@ function edd_get_minute_values() {
'59' => '59'
) );
}
/**
* Gets the UTC equivalent of a date in the local timezone.
*
* @since 3.1.4
* @param string $date_string The date string to convert.
* @param string $format The format to return the date in.
* @return string
*/
function edd_get_utc_date_string( $date_string = 'now', $format = 'Y-m-d H:i:s' ) {
return EDD()->utils->date( $date_string, edd_get_timezone_id(), false )->get_utc_from_local( $format );
}

View File

@ -709,31 +709,53 @@ function edd_get_download_sales_stats( $download_id = 0 ) {
* @param int $download_id Download ID.
* @param int $file_id File ID.
* @param array $user_info User information (deprecated).
* @param string $ip User IP.
* @param string $ip Optional. IP address.
* @param int $order_id Order ID.
* @param int $price_id Optional. Price ID,
* @param string $user_agent Optional. User agent.
* @return void
*/
function edd_record_download_in_log( $download_id = 0, $file_id = 0, $user_info = array(), $ip = '', $order_id = 0, $price_id = 0 ) {
function edd_record_download_in_log( $download_id = 0, $file_id = 0, $user_info = array(), $ip = '', $order_id = 0, $price_id = 0, $user_agent = '' ) {
$order = edd_get_order( $order_id );
if ( ! class_exists( 'Browser' ) ) {
require_once EDD_PLUGIN_DIR . 'includes/libraries/browser.php';
if ( empty( $user_agent ) ) {
if ( ! class_exists( 'Browser' ) ) {
require_once EDD_PLUGIN_DIR . 'includes/libraries/browser.php';
}
$browser = new Browser();
$user_agent = $browser->getBrowser() . ' ' . $browser->getVersion() . '/' . $browser->getPlatform();
}
$browser = new Browser();
if ( empty( $ip ) ) {
$ip = edd_get_ip();
}
$user_agent = $browser->getBrowser() . ' ' . $browser->getVersion() . '/' . $browser->getPlatform();
$file_id = absint( $file_id );
$files = edd_get_download_files( $download_id );
$file_name = '';
edd_add_file_download_log( array(
if ( is_array( $files ) ) {
foreach ( $files as $key => $file ) {
if ( absint( $key ) === $file_id ) {
$file_name = edd_get_file_name( $file );
break;
}
}
}
$log_id = edd_add_file_download_log( array(
'product_id' => absint( $download_id ),
'file_id' => absint( $file_id ),
'file_id' => $file_id,
'order_id' => absint( $order_id ),
'price_id' => absint( $price_id ),
'customer_id' => $order->customer_id,
'ip' => sanitize_text_field( $ip ),
'user_agent' => $user_agent,
) );
if ( $log_id && ! empty( $file_name ) ) {
edd_add_file_download_log_meta( $log_id, 'file_name', $file_name );
}
}
/**

View File

@ -60,7 +60,7 @@ function edd_resend_purchase_receipt( $data ) {
wp_die( __( 'You do not have permission to edit this payment record', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
}
$email = ! empty( $_GET['email'] ) ? sanitize_email( $_GET['email'] ) : '';
$email = ! empty( $data['email'] ) ? sanitize_email( $data['email'] ) : '';
if( empty( $email ) ) {
$customer = new EDD_Customer( edd_get_payment_customer_id( $purchase_id ) );
@ -88,6 +88,7 @@ function edd_resend_purchase_receipt( $data ) {
'edd-message' => $sent ? 'email_sent' : 'email_send_failed',
'edd-action' => false,
'purchase_id' => false,
'email' => false,
)
)
);

View File

@ -506,7 +506,7 @@ function get_account_info() {
wp_send_json_success( array(
'status' => $status,
'account_status' => '<ul class="edd-paypal-account-status">' . $account_status . '</ul>',
'account_status' => '<ul class="edd-paypal-account-status edd-settings__list--disc">' . $account_status . '</ul>',
'webhook_object' => isset( $validator ) ? $validator->webhook : null,
'actions' => array_values( $actions ),
'disconnect_links' => array_values( $disconnect_links ),

View File

@ -3,7 +3,7 @@
* Plugin Name: Easy Digital Downloads - Stripe Pro Payment Gateway
* Plugin URI: https://easydigitaldownloads.com/downloads/stripe-gateway/
* Description: Adds support for pre-authorized credit card payments and removes additional transaction fees.
* Version: 2.9.5.1
* Version: 2.9.6
* Requires at least: 5.4
* Requires PHP: 7.1
* Author: Easy Digital Downloads
@ -44,7 +44,7 @@ function edd_stripe_core_bootstrap() {
}
if ( ! defined( 'EDD_STRIPE_VERSION' ) ) {
define( 'EDD_STRIPE_VERSION', '2.9.5.1' );
define( 'EDD_STRIPE_VERSION', '2.9.6' );
}
if ( ! defined( 'EDD_STRIPE_API_VERSION' ) ) {

View File

@ -161,8 +161,10 @@ function edds_add_settings( $settings ) {
'id' => 'stripe_allow_prepaid_elements_note',
'name' => __( 'Prepaid Cards', 'easy-digital-downloads' ),
'desc' => sprintf(
__( 'Prepaid card allowance can now be managed in your <a href="%s" target="_blank">Stripe Radar Rules</a>.', 'easy-digital-downloads' ),
$radar_rules_url
/* translators: %1$s Opening anchor tag, do not translate. %2$s Closing anchor tag, do not translate. */
__( 'Prepaid card allowance can now be managed in your %1$sStripe Radar Rules%2$s.', 'easy-digital-downloads' ),
'<a href="' . $radar_rules_url . '" target="_blank">',
'</a>'
),
'type' => 'descriptive_text',
'class' => 'payment-elements' === $elements_mode ? 'payment-elements-feature' : 'edd-hidden payment-elements-feature',
@ -188,8 +190,10 @@ function edds_add_settings( $settings ) {
'id' => 'stripe_use_existing_cards_elements_note',
'name' => __( 'Show Previously Used Cards', 'easy-digital-downloads' ),
'desc' => sprintf(
__( 'Previously used cards are now managed by <a href="%s" target="_blank">Link by Stripe</a>, for even better conversions and security.', 'easy-digital-downloads' ),
'https://link.co/'
/* translators: %1$s Opening anchor tag, do not translate. %2$s Closing anchor tag, do not translate. */
__( 'Previously used cards are now managed by %1$sLink by Stripe%2$s, for even better conversions and security.', 'easy-digital-downloads' ),
'<a href="https://link.co/" target="_blank">',
'</a>'
),
'type' => 'descriptive_text',
'class' => 'payment-elements' === $elements_mode ? 'payment-elements-feature' : 'edd-hidden payment-elements-feature',
@ -353,7 +357,7 @@ function edd_stripe_requirements_not_met_callback() {
echo '<p>';
echo wp_kses(
sprintf(
/* translators: %1$s Future PHP version requirement. %2$s Current PHP version. %3$s Opening strong tag, do not translate. %4$s Closing strong tag, do not translate. */
/* translators: %1$s PHP version requirement. %2$s Current PHP version. %3$s Opening strong tag, do not translate. %4$s Closing strong tag, do not translate. */
__(
'Processing credit cards with Stripe requires PHP version %1$s or higher. It looks like you\'re using version %2$s, which means you will need to %3$supgrade your version of PHP before acceping credit card payments%4$s.',
'easy-digital-downloads'

View File

@ -568,9 +568,9 @@ function edds_stripe_connect_account_info_ajax_response() {
)
. ' ' .
sprintf(
/** Translators: Replacements are for the html wrappers for the phrse Upgrade to Pro and should not be translated. */
esc_html__(
'%sUpgrade to Pro%s and install the Stripe Pro Gateway to remove transaction fees.', 'easy-digital-downloads'
/* Translators: Replacements are for the html wrappers for the phrase Upgrade to Pro and should not be translated. */
'%1$sUpgrade to Pro%2$s and install the Stripe Pro Gateway to remove transaction fees.', 'easy-digital-downloads'
),
'<span class="edd-pro-upgrade"><a href="' . edd_link_helper( 'https://easydigitaldownloads.com/pricing/', array( 'utm_medium' => 'stripe-settings', 'utm_content' => 'upgrade-to-pro' ) ) . '" target="_blank">',
'</a></span>'
@ -772,94 +772,3 @@ function edds_stripe_connect_admin_notices_print() {
} catch( Exception $e ) {}
}
add_action( 'admin_notices', 'edds_stripe_connect_admin_notices_print' );
/**
* Adds a Stripe Connect site health test.
*
* @since 2.9.3
* @param array $tests The array of Site Health tests.
* @return array
*/
function edds_stripe_connect_site_health_test( $tests ) {
$active_gateways = edd_get_enabled_payment_gateways();
if ( ! empty( $active_gateways['stripe'] ) && current_user_can( 'manage_shop_settings' ) ) {
$tests['direct']['edds_stripe_connect'] = array(
'label' => __( 'Stripe Connect', 'easy-digital-downloads' ),
'test' => 'edds_get_test_stripe_connect',
);
}
return $tests;
}
add_filter( 'site_status_tests', 'edds_stripe_connect_site_health_test' );
/**
* Adds the Stripe Connect Site Health test.
*
* @since 2.9.3
* @return array
*/
function edds_get_test_stripe_connect() {
$result = array(
'label' => __( 'You are securely connected to Stripe', 'easy-digital-downloads' ),
'status' => 'good',
'badge' => array(
'label' => __( 'Easy Digital Downloads: Stripe', 'easy-digital-downloads' ),
'color' => 'blue',
),
'description' => sprintf(
'<p>%s</p>',
__( 'Stripe Connect helps ensure easy setup and security.', 'easy-digital-downloads' )
),
'actions' => '',
'test' => 'edds_stripe_connect',
);
$elements_mode = edds_get_elements_mode();
if ( edd_stripe()->connect()->is_connected ) {
if ( 'payment-elements' === $elements_mode ) {
return $result;
}
// User is connected but on the Card Elements, we should give them a recommendation to use the Payment Elements.
$result['label'] = __( 'You are using the legacy Card Elements fields', 'easy-digital-downloads' );
$result['status'] = 'recommended';
$result['badge']['color'] = 'orange';
$result['description'] = sprintf(
'<p>%s</p>',
esc_html__( 'Increase conversions, security, and reliability by using the Payment Elements integration for Stripe.', 'easy-digital-downloads' )
);
$result['actions'] = sprintf(
'<a href="%s" class="button button-primary"><span>%s</span></a>',
esc_url(
edd_get_admin_url(
array(
'page' => 'edd-settings',
'tab' => 'gateways',
'section' => 'edd-stripe',
)
)
),
esc_html__( 'Switch to Payment Elements', 'easy-digital-downloads' )
);
} else {
$result['label'] = __( 'You are using manually managed Stripe API keys', 'easy-digital-downloads' );
$result['status'] = 'critical';
$result['badge']['color'] = 'red';
$result['description'] = sprintf(
'<p>%s</p>',
esc_html__( 'By securely connecting your Easy Digital Downloads store with Stripe Connect, you\'ll get access to more reliable payments and use managed API keys which are more secure.', 'easy-digital-downloads' )
);
$result['actions'] = sprintf(
'<a href="%s" class="edd-stripe-connect"><span>%s</span></a>',
esc_url( edds_stripe_connect_url() ),
esc_html__( 'Connect with Stripe', 'easy-digital-downloads' )
);
}
edd_stripe_connect_admin_style();
return $result;
}

View File

@ -0,0 +1,144 @@
<?php
/*
* Site Health
*
* @package EDD_Stripe\Admin\SiteHealth
* @copyright Copyright (c) 2023, Easy Digital Downloads
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 2.9.6
*/
defined( 'ABSPATH' ) || exit;
/**
* Adds a Stripe Connect site health test.
*
* @since 2.9.3
* @param array $tests The array of Site Health tests.
* @return array
*/
function edds_stripe_connect_site_health_test( $tests ) {
$active_gateways = edd_get_enabled_payment_gateways();
if ( ! empty( $active_gateways['stripe'] ) && current_user_can( 'manage_shop_settings' ) ) {
$tests['direct']['edds_stripe_connect'] = array(
'label' => __( 'Stripe Connect', 'easy-digital-downloads' ),
'test' => 'edds_get_test_stripe_connect',
);
}
return $tests;
}
add_filter( 'site_status_tests', 'edds_stripe_connect_site_health_test' );
/**
* Adds the Stripe Connect Site Health test.
*
* @since 2.9.3
* @return array
*/
function edds_get_test_stripe_connect() {
$result = array(
'label' => __( 'You are securely connected to Stripe', 'easy-digital-downloads' ),
'status' => 'good',
'badge' => array(
'label' => __( 'Easy Digital Downloads: Stripe', 'easy-digital-downloads' ),
'color' => 'blue',
),
'description' => sprintf(
'<p>%s</p>',
__( 'Stripe Connect helps ensure easy setup and security.', 'easy-digital-downloads' )
),
'actions' => '',
'test' => 'edds_stripe_connect',
);
$elements_mode = edds_get_elements_mode();
if ( edd_stripe()->connect()->is_connected ) {
if ( 'payment-elements' === $elements_mode ) {
return $result;
}
// User is connected but on the Card Elements, we should give them a recommendation to use the Payment Elements.
$result['label'] = __( 'You are using the legacy Card Elements fields', 'easy-digital-downloads' );
$result['status'] = 'recommended';
$result['badge']['color'] = 'orange';
$result['description'] = sprintf(
'<p>%s</p>',
esc_html__( 'Increase conversions, security, and reliability by using the Payment Elements integration for Stripe.', 'easy-digital-downloads' )
);
$result['actions'] = sprintf(
'<a href="%s" class="button button-primary"><span>%s</span></a>',
esc_url(
edd_get_admin_url(
array(
'page' => 'edd-settings',
'tab' => 'gateways',
'section' => 'edd-stripe',
)
)
),
esc_html__( 'Switch to Payment Elements', 'easy-digital-downloads' )
);
} else {
$result['label'] = __( 'You are using manually managed Stripe API keys', 'easy-digital-downloads' );
$result['status'] = 'critical';
$result['badge']['color'] = 'red';
$result['description'] = sprintf(
'<p>%s</p>',
esc_html__( 'By securely connecting your Easy Digital Downloads store with Stripe Connect, you\'ll get access to more reliable payments and use managed API keys which are more secure.', 'easy-digital-downloads' )
);
$result['actions'] = sprintf(
'<a href="%s" class="edd-stripe-connect"><span>%s</span></a>',
esc_url( edds_stripe_connect_url() ),
esc_html__( 'Connect with Stripe', 'easy-digital-downloads' )
);
}
edd_stripe_connect_admin_style();
return $result;
}
add_filter( 'edd_debug_information', 'edds_debug_information' );
/**
* Add Stripe debugging information to the EDD information.
*
* @since 2.9.6
* @param array $information The EDD debug information.
* @return array
*/
function edds_debug_information( $information ) {
$stripe = array(
'edd_stripe' => array(
'label' => __( 'Easy Digital Downloads &mdash; Stripe', 'easy-digital-downloads' ),
'fields' => array(
'connect' => array(
'label' => 'Stripe Connect',
'value' => edd_stripe()->connect()->is_connected ? 'Connected' : 'Not Connected',
),
'mode' => array(
'label' => 'Elements Mode',
'value' => 'payment-elements' === edds_get_elements_mode() ? 'Payment Elements' : 'Legacy Card Elements',
),
'preapproved_payments' => array(
'label' => 'Preapproved Payments',
'value' => edds_is_preapprove_enabled() ? 'Enabled' : 'Disabled',
),
'assets' => array(
'label' => 'Stripe Assets',
'value' => edd_get_option( 'stripe_restrict_assets', false ) ? 'Limited' : 'Global',
),
),
),
);
$position = array_search( 'edd_gateways', array_keys( $information ), true );
return array_merge(
array_slice( $information, 0, $position + 1 ),
$stripe,
array_slice( $information, $position + 1 )
);
}

View File

@ -74,18 +74,6 @@ class EDD_Stripe {
self::$instance->setup_classes();
self::$instance->actions();
self::$instance->filters();
if ( true === edds_is_pro() ) {
add_action( 'edd_extension_license_init', function( \EDD\Extensions\ExtensionRegistry $registry ) {
$registry->addExtension(
EDD_STRIPE_PLUGIN_FILE,
'Stripe Pro Payment Gateway',
167,
EDD_STRIPE_VERSION,
'stripe_license_key'
);
} );
}
}
return self::$instance;
@ -170,6 +158,7 @@ class EDD_Stripe {
require_once EDDS_PLUGIN_DIR . '/includes/admin/settings/stripe-connect.php';
require_once EDDS_PLUGIN_DIR . '/includes/admin/settings.php';
require_once EDDS_PLUGIN_DIR . '/includes/admin/upgrade-functions.php';
require_once EDDS_PLUGIN_DIR . '/includes/admin/site-health.php';
}
if ( defined( 'WP_CLI' ) && WP_CLI ) {

View File

@ -616,6 +616,8 @@ function edds_stripe_connect_account_country_supports_application_fees() {
$blocked_countries = array(
'br',
'in',
'mx',
);
return ! in_array( $account_country, $blocked_countries, true );
@ -776,4 +778,4 @@ function edds_get_tokenizer_input( $custom_id = '' ) {
esc_attr( $timestamp ),
esc_attr( \EDD\Utils\Tokenizer::tokenize( $timestamp ) )
);
}
}

View File

@ -68,29 +68,30 @@ function edds_process_purchase_form( $purchase_data ) {
*/
do_action( 'edds_pre_process_purchase_form', $purchase_data );
if ( edds_is_zero_decimal_currency() ) {
$amount = $purchase_data['price'];
} else {
$amount = round( $purchase_data['price'] * 100, 0 );
}
/**
* We need to unhook some of the Recurring Payments actions here as we're handling captures ourselves.
*
* We're also going to attempt to restrict this to a single subscription and no mixed carts, for the time being.
*/
$cart_contains_subscription = false;
$cart_contains_subscription = (bool) ( function_exists( 'edd_recurring' ) && edd_recurring()->cart_contains_recurring() );
if ( function_exists( 'edd_recurring' ) ) {
$cart_contains_subscription = edd_recurring()->cart_contains_recurring();
if ( ( count( edd_get_cart_contents() ) > 1 && $cart_contains_subscription ) || edd_recurring()->cart_is_mixed() ) {
if ( $cart_contains_subscription ) {
if ( count( edd_get_cart_contents() ) > 1 || edd_recurring()->cart_is_mixed() ) {
throw new \EDD_Stripe_Gateway_Exception( edds_get_single_subscription_cart_error() );
}
if ( edd_recurring()->cart_has_free_trial() ) {
$amount = 0;
}
global $edd_recurring_stripe;
remove_filter( 'edds_create_payment_intent_args', array( $edd_recurring_stripe, 'create_payment_intent_args' ), 10, 2 );
remove_filter( 'edds_capture_payment_intent', array( $edd_recurring_stripe, 'capture_payment_intent' ) );
}
if ( edds_is_zero_decimal_currency() ) {
$amount = $purchase_data['price'];
} else {
$amount = round( $purchase_data['price'] * 100, 0 );
}
$existing_intent = false;
@ -477,6 +478,8 @@ function edds_create_and_complete_order() {
// Retrieve the relevant Intent.
if ( 'setup_intent' === $intent->object ) {
$order_transaction_id = false;
$intent = edds_api_request( 'SetupIntent', 'update', $intent->id, array(
'metadata' => array(
'edd_payment_id' => $order->id,
@ -518,20 +521,20 @@ function edds_create_and_complete_order() {
'_edds_stripe_payment_intent_id',
$intent->id
);
}
// Use Intent ID for temporary transaction ID.
// It will be updated when a charge is available.
$order_transaction_id = edd_add_order_transaction(
array(
'object_id' => $order->id,
'object_type' => 'order',
'transaction_id' => sanitize_text_field( $intent->id ),
'gateway' => 'stripe',
'status' => 'pending',
'total' => $order->total,
)
);
// Use Intent ID for temporary transaction ID.
// It will be updated when a charge is available.
$order_transaction_id = edd_add_order_transaction(
array(
'object_id' => $order->id,
'object_type' => 'order',
'transaction_id' => sanitize_text_field( $intent->id ),
'gateway' => 'stripe',
'status' => 'pending',
'total' => $order->total,
)
);
}
// Retrieves or creates a Stripe Customer.
edd_update_order_meta( $order->id, '_edds_stripe_customer_id', $intent->customer );
@ -627,15 +630,14 @@ function edds_create_and_complete_order() {
)
);
edd_update_order_transaction(
$order_transaction_id,
array(
'transaction_id' => sanitize_text_field( $charge_id ),
'gateway' => 'stripe',
'status' => 'complete',
'total' => $order->total,
)
);
if ( ! empty( $order_transaction_id ) ) {
edd_update_order_transaction(
$order_transaction_id,
array(
'transaction_id' => sanitize_text_field( $charge_id ),
)
);
}
}
if ( has_action( 'edds_payment_complete' ) ) {

View File

@ -50,7 +50,7 @@ function edds_prb_add_settings( $settings ) {
'desc' => wp_kses(
(
sprintf(
/* translators: %1$s Opening anchor tag, do not translate. %2$s Opening anchor tag, do not translate. %3$s Closing anchor tag, do not translate. */
/* translators: %1$s Opening anchor tag, do not translate. %2$s Closing anchor tag, do not translate. %3$s Closing anchor tag, do not translate. */
__( '"Express Checkout" via Apple Pay, Google Pay, or Microsoft Pay digital wallets. By using Apple Pay, you agree to %1$sStripe%3$s and %2$sApple\'s%3$s terms of service.', 'easy-digital-downloads' ),
'<a href="https://stripe.com/apple-pay/legal" target="_blank" rel="noopener noreferrer">',
'<a href="https://developer.apple.com/apple-pay/acceptable-use-guidelines-for-websites/" target="_blank" rel="noopener noreferrer">',
@ -58,7 +58,7 @@ function edds_prb_add_settings( $settings ) {
) . (
edd_is_test_mode()
? '<br /><strong>' . __( 'Apple Pay is not available in Test Mode.', 'easy-digital-downloads' ) . '</strong> ' . sprintf(
/* translators: %1$s Opening anchor tag, do not translate. %2$s Opening anchor tag, do not translate. */
/* translators: %1$s Opening anchor tag, do not translate. %2$s Closing anchor tag, do not translate. */
__( 'See our %1$sdocumentation%2$s for more information.', 'easy-digital-downloads' ),
'<a href="' . esc_url( edds_documentation_route( 'stripe-express-checkout-apple-pay-google-pay' ) ) . '" target="_blank" rel="noopener noreferrer">',
'</a>'
@ -78,15 +78,16 @@ function edds_prb_add_settings( $settings ) {
),
'type' => 'multicheck',
'options' => array(
/** translators: %s Download noun */
'single' => sprintf(
/* translators: %s Download noun */
__( 'Single %s', 'easy-digital-downloads' ),
edd_get_label_singular()
),
/** translators: %s Download noun */
'archive' => sprintf(
__( '%s Archive (includes <code>[downloads]</code> shortcode)', 'easy-digital-downloads' ),
edd_get_label_singular()
/* translators: 1. Download noun; 2. shortcode tag wrapped in <code> span */
__( '%1$s Archive (includes %2$s shortcode)', 'easy-digital-downloads' ),
edd_get_label_singular(),
'<code>[downloads]</code>'
),
'checkout' => __( 'Checkout', 'easy-digital-downloads' ),
),

View File

@ -162,6 +162,7 @@ function edds_prb_get_download_data( $download_id, $price_id = false, $quantity
'label' => sprintf(
'%s%s',
strip_tags( $name ),
/* translators: %d: Quantity.*/
( $quantity > 1 ? sprintf( __( ' × %d', 'easy-digital-downloads' ), $quantity ) : '' )
),
'amount' => $price,

View File

@ -110,6 +110,7 @@ abstract class EDD_Stripe_Region_Base {
<p>
<?php
printf(
/* translators: %s: The country name. */
esc_html__( 'Based on your store\'s base country of %s, it is recommended to set your Billing Address Display to use the "Full Address" option to ensure payments are completed successfully.', 'easy-digital-downloads' ),
edd_get_country_name( edd_get_option( 'base_country', 'US' ) )
);

View File

@ -12,81 +12,6 @@
// Exit if accessed directly
defined( 'ABSPATH' ) || exit;
/**
* Get the current database version
*
* @since 3.0
*
* @return string
*/
function edd_get_db_version() {
$db_version = get_option( 'edd_version' );
$retval = ! empty( $db_version )
? edd_format_db_version( $db_version )
: false;
return $retval;
}
/**
* Update the EDD version in the options table
*
* @since 3.0
*/
function edd_update_db_version() {
if ( defined( 'EDD_VERSION' ) ) {
update_option( 'edd_version', edd_format_db_version( EDD_VERSION ) );
}
}
/**
* Format the EDD version (going into or coming from the database.)
*
* @since 3.0
*
* @param string $version
* @return string
*/
function edd_format_db_version( $version = '' ) {
return preg_replace( '/[^0-9.].*/', '', $version );
}
/**
* Check if the upgrade routine has been run for a specific action
*
* @since 2.3
* @param string $upgrade_action The upgrade action to check completion for
* @return bool If the action has been added to the copmleted actions array
*/
function edd_has_upgrade_completed( $upgrade_action = '' ) {
// Bail if no upgrade action to check
if ( empty( $upgrade_action ) ) {
return false;
}
// Get completed upgrades
$completed_upgrades = edd_get_completed_upgrades();
// Return true if in array, false if not
return in_array( $upgrade_action, $completed_upgrades, true );
}
/**
* Get's the array of completed upgrade actions
*
* @since 2.3
* @return array The array of completed upgrades
*/
function edd_get_completed_upgrades() {
// Get the completed upgrades for this site
$completed_upgrades = get_option( 'edd_completed_upgrades', array() );
// Return array of completed upgrades
return (array) $completed_upgrades;
}
/**
* Install
*
@ -244,21 +169,8 @@ function edd_set_all_upgrades_complete() {
return;
}
// Maybe include an admin-area only file/function
if ( ! function_exists( 'edd_set_upgrade_complete' ) ) {
require_once EDD_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
}
// When new upgrade routines are added, mark them as complete on fresh install
$upgrade_routines = array(
'upgrade_payment_taxes',
'upgrade_customer_payments_association',
'upgrade_user_api_keys',
'remove_refunded_sale_logs',
'update_file_download_log_data',
);
$edd_30_upgrades = edd_get_v30_upgrades();
$upgrade_routines = array_merge( $upgrade_routines, array_keys( $edd_30_upgrades ) );
$upgrade_routines = edd_get_all_upgrades();
// Loop through upgrade routines and mark them as complete
foreach ( $upgrade_routines as $upgrade ) {

View File

@ -1871,6 +1871,36 @@ function edd_link_helper( $base_url = 'https://easydigitaldownloads.com/', $quer
$args = wp_parse_args( $query_args, $default_args );
if ( empty( $args['utm_medium'] ) ) {
if ( is_admin() ) {
$screen = get_current_screen();
if ( $screen ) {
$args['utm_medium'] = $screen->id;
}
} else {
$template = '';
if ( is_home() ) {
$template = get_home_template();
} elseif ( is_front_page() ) {
$template = get_front_page_template();
} elseif ( is_search() ) {
$template = get_search_template();
} elseif ( is_single() ) {
$template = get_single_template();
} elseif ( is_page() ) {
$template = get_page_template();
} elseif ( is_post_type_archive() ) {
$template = get_post_type_archive_template();
} elseif ( is_archive() ) {
$template = get_archive_template();
}
$args['utm_medium'] = wp_basename( $template, 'php' );
}
}
// Ensure we sanitize the medium and content.
$args['utm_medium'] = str_replace( '_', '-', sanitize_title( $args['utm_medium'] ) );
$args['utm_content'] = str_replace( '_', '-', sanitize_title( $args['utm_content'] ) );

View File

@ -136,8 +136,7 @@ function edd_add_manual_order( $args = array() ) {
);
// The date is entered in the WP timezone. We need to convert it to UTC prior to saving now.
$date = edd_get_utc_equivalent_date( EDD()->utils->date( $date_string, edd_get_timezone_id(), false ) );
$date = $date->format( 'Y-m-d H:i:s' );
$date = edd_get_utc_date_string( $date_string );
// Get mode
$mode = edd_is_test_mode()

View File

@ -586,4 +586,4 @@ function edd_add_custom_roles_rest_user_query( $prepared_args, $request ) {
return $prepared_args;
}
add_filter( 'rest_user_query', 'edd_add_custom_roles_rest_user_query', 5, 2 );
add_filter( 'rest_user_query', 'edd_add_custom_roles_rest_user_query', 15, 2 );

View File

@ -163,17 +163,7 @@ function edd_process_download() {
*/
do_action( 'edd_process_download_pre_record_log', $requested_file, $args, $method );
// Record this file download in the log
$user_info = array();
$user_info['email'] = $args['email'];
if ( is_user_logged_in() ) {
$user_data = get_userdata( get_current_user_id() );
$user_info['id'] = get_current_user_id();
$user_info['name'] = $user_data->display_name;
}
edd_record_download_in_log( $args['download'], $args['file_key'], $user_info, edd_get_ip(), $args['payment'], $args['price_id'] );
edd_record_download_in_log( $args['download'], $args['file_key'], array(), edd_get_ip(), $args['payment'], $args['price_id'] );
$file_extension = edd_get_file_extension( $requested_file );
$ctype = edd_get_file_ctype( $file_extension );

View File

@ -788,7 +788,7 @@ function parse_relative_dates_for_range( $range = null, $relative_range = null,
case 'previous_month':
$dates = array(
'start' => $dates['start']->copy()->subMonth( 1 ),
'end' => $dates['end']->copy()->subMonth( 1 ),
'end' => $dates['end']->copy()->subMonthNoOverflow( 1 ),
);
break;
case 'previous_quarter':

View File

@ -514,9 +514,13 @@ function edd_localize_admin_scripts() {
'resend_receipt' => __( 'Are you sure you want to resend the purchase receipt?', 'easy-digital-downloads' ),
'disconnect_customer' => __( 'Are you sure you want to disconnect the WordPress user from this customer record?', 'easy-digital-downloads' ),
'copy_download_link_text' => __( 'Copy these links to your clipboard and give them to your customer', 'easy-digital-downloads' ),
/* translators: singular download label */
'delete_payment_download' => sprintf( __( 'Are you sure you want to delete this %s?', 'easy-digital-downloads' ), edd_get_label_singular() ),
'type_to_search' => sprintf( __( 'Type to search %s', 'easy-digital-downloads' ), edd_get_label_plural() ),
'one_option' => sprintf( __( 'Choose a %s', 'easy-digital-downloads' ), edd_get_label_singular() ),
/* translators: plural download label */
'type_to_search' => sprintf( __( 'Type to search %s', 'easy-digital-downloads' ), edd_get_label_plural() ),
/* translators: singular download label */
'one_option' => sprintf( __( 'Choose a %s', 'easy-digital-downloads' ), edd_get_label_singular() ),
/* translators: plural download label */
'one_or_more_option' => sprintf( __( 'Choose one or more %s', 'easy-digital-downloads' ), edd_get_label_plural() ),
'one_price_min' => __( 'You must have at least one price', 'easy-digital-downloads' ),
'one_field_min' => __( 'You must have at least one field', 'easy-digital-downloads' ),

View File

@ -610,8 +610,9 @@ function edd_downloads_query( $atts, $content = null ) {
<?php
else:
printf( _x( 'No %s found', 'download post type name', 'easy-digital-downloads' ), edd_get_label_plural() );
else :
/* translators: plural download label */
printf( _x( 'No %s found', 'download post type name', 'easy-digital-downloads' ), esc_html( edd_get_label_plural() ) );
endif;
do_action( 'edd_downloads_list_after', $atts, $downloads, $query );
@ -984,9 +985,10 @@ function edd_process_profile_editor_remove_email( $data ) {
$url = add_query_arg( 'updated', true, $data['redirect'] );
$user = wp_get_current_user();
$user_login = ! empty( $user->user_login ) ? $user->user_login : edd_get_bot_name();
$customer_note = sprintf( __( 'Email address %s removed by %s', 'easy-digital-downloads' ), sanitize_email( $data['email'] ), $user_login );
$user = wp_get_current_user();
$user_login = ! empty( $user->user_login ) ? $user->user_login : edd_get_bot_name();
/* translators: 1. email address; 2. user who removed email. */
$customer_note = sprintf( __( 'Email address %1$s removed by %2$s', 'easy-digital-downloads' ), sanitize_email( $data['email'] ), $user_login );
$customer->add_note( $customer_note );
} else {

View File

@ -60,6 +60,7 @@ function edd_get_purchase_link( $args = array() ) {
edd_set_error(
'set_checkout',
sprintf(
/* translators: the settings screen URL */
__( 'No checkout page has been configured. Visit <a href="%s">Settings</a> to set one.', 'easy-digital-downloads' ),
esc_url( edd_get_admin_url( array(
'page' => 'edd-settings',

View File

@ -0,0 +1,201 @@
<?php
/**
* General upgrade helper functions.
*
* @package easy-digital-downloads
* @subpackage Upgrades
* @copyright Copyright (c) 2023, Easy Digital Downloads
* @license GPL2+
*/
defined( 'ABSPATH' ) || exit;
/**
* Get the current database version
*
* @since 3.0
*
* @return string
*/
function edd_get_db_version() {
$db_version = get_option( 'edd_version' );
$retval = ! empty( $db_version )
? edd_format_db_version( $db_version )
: false;
return $retval;
}
/**
* Update the EDD version in the options table
*
* @since 3.0
*/
function edd_update_db_version() {
if ( defined( 'EDD_VERSION' ) ) {
update_option( 'edd_version', edd_format_db_version( EDD_VERSION ) );
}
}
/**
* Format the EDD version (going into or coming from the database.)
*
* @since 3.0
*
* @param string $version
* @return string
*/
function edd_format_db_version( $version = '' ) {
return preg_replace( '/[^0-9.].*/', '', $version );
}
/**
* Check if the upgrade routine has been run for a specific action
*
* @since 2.3
* @param string $upgrade_action The upgrade action to check completion for
* @return bool If the action has been added to the copmleted actions array
*/
function edd_has_upgrade_completed( $upgrade_action = '' ) {
// Bail if no upgrade action to check
if ( empty( $upgrade_action ) ) {
return false;
}
// Get completed upgrades
$completed_upgrades = edd_get_completed_upgrades();
// Return true if in array, false if not
return in_array( $upgrade_action, $completed_upgrades, true );
}
/**
* Adds an upgrade action to the completed upgrades array
*
* @since 2.3
* @param string $upgrade_action The action to add to the copmleted upgrades array
* @return bool If the function was successfully added
*/
function edd_set_upgrade_complete( $upgrade_action = '' ) {
if ( empty( $upgrade_action ) ) {
return false;
}
$completed_upgrades = edd_get_completed_upgrades();
$completed_upgrades[] = $upgrade_action;
// Remove any blanks, and only show uniques
$completed_upgrades = array_unique( array_values( $completed_upgrades ) );
return update_option( 'edd_completed_upgrades', $completed_upgrades );
}
/**
* Gets the array of completed upgrade actions
*
* @since 2.3
* @return array The array of completed upgrades
*/
function edd_get_completed_upgrades() {
// Get the completed upgrades for this site
$completed_upgrades = get_option( 'edd_completed_upgrades', array() );
// Return array of completed upgrades
return (array) $completed_upgrades;
}
/**
* Defines all EDD core upgrades.
* When a new upgrade routine is added, it should be registered here.
*
* @since 3.1.4
* @return array
*/
function edd_get_all_upgrades() {
$upgrade_routines = array(
'upgrade_payment_taxes',
'upgrade_customer_payments_association',
'upgrade_user_api_keys',
'remove_refunded_sale_logs',
'update_file_download_log_data',
);
$edd_30_upgrades = edd_get_v30_upgrades();
return array_merge( $upgrade_routines, array_keys( $edd_30_upgrades ) );
}
/**
* Returns an array of upgrades for 3.0
*
* Key is the name of the upgrade, which can be used in `edd_has_upgrade_completed()` completed functions.
* The value is the name of the associated batch processor class for that upgrade.
*
* @since 3.0
* @return array
*/
function edd_get_v30_upgrades() {
return array(
'migrate_tax_rates' => array(
'name' => __( 'Tax Rates', 'easy-digital-downloads' ),
'class' => 'EDD\\Admin\\Upgrades\\v3\\Tax_Rates',
),
'migrate_discounts' => array(
'name' => __( 'Discounts', 'easy-digital-downloads' ),
'class' => 'EDD\\Admin\\Upgrades\\v3\\Discounts',
),
'migrate_orders' => array(
'name' => __( 'Orders', 'easy-digital-downloads' ),
'class' => 'EDD\\Admin\\Upgrades\\v3\\Orders',
),
'migrate_customer_addresses' => array(
'name' => __( 'Customer Addresses', 'easy-digital-downloads' ),
'class' => 'EDD\\Admin\\Upgrades\\v3\\Customer_Addresses',
),
'migrate_customer_email_addresses' => array(
'name' => __( 'Customer Email Addresses', 'easy-digital-downloads' ),
'class' => 'EDD\\Admin\\Upgrades\\v3\\Customer_Email_Addresses',
),
'migrate_customer_notes' => array(
'name' => __( 'Customer Notes', 'easy-digital-downloads' ),
'class' => 'EDD\\Admin\\Upgrades\\v3\\Customer_Notes',
),
'migrate_logs' => array(
'name' => __( 'Logs', 'easy-digital-downloads' ),
'class' => 'EDD\\Admin\\Upgrades\\v3\\Logs',
),
'migrate_order_notes' => array(
'name' => __( 'Order Notes', 'easy-digital-downloads' ),
'class' => 'EDD\\Admin\\Upgrades\\v3\\Order_Notes',
),
'v30_legacy_data_removed' => array(
'name' => __( 'Remove Legacy Data', 'easy-digital-downloads' ),
'class' => 'EDD\\Admin\\Upgrades\\v3\\Remove_Legacy_Data',
),
);
}
/**
* Perform automatic database upgrades when necessary
*
* @since 2.6
* @return void
*/
function edd_do_automatic_upgrades() {
$edd_version = edd_get_db_version();
if ( version_compare( $edd_version, EDD_VERSION, '>=' ) ) {
return;
}
// Existing stores should set the upgraded version and the onboarding wizard as complete.
if ( ! empty( $edd_version ) ) {
update_option( 'edd_version_upgraded_from', $edd_version, false );
if ( ! get_option( 'edd_onboarding_completed', false ) && ! get_option( 'edd_onboarding_started', false ) ) {
update_option( 'edd_onboarding_completed', true, false );
}
}
edd_update_db_version();
}

View File

@ -581,10 +581,13 @@ function edd_new_user_notification( $user_id = 0, $user_data = array() ) {
$emails->__set( 'from_name', $from_name );
$emails->__set( 'from_email', $from_email );
$admin_subject = apply_filters( 'edd_user_registration_admin_email_subject', sprintf( __('[%s] New User Registration', 'easy-digital-downloads' ), $from_name ), $user_data );
/* translators: Site name */
$admin_subject = apply_filters( 'edd_user_registration_admin_email_subject', sprintf( __( '[%s] New User Registration', 'easy-digital-downloads' ), $from_name ), $user_data );
$admin_heading = apply_filters( 'edd_user_registration_admin_email_heading', __( 'New user registration', 'easy-digital-downloads' ), $user_data );
$admin_message = sprintf( __( 'Username: %s', 'easy-digital-downloads'), $user_data['user_login'] ) . "\r\n\r\n";
$admin_message .= sprintf( __( 'E-mail: %s', 'easy-digital-downloads'), $user_data['user_email'] ) . "\r\n";
/* translators: the username */
$admin_message = sprintf( __( 'Username: %s', 'easy-digital-downloads' ), $user_data['user_login'] ) . "\r\n\r\n";
/* translators: the user email */
$admin_message .= sprintf( __( 'E-mail: %s', 'easy-digital-downloads' ), $user_data['user_email'] ) . "\r\n";
$admin_message = apply_filters( 'edd_user_registration_admin_email_message', $admin_message, $user_data );
@ -593,6 +596,7 @@ function edd_new_user_notification( $user_id = 0, $user_data = array() ) {
$emails->send( get_option( 'admin_email' ), $admin_subject, $admin_message );
// Setup and send the new user email for the end user.
/* translators: Site name */
$user_subject = apply_filters( 'edd_user_registration_email_subject', sprintf( __( '[%s] Your username and password', 'easy-digital-downloads' ), $from_name ), $user_data );
$user_heading = apply_filters( 'edd_user_registration_email_heading', __( 'Your account info', 'easy-digital-downloads' ), $user_data );
$user_message = apply_filters( 'edd_user_registration_email_username', sprintf( __( 'Username: %s', 'easy-digital-downloads' ), $user_data['user_login'] ) . "\r\n", $user_data );
@ -603,6 +607,7 @@ function edd_new_user_notification( $user_id = 0, $user_data = array() ) {
$password_message = __( 'Password entered at registration', 'easy-digital-downloads' );
}
/* translators: %s: password message */
$user_message .= apply_filters( 'edd_user_registration_email_password', sprintf( __( 'Password: %s', 'easy-digital-downloads' ), '[' . $password_message . ']' ) . "\r\n" );
$login_url = apply_filters( 'edd_user_registration_email_login_url', wp_login_url() );
@ -611,9 +616,8 @@ function edd_new_user_notification( $user_id = 0, $user_data = array() ) {
$user_message .= '<a href="' . esc_url( $login_url ) . '"> ' . esc_attr__( 'Click here to log in', 'easy-digital-downloads' ) . ' &rarr;</a>' . "\r\n";
} else {
/* translators: %s: login URL */
$user_message .= sprintf( __( 'To log in, visit: %s', 'easy-digital-downloads' ), esc_url( $login_url ) ) . "\r\n";
}
$user_message = apply_filters( 'edd_user_registration_email_message', $user_message, $user_data );
@ -769,6 +773,7 @@ function edd_send_user_verification_email( $user_id = 0 ) {
$subject = apply_filters( 'edd_user_verification_email_subject', __( 'Verify your account', 'easy-digital-downloads' ), $user_id );
$heading = apply_filters( 'edd_user_verification_email_heading', __( 'Verify your account', 'easy-digital-downloads' ), $user_id );
$message = sprintf(
/* translators: 1: User display name, 2: Site name, 3: Verification URL */
__( 'Hello %1$s,
Your account with %2$s needs to be verified before you can access your purchase history. <a href="%3$s">Click here</a> to verify your account.
@ -899,6 +904,7 @@ function edd_validate_user_verification_token( $url = '' ) {
do_action( 'edd_user_verification_token_expired' );
$link_text = sprintf(
/* translators: %s: URL to request a new verification link */
__( 'Sorry but your account verification link has expired. <a href="%s">Click here</a> to request a new verification URL.', 'easy-digital-downloads' ),
esc_url( edd_get_user_verification_request_url() )
);
@ -1137,7 +1143,10 @@ function edd_show_user_api_key_field( $user ) {
<tbody>
<tr>
<th>
<?php printf( __( 'Easy Digital Downloads <a href="%s">iOS App</a>', 'easy-digital-downloads' ), 'https://itunes.apple.com/us/app/easy-digital-downloads-2/id1169488828?ls=1&mt=8' ); ?>
<?php
/* translators: %s: iOS App URL */
printf( __( 'Easy Digital Downloads <a href="%s">iOS App</a>', 'easy-digital-downloads' ), 'https://itunes.apple.com/us/app/easy-digital-downloads-2/id1169488828?ls=1&mt=8' );
?>
</th>
<td>
<?php

View File

@ -112,4 +112,18 @@ final class Date extends \Carbon\Carbon {
public function getWPTimestamp() {
return $this->getTimestamp() + EDD()->utils->get_gmt_offset();
}
/**
* Converts a localized date string to UTC.
*
* @since 3.1.4
* @param $format string
* @return string
*/
public function get_utc_from_local( $format = 'Y-m-d H:i:s' ) {
$utc_timezone = new \DateTimeZone( 'utc' );
$this->setTimezone( $utc_timezone );
return $this->format( $format );
}
}