updated plugin Easy Digital Downloads version 3.1.2

This commit is contained in:
2023-06-28 12:45:44 +00:00
committed by Gitium
parent 44df590080
commit f710fa7de2
120 changed files with 5556 additions and 3347 deletions

View File

@ -59,6 +59,7 @@ function edd_tools_banned_emails_display() {
* @return void
*/
function edd_trigger_purchase_delete( $data ) {
_edd_deprecated_function( __FUNCTION__, '3.0' );
if ( wp_verify_nonce( $data['_wpnonce'], 'edd_payment_nonce' ) ) {
$payment_id = absint( $data['purchase_id'] );
@ -72,7 +73,6 @@ function edd_trigger_purchase_delete( $data ) {
edd_redirect( admin_url( 'edit.php?post_type=download&page=edd-payment-history&edd-message=payment_deleted' ) );
}
}
add_action( 'edd_delete_payment', 'edd_trigger_purchase_delete' );
/**
* Add-ons Page
@ -283,6 +283,491 @@ function edd_add_extentions_link() {
}
}
/**
* Display the system info tab
*
* @deprecated 3.1.2
* @since 2.0
*/
function edd_tools_sysinfo_display() {
if ( ! current_user_can( 'manage_shop_settings' ) ) {
return;
}
_edd_deprecated_function( __FUNCTION__, '3.1.2' );
?>
<div class="postbox">
<h3><span><?php esc_html_e( 'System Information', 'easy-digital-downloads' ); ?></span></h3>
<div class="inside">
<p>
<?php esc_html_e( 'Use the system information below to help troubleshoot problems.', 'easy-digital-downloads' ); ?>
</p>
<form id="edd-system-info" action="<?php echo esc_url( admin_url( 'edit.php?post_type=download&page=edd-tools&tab=system_info' ) ); ?>" method="post" dir="ltr">
<textarea readonly="readonly" onclick="this.focus(); this.select()" id="system-info-textarea" class="edd-tools-textarea" name="edd-sysinfo"
><?php echo edd_tools_sysinfo_get(); ?></textarea>
<p>
<input type="hidden" name="edd-action" value="download_sysinfo"/>
<?php
wp_nonce_field( 'edd_download_system_info', 'edd_system_info' );
submit_button( __( 'Download System Info File', 'easy-digital-downloads' ), 'primary', 'edd-download-sysinfo', false );
submit_button( __( 'Copy to Clipboard', 'easy-digital-downloads' ), 'secondary edd-inline-button', 'edd-copy-system-info', false, array( 'onclick' => "this.form['edd-sysinfo'].focus();this.form['edd-sysinfo'].select();document.execCommand('copy');return false;" ) );
?>
</p>
</form>
</div>
</div>
<?php
}
/**
* Get system info.
*
* @deprecated 3.1.2
* @since 2.0
*
* @return string $return A string containing the info to output
*/
function edd_tools_sysinfo_get() {
_edd_deprecated_function( __FUNCTION__, '3.1.2' );
global $wpdb;
if ( ! class_exists( 'Browser' ) ) {
require_once EDD_PLUGIN_DIR . 'includes/libraries/browser.php';
}
$browser = new Browser();
// Get theme info
$theme_data = wp_get_theme();
$theme = $theme_data->Name . ' ' . $theme_data->Version;
$parent_theme = $theme_data->Template;
if ( ! empty( $parent_theme ) ) {
$parent_theme_data = wp_get_theme( $parent_theme );
$parent_theme = $parent_theme_data->Name . ' ' . $parent_theme_data->Version;
}
// Try to identify the hosting provider
$host = edd_get_host();
$return = '### Begin System Info (Generated ' . date( 'Y-m-d H:i:s' ) . ') ###' . "\n\n";
// Start with the basics...
$return .= '-- Site Info' . "\n\n";
$return .= 'Site URL: ' . site_url() . "\n";
$return .= 'Home URL: ' . home_url() . "\n";
$return .= 'Multisite: ' . ( is_multisite() ? 'Yes' : 'No' ) . "\n";
$return = apply_filters( 'edd_sysinfo_after_site_info', $return );
// Can we determine the site's host?
if ( $host ) {
$return .= "\n" . '-- Hosting Provider' . "\n\n";
$return .= 'Host: ' . $host . "\n";
$return = apply_filters( 'edd_sysinfo_after_host_info', $return );
}
// The local users' browser information, handled by the Browser class
$return .= "\n" . '-- User Browser' . "\n\n";
$return .= $browser;
$return = apply_filters( 'edd_sysinfo_after_user_browser', $return );
$locale = get_locale();
// WordPress configuration
$return .= "\n" . '-- WordPress Configuration' . "\n\n";
$return .= 'Version: ' . get_bloginfo( 'version' ) . "\n";
$return .= 'Language: ' . ( ! empty( $locale ) ? $locale : 'en_US' ) . "\n";
$return .= 'Permalink Structure: ' . ( get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : 'Default' ) . "\n";
$return .= 'Active Theme: ' . $theme . "\n";
$return .= 'WP Timezone: ' . wp_timezone_string() . "\n";
$return .= 'EDD Timezone: ' . edd_get_timezone_abbr() . "\n";
if ( $parent_theme !== $theme ) {
$return .= 'Parent Theme: ' . $parent_theme . "\n";
}
$customized_template_files = edd_get_theme_edd_templates();
$return .= "\n" . '-- Customized Templates' . "\n\n";
if ( empty( $customized_template_files ) ) {
$return .= 'No custom templates found.' . "\n\n";
} else {
foreach ( $customized_template_files as $customized_template_file ) {
$return .= $customized_template_file . "\n";
}
}
$return .= "\n";
$return = apply_filters( 'edd_sysinfo_after_customized_templates', $return );
$return .= 'Show On Front: ' . get_option( 'show_on_front' ) . "\n";
// Only show page specs if frontpage is set to 'page'
if ( get_option( 'show_on_front' ) == 'page' ) {
$front_page_id = get_option( 'page_on_front' );
$blog_page_id = get_option( 'page_for_posts' );
$return .= 'Page On Front: ' . ( $front_page_id != 0 ? '#' . $front_page_id : 'Unset' ) . "\n";
$return .= 'Page For Posts: ' . ( $blog_page_id != 0 ? '#' . $blog_page_id : 'Unset' ) . "\n";
}
$return .= 'ABSPATH: ' . ABSPATH . "\n";
// Make sure wp_remote_post() is working
$request['cmd'] = '_notify-validate';
$params = array(
'sslverify' => false,
'timeout' => 60,
'user-agent' => 'EDD/' . EDD_VERSION,
'body' => $request,
);
$response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
$WP_REMOTE_POST = 'wp_remote_post() works';
} else {
$WP_REMOTE_POST = 'wp_remote_post() does not work';
}
$return .= 'Remote Post: ' . $WP_REMOTE_POST . "\n";
$return .= 'Table Prefix: ' . 'Length: ' . strlen( $wpdb->prefix ) . ' Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ) . "\n";
// Commented out per https://github.com/easydigitaldownloads/Easy-Digital-Downloads/issues/3475
//$return .= 'Admin AJAX: ' . ( edd_test_ajax_works() ? 'Accessible' : 'Inaccessible' ) . "\n";
$return .= 'WP_DEBUG: ' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ) . "\n";
$return .= 'Memory Limit: ' . WP_MEMORY_LIMIT . "\n";
$return .= 'Registered Post Stati: ' . implode( ', ', get_post_stati() ) . "\n";
$return = apply_filters( 'edd_sysinfo_after_wordpress_config', $return );
// EDD configuration
$return .= "\n" . '-- EDD Configuration' . "\n\n";
$return .= 'Version: ' . EDD_VERSION . "\n";
$return .= 'Upgraded From: ' . get_option( 'edd_version_upgraded_from', 'None' ) . "\n";
$return .= 'EDD (Pro) Status: ' . ( edd_is_pro() ? "Enabled\n" : "Disabled\n" );
$return .= 'EDD (Pro) Activated On: ' . ( get_option( 'edd_pro_activation_date' ) ? edd_date_i18n( get_option( 'edd_pro_activation_date' ), 'Y-m-d' ) . "\n" : "N/A\n" );
$return .= 'EDD Pass Status: ' . ( EDD\Admin\Pass_Manager::isPro() ? "Valid Pass\n" : "Missing\n" );
$return .= 'Test Mode: ' . ( edd_is_test_mode() ? "Enabled\n" : "Disabled\n" );
$return .= 'AJAX: ' . ( ! edd_is_ajax_disabled() ? "Enabled\n" : "Disabled\n" );
$return .= 'Guest Checkout: ' . ( edd_no_guest_checkout() ? "Disabled\n" : "Enabled\n" );
$return .= 'Symlinks: ' . ( apply_filters( 'edd_symlink_file_downloads', edd_get_option( 'symlink_file_downloads', false ) ) && function_exists( 'symlink' ) ? "Enabled\n" : "Disabled\n" );
$return .= 'Download Method: ' . ucfirst( edd_get_file_download_method() ) . "\n";
$return .= 'Currency Code: ' . edd_get_currency() . "\n";
$return .= 'Currency Position: ' . edd_get_option( 'currency_position', 'before' ) . "\n";
$return .= 'Decimal Separator: ' . edd_get_option( 'decimal_separator', '.' ) . "\n";
$return .= 'Thousands Separator: ' . edd_get_option( 'thousands_separator', ',' ) . "\n";
$return .= 'Upgrades Completed: ' . implode( ',', edd_get_completed_upgrades() ) . "\n";
$return .= 'Download Link Expiration: ' . edd_get_option( 'download_link_expiration' ) . " hour(s)\n";
$return = apply_filters( 'edd_sysinfo_after_edd_config', $return );
// EDD Database tables
$return .= "\n" . '-- EDD Database Tables' . "\n\n";
foreach ( EDD()->components as $component ) {
// Object
$thing = $component->get_interface( 'table' );
if ( ! empty( $thing ) ) {
$return .= str_pad( $thing->name . ': ', 32, ' ' ) . $thing->get_version() . "\n";
}
// Meta
$thing = $component->get_interface( 'meta' );
if ( ! empty( $thing ) ) {
$return .= str_pad( $thing->name . ': ', 32, ' ' ) . $thing->get_version() . "\n";
}
}
$return = apply_filters( 'edd_sysinfo_after_edd_database_tables', $return );
// EDD Database tables
$return .= "\n" . '-- EDD Database Row Counts' . "\n\n";
foreach ( EDD()->components as $component ) {
// Object
$thing = $component->get_interface( 'table' );
if ( ! empty( $thing ) ) {
$return .= str_pad( $thing->name . ': ', 32, ' ' ) . $thing->count() . "\n";
}
// Meta
$thing = $component->get_interface( 'meta' );
if ( ! empty( $thing ) ) {
$return .= str_pad( $thing->name . ': ', 32, ' ' ) . $thing->count() . "\n";
}
}
$return = apply_filters( 'edd_sysinfo_after_edd_database_row_counts', $return );
// EDD pages
$purchase_page = edd_get_option( 'purchase_page', '' );
$success_page = edd_get_option( 'success_page', '' );
$failure_page = edd_get_option( 'failure_page', '' );
$return .= "\n" . '-- EDD Page Configuration' . "\n\n";
$return .= 'Checkout: ' . ( ! empty( $purchase_page ) ? "Valid\n" : "Invalid\n" );
$return .= 'Checkout Page: ' . ( ! empty( $purchase_page ) ? get_permalink( $purchase_page ) . "\n" : "Unset\n" );
$return .= 'Success Page: ' . ( ! empty( $success_page ) ? get_permalink( $success_page ) . "\n" : "Unset\n" );
$return .= 'Failure Page: ' . ( ! empty( $failure_page ) ? get_permalink( $failure_page ) . "\n" : "Unset\n" );
$return .= 'Downloads Slug: ' . ( defined( 'EDD_SLUG' ) ? '/' . EDD_SLUG . "\n" : "/downloads\n" );
$return = apply_filters( 'edd_sysinfo_after_edd_pages', $return );
// EDD gateways
$return .= "\n" . '-- EDD Gateway Configuration' . "\n\n";
$active_gateways = edd_get_enabled_payment_gateways();
if ( $active_gateways ) {
$default_gateway_is_active = edd_is_gateway_active( edd_get_default_gateway() );
if ( $default_gateway_is_active ) {
$default_gateway = edd_get_default_gateway();
$default_gateway = $active_gateways[ $default_gateway ]['admin_label'];
} else {
$default_gateway = 'Test Payment';
}
$gateways = array();
foreach ( $active_gateways as $gateway ) {
$gateways[] = $gateway['admin_label'];
}
$return .= 'Enabled Gateways: ' . implode( ', ', $gateways ) . "\n";
$return .= 'Default Gateway: ' . $default_gateway . "\n";
} else {
$return .= 'Enabled Gateways: None' . "\n";
}
$return = apply_filters( 'edd_sysinfo_after_edd_gateways', $return );
// EDD Taxes
$return .= "\n" . '-- EDD Tax Configuration' . "\n\n";
$return .= 'Taxes: ' . ( edd_use_taxes() ? "Enabled\n" : "Disabled\n" );
$return .= 'Default Rate: ' . edd_get_formatted_tax_rate() . "\n";
$return .= 'Display On Checkout: ' . ( edd_get_option( 'checkout_include_tax', false ) ? "Displayed\n" : "Not Displayed\n" );
$return .= 'Prices Include Tax: ' . ( edd_prices_include_tax() ? "Yes\n" : "No\n" );
$rates = edd_get_tax_rates();
if ( ! empty( $rates ) ) {
$return .= 'Country / State Rates: ' . "\n";
foreach ( $rates as $rate ) {
$return .= ' Country: ' . $rate['country'] . ', State: ' . $rate['state'] . ', Rate: ' . $rate['rate'] . "\n";
}
}
$return = apply_filters( 'edd_sysinfo_after_edd_taxes', $return );
// EDD Templates
$dir = get_stylesheet_directory() . '/edd_templates/*';
if ( is_dir( $dir ) && ( count( glob( "$dir/*" ) ) !== 0 ) ) {
$return .= "\n" . '-- EDD Template Overrides' . "\n\n";
foreach ( glob( $dir ) as $file ) {
$return .= 'Filename: ' . basename( $file ) . "\n";
}
$return = apply_filters( 'edd_sysinfo_after_edd_templates', $return );
}
// Drop Ins
$dropins = get_dropins();
if ( count( $dropins ) > 0 ) {
$return .= "\n" . '-- Drop Ins' . "\n\n";
foreach ( $dropins as $plugin => $plugin_data ) {
$return .= str_pad( $plugin_data['Name'] . ': ', 26, ' ' ) . $plugin_data['Version'] . "\n";
}
$return = apply_filters( 'edd_sysinfo_after_wordpress_dropin_plugins', $return );
}
// Get plugins that have an update
$updates = get_plugin_updates();
// Must-use plugins
// NOTE: MU plugins can't show updates!
$muplugins = get_mu_plugins();
if ( count( $muplugins ) > 0 ) {
$return .= "\n" . '-- Must-Use Plugins' . "\n\n";
foreach ( $muplugins as $plugin => $plugin_data ) {
$return .= str_pad( $plugin_data['Name'] . ': ', 26, ' ' ) . $plugin_data['Version'] . "\n";
}
$return = apply_filters( 'edd_sysinfo_after_wordpress_mu_plugins', $return );
}
// WordPress active plugins
$return .= "\n" . '-- WordPress Active Plugins' . "\n\n";
$plugins = get_plugins();
$active_plugins = get_option( 'active_plugins', array() );
foreach ( $plugins as $plugin_path => $plugin ) {
if ( ! in_array( $plugin_path, $active_plugins ) ) {
continue;
}
$update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[ $plugin_path ]->update->new_version . ')' : '';
$plugin_url = '';
if ( ! empty( $plugin['PluginURI'] ) ) {
$plugin_url = $plugin['PluginURI'];
} elseif ( ! empty( $plugin['AuthorURI'] ) ) {
$plugin_url = $plugin['AuthorURI'];
} elseif ( ! empty( $plugin['Author'] ) ) {
$plugin_url = $plugin['Author'];
}
if ( $plugin_url ) {
$plugin_url = "\n" . $plugin_url;
}
$return .= str_pad( $plugin['Name'] . ': ', 26, ' ' ) . $plugin['Version'] . $update . $plugin_url . "\n\n";
}
$return = apply_filters( 'edd_sysinfo_after_wordpress_plugins', $return );
// WordPress inactive plugins
$return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n";
foreach ( $plugins as $plugin_path => $plugin ) {
if ( in_array( $plugin_path, $active_plugins ) ) {
continue;
}
$update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[ $plugin_path ]->update->new_version . ')' : '';
$plugin_url = '';
if ( ! empty( $plugin['PluginURI'] ) ) {
$plugin_url = $plugin['PluginURI'];
} elseif ( ! empty( $plugin['AuthorURI'] ) ) {
$plugin_url = $plugin['AuthorURI'];
} elseif ( ! empty( $plugin['Author'] ) ) {
$plugin_url = $plugin['Author'];
}
if ( $plugin_url ) {
$plugin_url = "\n" . $plugin_url;
}
$return .= str_pad( $plugin['Name'] . ': ', 26, ' ' ) . $plugin['Version'] . $update . $plugin_url . "\n\n";
}
$return = apply_filters( 'edd_sysinfo_after_wordpress_plugins_inactive', $return );
if ( is_multisite() ) {
// WordPress Multisite active plugins
$return .= "\n" . '-- Network Active Plugins' . "\n\n";
$plugins = wp_get_active_network_plugins();
$active_plugins = get_site_option( 'active_sitewide_plugins', array() );
foreach ( $plugins as $plugin_path ) {
$plugin_base = plugin_basename( $plugin_path );
if ( ! array_key_exists( $plugin_base, $active_plugins ) ) {
continue;
}
$update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[ $plugin_path ]->update->new_version . ')' : '';
$plugin = get_plugin_data( $plugin_path );
$plugin_url = '';
if ( ! empty( $plugin['PluginURI'] ) ) {
$plugin_url = $plugin['PluginURI'];
} elseif ( ! empty( $plugin['AuthorURI'] ) ) {
$plugin_url = $plugin['AuthorURI'];
} elseif ( ! empty( $plugin['Author'] ) ) {
$plugin_url = $plugin['Author'];
}
if ( $plugin_url ) {
$plugin_url = "\n" . $plugin_url;
}
$return .= str_pad( $plugin['Name'] . ': ', 26, ' ' ) . $plugin['Version'] . $update . $plugin_url . "\n\n";
}
$return = apply_filters( 'edd_sysinfo_after_wordpress_ms_plugins', $return );
}
// Server configuration (really just versioning)
$return .= "\n" . '-- Webserver Configuration' . "\n\n";
$return .= 'PHP Version: ' . PHP_VERSION . "\n";
$return .= 'MySQL Version: ' . $wpdb->db_version() . "\n";
$return .= 'Webserver Info: ' . $_SERVER['SERVER_SOFTWARE'] . "\n";
$return = apply_filters( 'edd_sysinfo_after_webserver_config', $return );
// PHP configs... now we're getting to the important stuff
$return .= "\n" . '-- PHP Configuration' . "\n\n";
$return .= 'Memory Limit: ' . ini_get( 'memory_limit' ) . "\n";
$return .= 'Upload Max Size: ' . ini_get( 'upload_max_filesize' ) . "\n";
$return .= 'Post Max Size: ' . ini_get( 'post_max_size' ) . "\n";
$return .= 'Upload Max Filesize: ' . ini_get( 'upload_max_filesize' ) . "\n";
$return .= 'Time Limit: ' . ini_get( 'max_execution_time' ) . "\n";
$return .= 'Max Input Vars: ' . ini_get( 'max_input_vars' ) . "\n";
$return .= 'Display Errors: ' . ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ) . "\n";
$return .= 'PHP Arg Separator: ' . edd_get_php_arg_separator_output() . "\n";
$return = apply_filters( 'edd_sysinfo_after_php_config', $return );
// PHP extensions and such
$return .= "\n" . '-- PHP Extensions' . "\n\n";
$return .= 'cURL: ' . ( function_exists( 'curl_init' ) ? 'Supported' : 'Not Supported' ) . "\n";
$return .= 'fsockopen: ' . ( function_exists( 'fsockopen' ) ? 'Supported' : 'Not Supported' ) . "\n";
$return .= 'SOAP Client: ' . ( class_exists( 'SoapClient' ) ? 'Installed' : 'Not Installed' ) . "\n";
$return .= 'Suhosin: ' . ( extension_loaded( 'suhosin' ) ? 'Installed' : 'Not Installed' ) . "\n";
$return = apply_filters( 'edd_sysinfo_after_php_ext', $return );
// Session stuff
$return .= "\n" . '-- Session Configuration' . "\n\n";
$return .= 'EDD Use Sessions: ' . ( defined( 'EDD_USE_PHP_SESSIONS' ) && EDD_USE_PHP_SESSIONS ? 'Enforced' : ( EDD()->session->use_php_sessions() ? 'Enabled' : 'Disabled' ) ) . "\n";
$return .= 'Session: ' . ( isset( $_SESSION ) ? 'Enabled' : 'Disabled' ) . "\n";
// The rest of this is only relevant is session is enabled
if ( isset( $_SESSION ) ) {
$return .= 'Session Name: ' . esc_html( ini_get( 'session.name' ) ) . "\n";
$return .= 'Cookie Path: ' . esc_html( ini_get( 'session.cookie_path' ) ) . "\n";
$return .= 'Save Path: ' . esc_html( ini_get( 'session.save_path' ) ) . "\n";
$return .= 'Use Cookies: ' . ( ini_get( 'session.use_cookies' ) ? 'On' : 'Off' ) . "\n";
$return .= 'Use Only Cookies: ' . ( ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off' ) . "\n";
}
$return = apply_filters( 'edd_sysinfo_after_session_config', $return );
$return .= "\n" . '### End System Info ###';
return $return;
}
/**
* Generates a System Info download file
*
* @deprecated 3.1.2
* @since 2.0
*/
function edd_tools_sysinfo_download() {
_edd_deprecated_function( __FUNCTION__, '3.1.2' );
if ( ! current_user_can( 'manage_shop_settings' ) ) {
return;
}
check_admin_referer( 'edd_download_system_info', 'edd_system_info' );
nocache_headers();
header( 'Content-Type: text/plain' );
header( 'Content-Disposition: attachment; filename="edd-system-info.txt"' );
echo wp_strip_all_tags( $_POST['edd-sysinfo'] );
edd_die();
}
/**
* Process bulk edit actions via AJAX
*
@ -292,6 +777,7 @@ function edd_add_extentions_link() {
*/
function edd_save_bulk_edit() {
_edd_deprecated_function( __FUNCTION__, '3.1.1.4' );
$post_ids = ! empty( $_POST['post_ids'] )
? wp_parse_id_list( $_POST['post_ids'] )
: array();
@ -314,3 +800,89 @@ function edd_save_bulk_edit() {
die();
}
/**
* Remove sale logs from refunded orders
*
* @deprecated 3.1.2
* @since 2.4.3
* @return void
*/
function edd_remove_refunded_sale_logs() {
_edd_deprecated_function( __FUNCTION__, '3.1.2' );
check_admin_referer( 'edd-upgrade' );
if ( ! current_user_can( 'manage_shop_settings' ) ) {
wp_die( __( 'You do not have permission to do shop upgrades', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
}
edd_set_time_limit();
$step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1;
$total = isset( $_GET['total'] ) ? absint( $_GET['total'] ) : edd_count_payments()->refunded;
$refunds = edd_get_payments( array(
'status' => 'refunded',
'number' => 20,
'page' => $step
) );
if ( ! empty( $refunds ) ) {
$edd_logs = EDD()->debug_log;
// Refunded Payments found so process them
foreach ( $refunds as $refund ) {
// Remove related sale log entries
$edd_logs->delete_logs(
null,
'sale',
array(
array(
'key' => '_edd_log_payment_id',
'value' => $refund->ID
)
)
);
}
$step++;
$redirect = add_query_arg( array(
'page' => 'edd-upgrades',
'edd-upgrade' => 'remove_refunded_sale_logs',
'step' => urlencode( $step ),
'total' => urlencode( $total ),
'_wpnonce' => wp_create_nonce( 'edd-upgrade' ),
), admin_url( 'index.php' ) );
edd_redirect( $redirect );
// No more refunded payments found, finish up
} else {
edd_set_upgrade_complete( 'remove_refunded_sale_logs' );
delete_option( 'edd_doing_upgrade' );
edd_redirect( admin_url() );
}
}
/**
* Sales Log View
*
* @deprecated 3.0
*
* @since 1.4
* @uses EDD_Sales_Log_Table::prepare_items()
* @uses EDD_Sales_Log_Table::display()
* @return void
*/
function edd_logs_view_sales() {
_edd_deprecated_function( __FUNCTION__, '3.0' );
// Setup or bail
if ( ! edd_logs_view_setup( 'sales' ) ) {
return;
}
$logs_table = new EDD_Sales_Log_Table();
edd_logs_view_page( $logs_table, 'sales' );
}

View File

@ -208,17 +208,17 @@ function edd_is_admin_page( $passed_page = '', $passed_view = '', $include_non_e
switch ( $passed_view ) {
case 'list-table':
case 'new':
if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit-tags.php' && 'edit' !== $action && 'download_tax' === $taxonomy ) {
if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit-tags.php' && 'edit' !== $action && 'download_tag' === $taxonomy ) {
$found = true;
}
break;
case 'edit':
if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit-tags.php' && 'edit' === $action && 'download_tax' === $taxonomy ) {
if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit-tags.php' && 'edit' === $action && 'download_tag' === $taxonomy ) {
$found = true;
}
break;
default:
if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit-tags.php' && 'download_tax' === $taxonomy ) {
if ( ( 'download' === $typenow || 'download' === $post_type ) && $pagenow === 'edit-tags.php' && 'download_tag' === $taxonomy ) {
$found = true;
}
break;

View File

@ -128,11 +128,6 @@ class EDD_Notices {
*/
public function add_notices() {
// User can edit pages
if ( current_user_can( 'edit_pages' ) ) {
$this->add_page_notices();
}
// User can view shop reports
if ( current_user_can( 'view_shop_reports' ) ) {
$this->add_reports_notices();
@ -140,9 +135,9 @@ class EDD_Notices {
// User can manage the entire shop
if ( current_user_can( 'manage_shop_settings' ) ) {
$this->add_system_notices();
$this->add_data_notices();
$this->add_settings_notices();
$this->add_order_upgrade_notice();
}
// Generic notices
@ -189,6 +184,10 @@ class EDD_Notices {
* @since 2.6.0 bbPress (r6771)
*/
public function display_notices() {
$screen = get_current_screen();
if ( 'site-health' === $screen->id ) {
return;
}
$this->show_debugging_notice();
@ -261,6 +260,7 @@ class EDD_Notices {
* Notices about missing pages
*
* @since 3.0
* @deprecated 3.1.2
*/
private function add_page_notices() {
@ -289,6 +289,7 @@ class EDD_Notices {
* Notices for the entire shop
*
* @since 3.0
* @deprecated 3.1.2
*/
private function add_system_notices() {
@ -419,41 +420,48 @@ class EDD_Notices {
private function add_settings_notices() {
// Settings area
if ( ! empty( $_GET['page'] ) && ( 'edd-settings' === $_GET['page'] ) ) {
if ( empty( $_GET['page'] ) || ( 'edd-settings' !== $_GET['page'] ) ) {
return;
}
// Settings updated
if ( ! empty( $_GET['settings-updated'] ) ) {
$this->add_notice( array(
// Settings updated
if ( ! empty( $_GET['settings-updated'] ) ) {
$this->add_notice(
array(
'id' => 'edd-notices',
'message' => __( 'Settings updated.', 'easy-digital-downloads' )
) );
}
// No payment gateways are enabled
if ( ! edd_get_option( 'gateways' ) && edd_is_test_mode() ) {
// URL to fix this
$url = edd_get_admin_url(
array(
'page' => 'edd-settings',
'tab' => 'gateways',
)
);
// Link
$link = '<a href="' . esc_url( $url ) . '">' . __( 'Fix this', 'easy-digital-downloads' ) . '</a>';
// Add the notice
$this->add_notice( array(
'id' => 'edd-gateways',
'class' => 'error',
'message' => sprintf( __( 'No payment gateways are enabled. %s.', 'easy-digital-downloads' ), $link ),
'is_dismissible' => false
) );
}
)
);
}
}
/**
* Adds a notice if an order migration is running.
* This is only shown if the migration is running via UI by a different user or on another screen.
*
* @since 3.1.2
* @return void
*/
private function add_order_upgrade_notice() {
if ( edd_has_upgrade_completed( 'migrate_orders' ) ) {
return;
}
if ( ! get_option( '_edd_v30_doing_order_migration', false ) ) {
return;
}
if ( get_option( 'edd_v30_cli_migration_running', false ) ) {
return;
}
$this->add_notice(
array(
'id' => 'edd-v30-order-migration-running',
'class' => 'updated',
'message' => __( 'Easy Digital Downloads is migrating orders. Sales and earnings data for your store will be updated when all orders have been migrated.', 'easy-digital-downloads' ),
'is_dismissible' => false,
)
);
}
/**
* Notices about actions that the user has taken
*

View File

@ -47,6 +47,16 @@ class EDD_Email_Summary_Admin {
* @param array $data GET Request array.
*/
public function send_test_email_summary() {
if ( ! current_user_can( 'manage_shop_settings' ) ) {
echo wp_json_encode(
array(
'status' => 'error',
'message' => __( 'You do not have permission to perform this action.', 'easy-digital-downloads' ),
)
);
}
add_action( 'wp_mail_failed', array( $this, 'mail_failed' ) );
$output = array(

View File

@ -259,11 +259,12 @@ class EDD_Batch_Downloads_Import extends EDD_Batch_Import {
*/
public function get_percentage_complete() {
if( $this->total > 0 ) {
$percentage = 0;
if ( $this->total > 0 ) {
$percentage = ( $this->step * $this->per_step / $this->total ) * 100;
}
if( $percentage > 100 ) {
if ( $percentage > 100 ) {
$percentage = 100;
}
@ -368,7 +369,7 @@ class EDD_Batch_Downloads_Import extends EDD_Batch_Import {
private function set_image( $download_id = 0, $image = '', $post_author = 0 ) {
$is_url = false !== filter_var( $image, FILTER_VALIDATE_URL );
$is_local = $is_url && false !== strpos( site_url(), $image );
$is_local = $is_url && false !== strpos( $image, site_url() );
$ext = edd_get_file_extension( $image );
if( $is_url && $is_local ) {

View File

@ -608,13 +608,14 @@ class EDD_Batch_Payments_Import extends EDD_Batch_Import {
*/
public function get_percentage_complete() {
$total = count( $this->csv );
$percentage = 0;
$total = count( $this->csv );
if( $total > 0 ) {
if ( $total > 0 ) {
$percentage = ( $this->step * $this->per_step / $total ) * 100;
}
if( $percentage > 100 ) {
if ( $percentage > 100 ) {
$percentage = 100;
}

View File

@ -85,13 +85,23 @@ class EDD_Batch_Import {
*/
public function __construct( $_file = '', $_step = 1 ) {
$this->step = $_step;
$this->file = $_file;
$this->done = false;
$this->csv = $this->get_csv_file( $this->file );
$this->step = $_step;
$this->done = false;
if ( ! empty( $_file ) ) {
$this->set_up_csv( $_file );
}
}
/**
* Sets up the CSV file for importing.
*
* @param [type] $file
* @return void
*/
public function set_up_csv( $file ) {
$this->csv = $this->get_csv_file( $file );
$this->total = count( $this->csv );
$this->init();
}
/**
@ -121,7 +131,8 @@ class EDD_Batch_Import {
* @return array
*/
public function get_csv_file( $file ) {
$csv = array_map( 'str_getcsv', file( $this->file ) );
$this->file = $file;
$csv = array_map( 'str_getcsv', file( $file ) );
array_walk(
$csv,
function ( &$a ) use ( $csv ) {

View File

@ -21,21 +21,36 @@ defined( 'ABSPATH' ) || exit;
*/
function edd_do_ajax_import_file_upload() {
if ( ! wp_verify_nonce( $_REQUEST['edd_ajax_import'], 'edd_ajax_import' ) ) {
wp_send_json_error( array( 'error' => __( 'Nonce verification failed', 'easy-digital-downloads' ) ) );
}
if ( empty( $_POST['edd-import-class'] ) ) {
wp_send_json_error( array( 'error' => __( 'Missing import parameters. Import class must be specified.', 'easy-digital-downloads' ), 'request' => $_REQUEST ) );
}
if ( ! function_exists( 'wp_handle_upload' ) ) {
require_once( ABSPATH . 'wp-admin/includes/file.php' );
require_once ABSPATH . 'wp-admin/includes/file.php';
}
require_once EDD_PLUGIN_DIR . 'includes/admin/import/class-batch-import.php';
if( ! wp_verify_nonce( $_REQUEST['edd_ajax_import'], 'edd_ajax_import' ) ) {
wp_send_json_error( array( 'error' => __( 'Nonce verification failed', 'easy-digital-downloads' ) ) );
$importer_class = sanitize_text_field( $_POST['edd-import-class'] );
$is_class_allowed = edd_importer_is_class_allowed( $importer_class );
if ( false === $is_class_allowed ) {
wp_send_json_error( array( 'error' => __( 'Invalid importer class supplied', 'easy-digital-downloads' ) ) );
}
if( empty( $_POST['edd-import-class'] ) ) {
wp_send_json_error( array( 'error' => __( 'Missing import parameters. Import class must be specified.', 'easy-digital-downloads' ), 'request' => $_REQUEST ) );
do_action( 'edd_batch_import_class_include', $importer_class );
$import = new $importer_class();
// The import class checks for the user's capability.
if ( ! $import->can_import() ) {
wp_send_json_error( array( 'error' => __( 'You do not have permission to import data', 'easy-digital-downloads' ) ) );
}
if( empty( $_FILES['edd-import-file'] ) ) {
if ( empty( $_FILES['edd-import-file'] ) ) {
wp_send_json_error( array( 'error' => __( 'Missing import file. Please provide an import file.', 'easy-digital-downloads' ), 'request' => $_REQUEST ) );
}
@ -43,7 +58,7 @@ function edd_do_ajax_import_file_upload() {
wp_send_json_error( array( 'error' => __( 'The file you uploaded does not appear to be a CSV file.', 'easy-digital-downloads' ), 'request' => $_REQUEST ) );
}
if( ! file_exists( $_FILES['edd-import-file']['tmp_name'] ) ) {
if ( ! file_exists( $_FILES['edd-import-file']['tmp_name'] ) ) {
wp_send_json_error( array( 'error' => __( 'Something went wrong during the upload process, please try again.', 'easy-digital-downloads' ), 'request' => $_REQUEST ) );
}
@ -52,20 +67,7 @@ function edd_do_ajax_import_file_upload() {
if ( $import_file && empty( $import_file['error'] ) ) {
$importer_class = sanitize_text_field( $_POST['edd-import-class'] );
$is_class_allowed = edd_importer_is_class_allowed( $importer_class );
if ( false === $is_class_allowed ) {
wp_send_json_error( array( 'error' => __( 'Invalid importer class supplied', 'easy-digital-downloads' ) ) );
}
do_action( 'edd_batch_import_class_include', $importer_class );
$import = new $importer_class( $import_file['file'] );
if( ! $import->can_import() ) {
wp_send_json_error( array( 'error' => __( 'You do not have permission to import data', 'easy-digital-downloads' ) ) );
}
$import->set_up_csv( $import_file['file'] );
wp_send_json_success( array(
'form' => $_POST,
'class' => $importer_class,
@ -104,11 +106,11 @@ function edd_do_ajax_import() {
wp_send_json_error( array( 'error' => __( 'Nonce verification failed', 'easy-digital-downloads' ), 'request' => $_REQUEST ) );
}
if( empty( $_REQUEST['class'] ) ) {
if ( empty( $_REQUEST['class'] ) ) {
wp_send_json_error( array( 'error' => __( 'Missing import parameters. Import class must be specified.', 'easy-digital-downloads' ), 'request' => $_REQUEST ) );
}
if( ! file_exists( $_REQUEST['upload']['file'] ) ) {
if ( ! file_exists( $_REQUEST['upload']['file'] ) ) {
wp_send_json_error( array( 'error' => __( 'Something went wrong during the upload process, please try again.', 'easy-digital-downloads' ), 'request' => $_REQUEST ) );
}
@ -140,13 +142,12 @@ function edd_do_ajax_import() {
$step = absint( $_REQUEST['step'] );
$class = $importer_class;
$import = new $class( $file, $step );
if( ! $import->can_import() ) {
$import = new $class( '', $step );
if ( ! $import->can_import() ) {
wp_send_json_error( array( 'error' => __( 'You do not have permission to import data', 'easy-digital-downloads' ) ) );
}
$import->set_up_csv( $file );
parse_str( $_REQUEST['mapping'], $map );

View File

@ -563,7 +563,7 @@ function edd_get_registered_settings() {
'default_gateway' => array(
'id' => 'default_gateway',
'name' => __( 'Default Gateway', 'easy-digital-downloads' ),
'desc' => __( 'Automatically select this gateway on checkout pages.<br>If empty, the first active gateway is selected instead.', 'easy-digital-downloads' ),
'desc' => __( 'Choose the gateway your checkout will use by default.<br />If you choose Automatic, the first enabled gateway from the Active Gateways will be used.', 'easy-digital-downloads' ),
'type' => 'gateway_select',
'options' => $gateways,
),
@ -2151,11 +2151,37 @@ function edd_gateways_callback( $args ) {
$html .= '<li class="edd-check-wrapper" data-key="' . edd_sanitize_key( $key ) . '">';
$html .= '<label>';
$html .= '<input name="edd_settings[' . esc_attr( $args['id'] ) . '][' . edd_sanitize_key( $key ) . ']" id="edd_settings[' . edd_sanitize_key( $args['id'] ) . '][' . edd_sanitize_key( $key ) . ']" class="' . $class . '" type="checkbox" value="1" data-gateway-key="' . edd_sanitize_key( $key ) . '" ' . checked( '1', $enabled, false ) . '/>&nbsp;';
$attributes = array(
'name' => 'edd_settings[' . edd_sanitize_key( $args['id'] ) . '][' . edd_sanitize_key( $key ) . ']',
'id' => 'edd_settings[' . edd_sanitize_key( $args['id'] ) . '][' . edd_sanitize_key( $key ) . ']',
'data-gateway-key' => edd_sanitize_key( $key ),
'checked' => checked( '1', $enabled, false ),
'is_setup' => edd_is_gateway_setup( $key ),
'disabled' => '',
);
if ( ! $attributes['is_setup'] ) {
$attributes['disabled'] = 'disabled="disabled"';
}
$html .= '<input name="' . $attributes['name'] . '" id="' . $attributes['id'] . '" class="' . $class . '" type="checkbox" value="1" data-gateway-key="' . $attributes['data-gateway-key'] . '" ' . $attributes['checked'] . ' ' . $attributes['disabled'] . '/>&nbsp;';
$html .= esc_html( $option['admin_label'] );
if ( 'manual' === $key ) {
$html .= '<span alt="f223" class="edd-help-tip dashicons dashicons-editor-help" title="<strong>' . esc_html__( 'Store Gateway', 'easy-digital-downloads' ) . '</strong>: ' . esc_html__( 'This is an internal payment gateway which can be used for manually added orders or test purchases. No money is actually processed.', 'easy-digital-downloads' ) . '"></span>';
}
// If a settings URL is returned, display a button to go to the settings page.
$gateway_settings_url = edd_get_gateway_settings_url( $key );
if ( ! empty( $gateway_settings_url ) ) {
$html .= sprintf(
'<a class="button edd-settings__button-settings" href="%s"><span class="screen-reader-text">%s</span></a>',
$gateway_settings_url,
__( 'Configure Gateway', 'easy-digital-downloads' )
);
}
$html .= '</label>';
$html .= '</li>';
}
@ -2170,7 +2196,7 @@ function edd_gateways_callback( $args ) {
)
);
$html .= '<p class="description">' . esc_html__( 'These gateways will be offered at checkout.', 'easy-digital-downloads' ) . '<br>' . sprintf( __( 'More <a href="%s">Payment Gateways</a> are available.', 'easy-digital-downloads' ), $url ) . '</p>';
$html .= '<p class="description">' . esc_html__( 'Choose how you want to allow your customers to pay you.', 'easy-digital-downloads' ) . '<br>' . sprintf( __( 'More <a href="%s">Payment Gateways</a> are available.', 'easy-digital-downloads' ), $url ) . '</p>';
}
echo apply_filters( 'edd_after_setting_output', $html, $args );
@ -2199,7 +2225,7 @@ function edd_gateway_select_callback( $args ) {
}
$html = '<select name="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']"" id="edd_settings[' . edd_sanitize_key( $args['id'] ) . ']" class="' . $class . '">';
$html .= '<option value="">' . __( '&mdash; No gateway &mdash;', 'easy-digital-downloads' ) . '</option>';
$html .= '<option value="">' . __( 'Automatic', 'easy-digital-downloads' ) . '</option>';
$gateways = edd_get_payment_gateways();
foreach ( $gateways as $key => $option ) {
@ -2858,6 +2884,11 @@ if ( ! function_exists( 'edd_license_key_callback' ) ) {
* @return void
*/
function edd_hook_callback( $args ) {
// Since our settings are hook based, just be sure the user can manage shop settings before firing the setting hook.
if ( ! current_user_can( 'manage_shop_settings') ) {
return;
}
do_action( 'edd_' . $args['id'], $args );
}

View File

@ -58,6 +58,17 @@ function edd_tools_page() {
$tab_url
);
// System Info is now found in Site Health.
if ( 'system_info' === $tab_id ) {
$tab_url = add_query_arg(
array(
'tab' => 'debug',
'edd' => 'filter',
),
admin_url( 'site-health.php' )
);
}
$active = ( $active_tab === $tab_id )
? ' nav-tab-active'
: '';
@ -469,7 +480,7 @@ function edd_tools_import_export_display() {
<?php wp_nonce_field( 'edd_ajax_import', 'edd_ajax_import' ); ?>
<input type="hidden" name="edd-import-class" value="EDD_Batch_Payments_Import"/>
<p>
<input name="edd-import-file" id="edd-payments-import-file" type="file"/>
<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' ); ?>"
@ -784,7 +795,7 @@ function edd_tools_import_export_display() {
<?php wp_nonce_field( 'edd_ajax_import', 'edd_ajax_import' ); ?>
<input type="hidden" name="edd-import-class" value="EDD_Batch_Downloads_Import"/>
<p>
<input name="edd-import-file" id="edd-downloads-import-file" type="file"/>
<input name="edd-import-file" id="edd-downloads-import-file" type="file" accept=".csv" required/>
</p>
<span>
<input type="submit" value="<?php _e( 'Import CSV', 'easy-digital-downloads' ); ?>"
@ -1022,7 +1033,7 @@ function edd_tools_import_export_display() {
<form method="post" enctype="multipart/form-data"
action="<?php echo esc_url( edd_get_admin_url( array( 'page' => 'edd-tools', 'tab' => 'import_export' ) ) ); ?>">
<p>
<input type="file" name="import_file"/>
<input type="file" name="import_file" accept=".json" required/>
</p>
<p>
<input type="hidden" name="edd_action" value="import_settings"/>
@ -1252,484 +1263,6 @@ function edd_handle_submit_debug_log() {
}
add_action( 'edd_submit_debug_log', 'edd_handle_submit_debug_log' );
/**
* Display the system info tab
*
* @since 2.0
*/
function edd_tools_sysinfo_display() {
if ( ! current_user_can( 'manage_shop_settings' ) ) {
return;
}
?>
<div class="postbox">
<h3><span><?php esc_html_e( 'System Information', 'easy-digital-downloads' ); ?></span></h3>
<div class="inside">
<p>
<?php esc_html_e( 'Use the system information below to help troubleshoot problems.', 'easy-digital-downloads' ); ?>
</p>
<form id="edd-system-info" action="<?php echo esc_url( admin_url( 'edit.php?post_type=download&page=edd-tools&tab=system_info' ) ); ?>" method="post" dir="ltr">
<textarea readonly="readonly" onclick="this.focus(); this.select()" id="system-info-textarea" class="edd-tools-textarea" name="edd-sysinfo"
><?php echo edd_tools_sysinfo_get(); ?></textarea>
<p>
<input type="hidden" name="edd-action" value="download_sysinfo"/>
<?php
wp_nonce_field( 'edd_download_system_info', 'edd_system_info' );
submit_button( __( 'Download System Info File', 'easy-digital-downloads' ), 'primary', 'edd-download-sysinfo', false );
submit_button( __( 'Copy to Clipboard', 'easy-digital-downloads' ), 'secondary edd-inline-button', 'edd-copy-system-info', false, array( 'onclick' => "this.form['edd-sysinfo'].focus();this.form['edd-sysinfo'].select();document.execCommand('copy');return false;" ) );
?>
</p>
</form>
</div>
</div>
<?php
}
add_action( 'edd_tools_tab_system_info', 'edd_tools_sysinfo_display' );
/**
* Get system info.
*
* @since 2.0
*
* @return string $return A string containing the info to output
*/
function edd_tools_sysinfo_get() {
global $wpdb;
if ( ! class_exists( 'Browser' ) ) {
require_once EDD_PLUGIN_DIR . 'includes/libraries/browser.php';
}
$browser = new Browser();
// Get theme info
$theme_data = wp_get_theme();
$theme = $theme_data->Name . ' ' . $theme_data->Version;
$parent_theme = $theme_data->Template;
if ( ! empty( $parent_theme ) ) {
$parent_theme_data = wp_get_theme( $parent_theme );
$parent_theme = $parent_theme_data->Name . ' ' . $parent_theme_data->Version;
}
// Try to identify the hosting provider
$host = edd_get_host();
$return = '### Begin System Info (Generated ' . date( 'Y-m-d H:i:s' ) . ') ###' . "\n\n";
// Start with the basics...
$return .= '-- Site Info' . "\n\n";
$return .= 'Site URL: ' . site_url() . "\n";
$return .= 'Home URL: ' . home_url() . "\n";
$return .= 'Multisite: ' . ( is_multisite() ? 'Yes' : 'No' ) . "\n";
$return = apply_filters( 'edd_sysinfo_after_site_info', $return );
// Can we determine the site's host?
if ( $host ) {
$return .= "\n" . '-- Hosting Provider' . "\n\n";
$return .= 'Host: ' . $host . "\n";
$return = apply_filters( 'edd_sysinfo_after_host_info', $return );
}
// The local users' browser information, handled by the Browser class
$return .= "\n" . '-- User Browser' . "\n\n";
$return .= $browser;
$return = apply_filters( 'edd_sysinfo_after_user_browser', $return );
$locale = get_locale();
// WordPress configuration
$return .= "\n" . '-- WordPress Configuration' . "\n\n";
$return .= 'Version: ' . get_bloginfo( 'version' ) . "\n";
$return .= 'Language: ' . ( ! empty( $locale ) ? $locale : 'en_US' ) . "\n";
$return .= 'Permalink Structure: ' . ( get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : 'Default' ) . "\n";
$return .= 'Active Theme: ' . $theme . "\n";
$return .= 'WP Timezone: ' . wp_timezone_string() . "\n";
$return .= 'EDD Timezone: ' . edd_get_timezone_abbr() . "\n";
if ( $parent_theme !== $theme ) {
$return .= 'Parent Theme: ' . $parent_theme . "\n";
}
$customized_template_files = edd_get_theme_edd_templates();
$return .= "\n" . '-- Customized Templates' . "\n\n";
if ( empty( $customized_template_files ) ) {
$return .= 'No custom templates found.' . "\n\n";
} else {
foreach ( $customized_template_files as $customized_template_file ) {
$return .= $customized_template_file . "\n";
}
}
$return .= "\n";
$return = apply_filters( 'edd_sysinfo_after_customized_templates', $return );
$return .= 'Show On Front: ' . get_option( 'show_on_front' ) . "\n";
// Only show page specs if frontpage is set to 'page'
if ( get_option( 'show_on_front' ) == 'page' ) {
$front_page_id = get_option( 'page_on_front' );
$blog_page_id = get_option( 'page_for_posts' );
$return .= 'Page On Front: ' . ( $front_page_id != 0 ? '#' . $front_page_id : 'Unset' ) . "\n";
$return .= 'Page For Posts: ' . ( $blog_page_id != 0 ? '#' . $blog_page_id : 'Unset' ) . "\n";
}
$return .= 'ABSPATH: ' . ABSPATH . "\n";
// Make sure wp_remote_post() is working
$request['cmd'] = '_notify-validate';
$params = array(
'sslverify' => false,
'timeout' => 60,
'user-agent' => 'EDD/' . EDD_VERSION,
'body' => $request,
);
$response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
$WP_REMOTE_POST = 'wp_remote_post() works';
} else {
$WP_REMOTE_POST = 'wp_remote_post() does not work';
}
$return .= 'Remote Post: ' . $WP_REMOTE_POST . "\n";
$return .= 'Table Prefix: ' . 'Length: ' . strlen( $wpdb->prefix ) . ' Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ) . "\n";
// Commented out per https://github.com/easydigitaldownloads/Easy-Digital-Downloads/issues/3475
//$return .= 'Admin AJAX: ' . ( edd_test_ajax_works() ? 'Accessible' : 'Inaccessible' ) . "\n";
$return .= 'WP_DEBUG: ' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ) . "\n";
$return .= 'Memory Limit: ' . WP_MEMORY_LIMIT . "\n";
$return .= 'Registered Post Stati: ' . implode( ', ', get_post_stati() ) . "\n";
$return = apply_filters( 'edd_sysinfo_after_wordpress_config', $return );
// EDD configuration
$return .= "\n" . '-- EDD Configuration' . "\n\n";
$return .= 'Version: ' . EDD_VERSION . "\n";
$return .= 'Activated On: ' . edd_date_i18n( edd_get_activation_date(), 'Y-m-d' ) . "\n";
$return .= 'Upgraded From: ' . get_option( 'edd_version_upgraded_from', 'None' ) . "\n";
$return .= 'EDD (Pro) Status: ' . ( edd_is_pro() ? "Enabled\n" : "Disabled\n" );
$return .= 'EDD (Pro) Activated On: ' . ( get_option( 'edd_pro_activation_date' ) ? edd_date_i18n( get_option( 'edd_pro_activation_date' ), 'Y-m-d' ) . "\n" : "N/A\n" );
$return .= 'EDD Pass Status: ' . ( EDD\Admin\Pass_Manager::isPro() ? "Valid Pass\n" : "Missing\n" );
$return .= 'Test Mode: ' . ( edd_is_test_mode() ? "Enabled\n" : "Disabled\n" );
$return .= 'AJAX: ' . ( ! edd_is_ajax_disabled() ? "Enabled\n" : "Disabled\n" );
$return .= 'Guest Checkout: ' . ( edd_no_guest_checkout() ? "Disabled\n" : "Enabled\n" );
$return .= 'Symlinks: ' . ( apply_filters( 'edd_symlink_file_downloads', edd_get_option( 'symlink_file_downloads', false ) ) && function_exists( 'symlink' ) ? "Enabled\n" : "Disabled\n" );
$return .= 'Download Method: ' . ucfirst( edd_get_file_download_method() ) . "\n";
$return .= 'Currency Code: ' . edd_get_currency() . "\n";
$return .= 'Currency Position: ' . edd_get_option( 'currency_position', 'before' ) . "\n";
$return .= 'Decimal Separator: ' . edd_get_option( 'decimal_separator', '.' ) . "\n";
$return .= 'Thousands Separator: ' . edd_get_option( 'thousands_separator', ',' ) . "\n";
$return .= 'Upgrades Completed: ' . implode( ',', edd_get_completed_upgrades() ) . "\n";
$return .= 'Download Link Expiration: ' . edd_get_option( 'download_link_expiration' ) . " hour(s)\n";
$return = apply_filters( 'edd_sysinfo_after_edd_config', $return );
// EDD Database tables
$return .= "\n" . '-- EDD Database Tables' . "\n\n";
foreach ( EDD()->components as $component ) {
// Object
$thing = $component->get_interface( 'table' );
if ( ! empty( $thing ) ) {
$return .= str_pad( $thing->name . ': ', 32, ' ' ) . $thing->get_version() . "\n";
}
// Meta
$thing = $component->get_interface( 'meta' );
if ( ! empty( $thing ) ) {
$return .= str_pad( $thing->name . ': ', 32, ' ' ) . $thing->get_version() . "\n";
}
}
$return = apply_filters( 'edd_sysinfo_after_edd_database_tables', $return );
// EDD Database tables
$return .= "\n" . '-- EDD Database Row Counts' . "\n\n";
foreach ( EDD()->components as $component ) {
// Object
$thing = $component->get_interface( 'table' );
if ( ! empty( $thing ) ) {
$return .= str_pad( $thing->name . ': ', 32, ' ' ) . $thing->count() . "\n";
}
// Meta
$thing = $component->get_interface( 'meta' );
if ( ! empty( $thing ) ) {
$return .= str_pad( $thing->name . ': ', 32, ' ' ) . $thing->count() . "\n";
}
}
$return = apply_filters( 'edd_sysinfo_after_edd_database_row_counts', $return );
// EDD pages
$purchase_page = edd_get_option( 'purchase_page', '' );
$success_page = edd_get_option( 'success_page', '' );
$failure_page = edd_get_option( 'failure_page', '' );
$return .= "\n" . '-- EDD Page Configuration' . "\n\n";
$return .= 'Checkout: ' . ( ! empty( $purchase_page ) ? "Valid\n" : "Invalid\n" );
$return .= 'Checkout Page: ' . ( ! empty( $purchase_page ) ? get_permalink( $purchase_page ) . "\n" : "Unset\n" );
$return .= 'Success Page: ' . ( ! empty( $success_page ) ? get_permalink( $success_page ) . "\n" : "Unset\n" );
$return .= 'Failure Page: ' . ( ! empty( $failure_page ) ? get_permalink( $failure_page ) . "\n" : "Unset\n" );
$return .= 'Downloads Slug: ' . ( defined( 'EDD_SLUG' ) ? '/' . EDD_SLUG . "\n" : "/downloads\n" );
$return = apply_filters( 'edd_sysinfo_after_edd_pages', $return );
// EDD gateways
$return .= "\n" . '-- EDD Gateway Configuration' . "\n\n";
$active_gateways = edd_get_enabled_payment_gateways();
if ( $active_gateways ) {
$default_gateway_is_active = edd_is_gateway_active( edd_get_default_gateway() );
if ( $default_gateway_is_active ) {
$default_gateway = edd_get_default_gateway();
$default_gateway = $active_gateways[ $default_gateway ]['admin_label'];
} else {
$default_gateway = 'Test Payment';
}
$gateways = array();
foreach ( $active_gateways as $gateway ) {
$gateways[] = $gateway['admin_label'];
}
$return .= 'Enabled Gateways: ' . implode( ', ', $gateways ) . "\n";
$return .= 'Default Gateway: ' . $default_gateway . "\n";
} else {
$return .= 'Enabled Gateways: None' . "\n";
}
$return = apply_filters( 'edd_sysinfo_after_edd_gateways', $return );
// EDD Taxes
$return .= "\n" . '-- EDD Tax Configuration' . "\n\n";
$return .= 'Taxes: ' . ( edd_use_taxes() ? "Enabled\n" : "Disabled\n" );
$return .= 'Default Rate: ' . edd_get_formatted_tax_rate() . "\n";
$return .= 'Display On Checkout: ' . ( edd_get_option( 'checkout_include_tax', false ) ? "Displayed\n" : "Not Displayed\n" );
$return .= 'Prices Include Tax: ' . ( edd_prices_include_tax() ? "Yes\n" : "No\n" );
$rates = edd_get_tax_rates();
if ( ! empty( $rates ) ) {
$return .= 'Country / State Rates: ' . "\n";
foreach ( $rates as $rate ) {
$return .= ' Country: ' . $rate['country'] . ', State: ' . $rate['state'] . ', Rate: ' . $rate['rate'] . "\n";
}
}
$return = apply_filters( 'edd_sysinfo_after_edd_taxes', $return );
// EDD Templates
$dir = get_stylesheet_directory() . '/edd_templates/*';
if ( is_dir( $dir ) && ( count( glob( "$dir/*" ) ) !== 0 ) ) {
$return .= "\n" . '-- EDD Template Overrides' . "\n\n";
foreach ( glob( $dir ) as $file ) {
$return .= 'Filename: ' . basename( $file ) . "\n";
}
$return = apply_filters( 'edd_sysinfo_after_edd_templates', $return );
}
// Drop Ins
$dropins = get_dropins();
if ( count( $dropins ) > 0 ) {
$return .= "\n" . '-- Drop Ins' . "\n\n";
foreach ( $dropins as $plugin => $plugin_data ) {
$return .= str_pad( $plugin_data['Name'] . ': ', 26, ' ' ) . $plugin_data['Version'] . "\n";
}
$return = apply_filters( 'edd_sysinfo_after_wordpress_dropin_plugins', $return );
}
// Get plugins that have an update
$updates = get_plugin_updates();
// Must-use plugins
// NOTE: MU plugins can't show updates!
$muplugins = get_mu_plugins();
if ( count( $muplugins ) > 0 ) {
$return .= "\n" . '-- Must-Use Plugins' . "\n\n";
foreach ( $muplugins as $plugin => $plugin_data ) {
$return .= str_pad( $plugin_data['Name'] . ': ', 26, ' ' ) . $plugin_data['Version'] . "\n";
}
$return = apply_filters( 'edd_sysinfo_after_wordpress_mu_plugins', $return );
}
// WordPress active plugins
$return .= "\n" . '-- WordPress Active Plugins' . "\n\n";
$plugins = get_plugins();
$active_plugins = get_option( 'active_plugins', array() );
foreach ( $plugins as $plugin_path => $plugin ) {
if ( ! in_array( $plugin_path, $active_plugins ) ) {
continue;
}
$update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[ $plugin_path ]->update->new_version . ')' : '';
$plugin_url = '';
if ( ! empty( $plugin['PluginURI'] ) ) {
$plugin_url = $plugin['PluginURI'];
} elseif ( ! empty( $plugin['AuthorURI'] ) ) {
$plugin_url = $plugin['AuthorURI'];
} elseif ( ! empty( $plugin['Author'] ) ) {
$plugin_url = $plugin['Author'];
}
if ( $plugin_url ) {
$plugin_url = "\n" . $plugin_url;
}
$return .= str_pad( $plugin['Name'] . ': ', 26, ' ' ) . $plugin['Version'] . $update . $plugin_url . "\n\n";
}
$return = apply_filters( 'edd_sysinfo_after_wordpress_plugins', $return );
// WordPress inactive plugins
$return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n";
foreach ( $plugins as $plugin_path => $plugin ) {
if ( in_array( $plugin_path, $active_plugins ) ) {
continue;
}
$update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[ $plugin_path ]->update->new_version . ')' : '';
$plugin_url = '';
if ( ! empty( $plugin['PluginURI'] ) ) {
$plugin_url = $plugin['PluginURI'];
} elseif ( ! empty( $plugin['AuthorURI'] ) ) {
$plugin_url = $plugin['AuthorURI'];
} elseif ( ! empty( $plugin['Author'] ) ) {
$plugin_url = $plugin['Author'];
}
if ( $plugin_url ) {
$plugin_url = "\n" . $plugin_url;
}
$return .= str_pad( $plugin['Name'] . ': ', 26, ' ' ) . $plugin['Version'] . $update . $plugin_url . "\n\n";
}
$return = apply_filters( 'edd_sysinfo_after_wordpress_plugins_inactive', $return );
if ( is_multisite() ) {
// WordPress Multisite active plugins
$return .= "\n" . '-- Network Active Plugins' . "\n\n";
$plugins = wp_get_active_network_plugins();
$active_plugins = get_site_option( 'active_sitewide_plugins', array() );
foreach ( $plugins as $plugin_path ) {
$plugin_base = plugin_basename( $plugin_path );
if ( ! array_key_exists( $plugin_base, $active_plugins ) ) {
continue;
}
$update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[ $plugin_path ]->update->new_version . ')' : '';
$plugin = get_plugin_data( $plugin_path );
$plugin_url = '';
if ( ! empty( $plugin['PluginURI'] ) ) {
$plugin_url = $plugin['PluginURI'];
} elseif ( ! empty( $plugin['AuthorURI'] ) ) {
$plugin_url = $plugin['AuthorURI'];
} elseif ( ! empty( $plugin['Author'] ) ) {
$plugin_url = $plugin['Author'];
}
if ( $plugin_url ) {
$plugin_url = "\n" . $plugin_url;
}
$return .= str_pad( $plugin['Name'] . ': ', 26, ' ' ) . $plugin['Version'] . $update . $plugin_url . "\n\n";
}
$return = apply_filters( 'edd_sysinfo_after_wordpress_ms_plugins', $return );
}
// Server configuration (really just versioning)
$return .= "\n" . '-- Webserver Configuration' . "\n\n";
$return .= 'PHP Version: ' . PHP_VERSION . "\n";
$return .= 'MySQL Version: ' . $wpdb->db_version() . "\n";
$return .= 'Webserver Info: ' . $_SERVER['SERVER_SOFTWARE'] . "\n";
$return = apply_filters( 'edd_sysinfo_after_webserver_config', $return );
// PHP configs... now we're getting to the important stuff
$return .= "\n" . '-- PHP Configuration' . "\n\n";
$return .= 'Memory Limit: ' . ini_get( 'memory_limit' ) . "\n";
$return .= 'Upload Max Size: ' . ini_get( 'upload_max_filesize' ) . "\n";
$return .= 'Post Max Size: ' . ini_get( 'post_max_size' ) . "\n";
$return .= 'Upload Max Filesize: ' . ini_get( 'upload_max_filesize' ) . "\n";
$return .= 'Time Limit: ' . ini_get( 'max_execution_time' ) . "\n";
$return .= 'Max Input Vars: ' . ini_get( 'max_input_vars' ) . "\n";
$return .= 'Display Errors: ' . ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ) . "\n";
$return .= 'PHP Arg Separator: ' . edd_get_php_arg_separator_output() . "\n";
$return = apply_filters( 'edd_sysinfo_after_php_config', $return );
// PHP extensions and such
$return .= "\n" . '-- PHP Extensions' . "\n\n";
$return .= 'cURL: ' . ( function_exists( 'curl_init' ) ? 'Supported' : 'Not Supported' ) . "\n";
$return .= 'fsockopen: ' . ( function_exists( 'fsockopen' ) ? 'Supported' : 'Not Supported' ) . "\n";
$return .= 'SOAP Client: ' . ( class_exists( 'SoapClient' ) ? 'Installed' : 'Not Installed' ) . "\n";
$return .= 'Suhosin: ' . ( extension_loaded( 'suhosin' ) ? 'Installed' : 'Not Installed' ) . "\n";
$return = apply_filters( 'edd_sysinfo_after_php_ext', $return );
// Session stuff
$return .= "\n" . '-- Session Configuration' . "\n\n";
$return .= 'EDD Use Sessions: ' . ( defined( 'EDD_USE_PHP_SESSIONS' ) && EDD_USE_PHP_SESSIONS ? 'Enforced' : ( EDD()->session->use_php_sessions() ? 'Enabled' : 'Disabled' ) ) . "\n";
$return .= 'Session: ' . ( isset( $_SESSION ) ? 'Enabled' : 'Disabled' ) . "\n";
// The rest of this is only relevant is session is enabled
if ( isset( $_SESSION ) ) {
$return .= 'Session Name: ' . esc_html( ini_get( 'session.name' ) ) . "\n";
$return .= 'Cookie Path: ' . esc_html( ini_get( 'session.cookie_path' ) ) . "\n";
$return .= 'Save Path: ' . esc_html( ini_get( 'session.save_path' ) ) . "\n";
$return .= 'Use Cookies: ' . ( ini_get( 'session.use_cookies' ) ? 'On' : 'Off' ) . "\n";
$return .= 'Use Only Cookies: ' . ( ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off' ) . "\n";
}
$return = apply_filters( 'edd_sysinfo_after_session_config', $return );
$return .= "\n" . '### End System Info ###';
return $return;
}
/**
* Generates a System Info download file
*
* @since 2.0
*/
function edd_tools_sysinfo_download() {
if ( ! current_user_can( 'manage_shop_settings' ) ) {
return;
}
check_admin_referer( 'edd_download_system_info', 'edd_system_info' );
nocache_headers();
header( 'Content-Type: text/plain' );
header( 'Content-Disposition: attachment; filename="edd-system-info.txt"' );
echo wp_strip_all_tags( $_POST['edd-sysinfo'] );
edd_die();
}
add_action( 'edd_download_sysinfo', 'edd_tools_sysinfo_download' );
/**
* Redirects requests to the old sales log to the orders page.
*

View File

@ -138,6 +138,7 @@ class EDD_Tools_Reset_Stats extends EDD_Batch_Export {
// Reset the sequential order numbers
if ( edd_get_option( 'enable_sequential' ) ) {
delete_option( 'edd_last_payment_number' );
delete_option( 'edd_next_order_number' );
}
$this->done = true;

View File

@ -85,29 +85,6 @@ function edd_logs_view_page( $logs_table, $tag = '' ) {
/** Views *********************************************************************/
/**
* Sales Log View
*
* @deprecated 3.0
*
* @since 1.4
* @uses EDD_Sales_Log_Table::prepare_items()
* @uses EDD_Sales_Log_Table::display()
* @return void
*/
function edd_logs_view_sales() {
// Setup or bail
if ( ! edd_logs_view_setup( 'sales' ) ) {
return;
}
$logs_table = new EDD_Sales_Log_Table();
edd_logs_view_page( $logs_table, 'sales' );
}
add_action( 'edd_logs_view_sales', 'edd_logs_view_sales' );
/**
* File Download Logs
*

View File

@ -0,0 +1,911 @@
<?php
/**
* Converts old sale and file download logs to new logging system
*
* @since 1.3.1
* @deprecated 3.1.2
* @uses WP_Query
* @uses EDD_Logging
* @return void
*/
function edd_v131_upgrades() {
if ( get_option( 'edd_logs_upgraded' ) ) {
return;
}
$edd_version = edd_get_db_version();
if ( version_compare( $edd_version, '1.3', '>=' ) ) {
return;
}
edd_set_time_limit();
$query = new WP_Query( array(
'post_type' => 'download',
'posts_per_page' => -1,
'post_status' => 'publish'
) );
$downloads = $query->get_posts();
if ( $downloads ) {
$edd_log = new EDD_Logging();
foreach ( $downloads as $download ) {
// Convert sale logs
$sale_logs = edd_get_download_sales_log( $download->ID, false );
if ( $sale_logs ) {
foreach ( $sale_logs['sales'] as $sale ) {
$log_data = array(
'post_parent' => $download->ID,
'post_date' => $sale['date'],
'log_type' => 'sale'
);
$log_meta = array(
'payment_id'=> $sale['payment_id']
);
$log = $edd_log->insert_log( $log_data, $log_meta );
}
}
// Convert file download logs
$file_logs = edd_get_file_download_log( $download->ID, false );
if ( $file_logs ) {
foreach ( $file_logs['downloads'] as $log ) {
$log_data = array(
'post_parent' => $download->ID,
'post_date' => $log['date'],
'log_type' => 'file_download'
);
$log_meta = array(
'user_info' => $log['user_info'],
'file_id' => $log['file_id'],
'ip' => $log['ip']
);
$log = $edd_log->insert_log( $log_data, $log_meta );
}
}
}
}
add_option( 'edd_logs_upgraded', '1' );
}
/**
* Upgrade routine for v1.3.0
*
* @since 1.3.0
* @deprecated 3.1.2
* @return void
*/
function edd_v134_upgrades() {
$general_options = get_option( 'edd_settings_general' );
// Settings already updated
if ( isset( $general_options['failure_page'] ) ) {
return;
}
// Failed Purchase Page
$failed = wp_insert_post(
array(
'post_title' => __( 'Transaction Failed', 'easy-digital-downloads' ),
'post_content' => __( 'Your transaction failed, please try again or contact site support.', 'easy-digital-downloads' ),
'post_status' => 'publish',
'post_author' => 1,
'post_type' => 'page',
'post_parent' => $general_options['purchase_page'],
'comment_status' => 'closed'
)
);
$general_options['failure_page'] = $failed;
update_option( 'edd_settings_general', $general_options );
}
/**
* Upgrade routine for v1.4
*
* @since 1.4
* @deprecated 3.1.2
* @global $edd_options Array of all the EDD Options
* @return void
*/
function edd_v14_upgrades() {
/** Add [edd_receipt] to success page **/
$success_page = get_post( edd_get_option( 'success_page' ) );
// Check for the [edd_receipt] shortcode and add it if not present
if ( strpos( $success_page->post_content, '[edd_receipt' ) === false ) {
$page_content = $success_page->post_content .= "\n[edd_receipt]";
wp_update_post( array( 'ID' => edd_get_option( 'success_page' ), 'post_content' => $page_content ) );
}
/** Convert Discounts to new Custom Post Type **/
$discounts = get_option( 'edd_discounts' );
if ( $discounts ) {
foreach ( $discounts as $discount ) {
$discount_id = wp_insert_post( array(
'post_type' => 'edd_discount',
'post_title' => isset( $discount['name'] ) ? $discount['name'] : '',
'post_status' => 'active'
) );
$meta = array(
'code' => isset( $discount['code'] ) ? $discount['code'] : '',
'uses' => isset( $discount['uses'] ) ? $discount['uses'] : '',
'max_uses' => isset( $discount['max'] ) ? $discount['max'] : '',
'amount' => isset( $discount['amount'] ) ? $discount['amount'] : '',
'start' => isset( $discount['start'] ) ? $discount['start'] : '',
'expiration' => isset( $discount['expiration'] ) ? $discount['expiration'] : '',
'type' => isset( $discount['type'] ) ? $discount['type'] : '',
'min_price' => isset( $discount['min_price'] ) ? $discount['min_price'] : ''
);
foreach ( $meta as $meta_key => $value ) {
update_post_meta( $discount_id, '_edd_discount_' . $meta_key, $value );
}
}
// Remove old discounts from database
delete_option( 'edd_discounts' );
}
}
/**
* Upgrade routine for v1.5
*
* @since 1.5
* @deprecated 3.1.2
* @return void
*/
function edd_v15_upgrades() {
// Update options for missing tax settings
$tax_options = get_option( 'edd_settings_taxes' );
// Set include tax on checkout to off
$tax_options['checkout_include_tax'] = 'no';
// Check if prices are displayed with taxes
$tax_options['prices_include_tax'] = isset( $tax_options['taxes_on_prices'] )
? 'yes'
: 'no';
update_option( 'edd_settings_taxes', $tax_options );
// Flush the rewrite rules for the new /edd-api/ end point
flush_rewrite_rules( false );
}
/**
* Upgrades for EDD v2.0
*
* @since 2.0
* @deprecated 3.1.2
* @return void
*/
function edd_v20_upgrades() {
global $edd_options, $wpdb;
edd_set_time_limit();
// Upgrade for the anti-behavior fix - #2188
if ( ! empty( $edd_options['disable_ajax_cart'] ) ) {
unset( $edd_options['enable_ajax_cart'] );
} else {
$edd_options['enable_ajax_cart'] = '1';
}
// Upgrade for the anti-behavior fix - #2188
if ( ! empty( $edd_options['disable_cart_saving'] ) ) {
unset( $edd_options['enable_cart_saving'] );
} else {
$edd_options['enable_cart_saving'] = '1';
}
// Properly set the register / login form options based on whether they were enabled previously - #2076
if ( ! empty( $edd_options['show_register_form'] ) ) {
$edd_options['show_register_form'] = 'both';
} else {
$edd_options['show_register_form'] = 'none';
}
// Remove all old, improperly expired sessions. See https://github.com/easydigitaldownloads/Easy-Digital-Downloads/issues/2031
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE '_wp_session_expires_%' AND option_value+0 < 2789308218" );
update_option( 'edd_settings', $edd_options );
}
/**
* Upgrades for EDD v2.0 and sequential payment numbers
*
* @deprecated 3.1.1.2 EDD no longer implies that past orders will be updated.
* @since 2.0
* @return void
*/
function edd_v20_upgrade_sequential_payment_numbers() {
if ( ! current_user_can( 'manage_shop_settings' ) ) {
wp_die( __( 'You do not have permission to do shop upgrades', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
}
edd_set_time_limit();
$step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1;
$total = isset( $_GET['total'] ) ? absint( $_GET['total'] ) : false;
if ( empty( $total ) || $total <= 1 ) {
$payments = edd_count_payments();
foreach ( $payments as $status ) {
$total += $status;
}
}
$orders = edd_get_orders( array(
'number' => 100,
'offset' => $step == 1 ? 0 : ( $step - 1 ) * 100,
'order' => 'asc',
) );
if ( $orders ) {
$prefix = edd_get_option( 'sequential_prefix' );
$postfix = edd_get_option( 'sequential_postfix' );
$number = ! empty( $_GET['custom'] ) ? absint( $_GET['custom'] ) : intval( edd_get_option( 'sequential_start', 1 ) );
foreach ( $orders as $order ) {
// Re-add the prefix and postfix
$payment_number = $prefix . $number . $postfix;
edd_update_order( $order->id, array(
'order_number' => $payment_number
) );
// Increment the payment number
$number++;
}
// Payments found so upgrade them
$step++;
$redirect = add_query_arg( array(
'page' => 'edd-upgrades',
'edd-upgrade' => 'upgrade_sequential_payment_numbers',
'step' => urlencode( $step ),
'custom' => urlencode( $number ),
'total' => urlencode( $total ),
), admin_url( 'index.php' ) );
edd_redirect( $redirect );
// No more payments found, finish up
} else {
delete_option( 'edd_upgrade_sequential' );
delete_option( 'edd_doing_upgrade' );
edd_redirect( admin_url() );
}
}
/**
* Upgrades for EDD v2.1 and the new customers database
*
* @since 2.1
* @deprecated 3.1.2 EDD no longer implies that past orders will be updated.
* @return void
*/
function edd_v21_upgrade_customers_db() {
global $wpdb;
if ( ! current_user_can( 'manage_shop_settings' ) ) {
wp_die( __( 'You do not have permission to do shop upgrades', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
}
edd_set_time_limit();
$number = 20;
$step = isset( $_GET['step'] )
? absint( $_GET['step'] )
: 1;
$offset = $step == 1
? 0
: ( $step - 1 ) * $number;
$emails = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT meta_value FROM {$wpdb->postmeta} WHERE meta_key = '_edd_payment_user_email' LIMIT %d,%d;", $offset, $number ) );
if ( $emails ) {
foreach ( $emails as $email ) {
if ( EDD()->customers->exists( $email ) ) {
continue; // Allow the upgrade routine to be safely re-run in the case of failure
}
$payments = new EDD_Payments_Query( array(
'user' => $email,
'order' => 'ASC',
'orderby' => 'ID',
'number' => 9999999,
'page' => $step
) );
$payments = $payments->get_payments();
if ( $payments ) {
$total_value = 0.00;
$total_count = 0;
foreach ( $payments as $payment ) {
if ( 'revoked' == $payment->status || 'complete' == $payment->status ) {
$total_value += $payment->total;
$total_count += 1;
}
}
$ids = wp_list_pluck( $payments, 'ID' );
$user = get_user_by( 'email', $email );
$args = array(
'email' => $email,
'user_id' => $user ? $user->ID : 0,
'name' => $user ? $user->display_name : '',
'purchase_count' => $total_count,
'purchase_value' => round( $total_value, 2 ),
'payment_ids' => implode( ',', array_map( 'absint', $ids ) ),
'date_created' => $payments[0]->date
);
$customer_id = EDD()->customers->add( $args );
foreach ( $ids as $id ) {
update_post_meta( $id, '_edd_payment_customer_id', $customer_id );
}
}
}
// Customers found so upgrade them
$step++;
$redirect = add_query_arg( array(
'page' => 'edd-upgrades',
'edd-upgrade' => 'upgrade_customers_db',
'step' => urlencode( $step ),
), admin_url( 'index.php' ) );
edd_redirect( $redirect );
// No more customers found, finish up
} else {
delete_option( 'edd_doing_upgrade' );
edd_redirect( admin_url() );
}
}
/**
* Fixes the edd_log meta for 2.2.6
*
* @since 2.2.6
* @deprecated 3.1.2 EDD no longer implies that past orders will be updated.
* @return void
*/
function edd_v226_upgrade_payments_price_logs_db() {
global $wpdb;
if ( ! current_user_can( 'manage_shop_settings' ) ) {
wp_die( __( 'You do not have permission to do shop upgrades', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
}
edd_set_time_limit();
$number = 25;
$step = isset( $_GET['step'] )
? absint( $_GET['step'] )
: 1;
$offset = $step == 1
? 0
: ( $step - 1 ) * $number;
if ( 1 === $step ) {
// Check if we have any variable price products on the first step
$sql = "SELECT ID FROM {$wpdb->posts} p LEFT JOIN {$wpdb->postmeta} m ON p.ID = m.post_id WHERE m.meta_key = '_variable_pricing' AND m.meta_value = 1 LIMIT 1";
$has_variable = $wpdb->get_col( $sql );
if ( empty( $has_variable ) ) {
// We had no variable priced products, so go ahead and just complete
delete_option( 'edd_doing_upgrade' );
edd_redirect( admin_url() );
}
}
$payment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'edd_payment' ORDER BY post_date DESC LIMIT %d,%d;", $offset, $number ) );
if ( ! empty( $payment_ids ) ) {
foreach ( $payment_ids as $payment_id ) {
$payment_downloads = edd_get_payment_meta_downloads( $payment_id );
$variable_downloads = array();
// May not be an array due to some very old payments, move along
if ( ! is_array( $payment_downloads ) ) {
continue;
}
foreach ( $payment_downloads as $download ) {
// Don't care if the download is a single price id
if ( ! isset( $download['options']['price_id'] ) ) {
continue;
}
$variable_downloads[] = array( 'id' => $download['id'], 'price_id' => $download['options']['price_id'] );
}
$variable_download_ids = array_unique( wp_list_pluck( $variable_downloads, 'id' ) );
$unique_download_ids = implode( ',', $variable_download_ids );
// If there were no downloads, just fees, move along
if ( empty( $unique_download_ids ) ) {
continue;
}
// Get all Log Ids where the post parent is in the set of download IDs we found in the cart meta
$logs = $wpdb->get_results( "SELECT m.post_id AS log_id, p.post_parent AS download_id FROM {$wpdb->postmeta} m LEFT JOIN {$wpdb->posts} p ON m.post_id = p.ID WHERE meta_key = '_edd_log_payment_id' AND meta_value = $payment_id AND p.post_parent IN ($unique_download_ids)", ARRAY_A );
$mapped_logs = array();
// Go through each cart item
foreach ( $variable_downloads as $cart_item ) {
// Itterate through the logs we found attached to this payment
foreach ( $logs as $key => $log ) {
// If this Log ID is associated with this download ID give it the price_id
if ( (int) $log['download_id'] === (int) $cart_item['id'] ) {
$mapped_logs[$log['log_id']] = $cart_item['price_id'];
// Remove this Download/Log ID from the list, for multipurchase compatibility
unset( $logs[$key] );
// These aren't the logs we're looking for. Move Along, Move Along.
break;
}
}
}
if ( ! empty( $mapped_logs ) ) {
$update = "UPDATE {$wpdb->postmeta} SET meta_value = ";
$case = "CASE post_id ";
foreach ( $mapped_logs as $post_id => $value ) {
$case .= "WHEN {$post_id} THEN {$value} ";
}
$case .= "END ";
$log_ids = implode( ',', array_keys( $mapped_logs ) );
$where = "WHERE post_id IN ({$log_ids}) AND meta_key = '_edd_log_price_id'";
$sql = $update . $case . $where;
// Execute our query to update this payment
$wpdb->query( $sql );
}
}
// More Payments found so upgrade them
$step++;
$redirect = add_query_arg( array(
'page' => 'edd-upgrades',
'edd-upgrade' => 'upgrade_payments_price_logs_db',
'step' => urlencode( $step ),
), admin_url( 'index.php' ) );
edd_redirect( $redirect );
} else {
delete_option( 'edd_doing_upgrade' );
edd_redirect( admin_url() );
}
}
/**
* Upgrades payment taxes for 2.3
*
* @since 2.3
* @deprecated 3.1.2 EDD no longer implies that past orders will be updated.
* @return void
*/
function edd_v23_upgrade_payment_taxes() {
global $wpdb;
if ( ! current_user_can( 'manage_shop_settings' ) ) {
wp_die( __( 'You do not have permission to do shop upgrades', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
}
edd_set_time_limit();
$number = 50;
$step = isset( $_GET['step'] )
? absint( $_GET['step'] )
: 1;
$offset = $step == 1
? 0
: ( $step - 1 ) * $number;
if ( $step < 2 ) {
// Check if we have any payments before moving on
$sql = "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'edd_payment' LIMIT 1";
$has_payments = $wpdb->get_col( $sql );
if ( empty( $has_payments ) ) {
// We had no payments, just complete
edd_set_upgrade_complete( 'upgrade_payment_taxes' );
delete_option( 'edd_doing_upgrade' );
edd_redirect( admin_url() );
}
}
$total = isset( $_GET['total'] ) ? absint( $_GET['total'] ) : false;
if ( empty( $total ) || $total <= 1 ) {
$total_sql = "SELECT COUNT(ID) as total_payments FROM {$wpdb->posts} WHERE post_type = 'edd_payment'";
$results = $wpdb->get_row( $total_sql, 0 );
$total = $results->total_payments;
}
$payment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'edd_payment' ORDER BY post_date DESC LIMIT %d,%d;", $offset, $number ) );
if ( $payment_ids ) {
// Add the new _edd_payment_meta item
foreach ( $payment_ids as $payment_id ) {
$payment_tax = edd_get_payment_tax( $payment_id );
edd_update_payment_meta( $payment_id, '_edd_payment_tax', $payment_tax );
}
// Payments found so upgrade them
$step++;
$redirect = add_query_arg( array(
'page' => 'edd-upgrades',
'edd-upgrade' => 'upgrade_payment_taxes',
'step' => urlencode( $step ),
'number' => urlencode( $number ),
'total' => urlencode( $total ),
), admin_url( 'index.php' ) );
edd_redirect( $redirect );
// No more payments found, finish up
} else {
edd_set_upgrade_complete( 'upgrade_payment_taxes' );
delete_option( 'edd_doing_upgrade' );
edd_redirect( admin_url() );
}
}
/**
* Run the upgrade for the customers to find all payment attachments
*
* @since 2.3
* @deprecated 3.1.2 EDD no longer implies that past orders will be updated.
* @return void
*/
function edd_v23_upgrade_customer_purchases() {
global $wpdb;
if ( ! current_user_can( 'manage_shop_settings' ) ) {
wp_die( __( 'You do not have permission to do shop upgrades', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
}
edd_set_time_limit();
$number = 50;
$step = isset( $_GET['step'] )
? absint( $_GET['step'] )
: 1;
$offset = $step == 1
? 0
: ( $step - 1 ) * $number;
if ( $step < 2 ) {
// Check if we have any payments before moving on
$sql = "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'edd_payment' LIMIT 1";
$has_payments = $wpdb->get_col( $sql );
if ( empty( $has_payments ) ) {
// We had no payments, just complete
edd_set_upgrade_complete( 'upgrade_customer_payments_association' );
delete_option( 'edd_doing_upgrade' );
edd_redirect( admin_url() );
}
}
$total = isset( $_GET['total'] ) ? absint( $_GET['total'] ) : false;
if ( empty( $total ) || $total <= 1 ) {
$total = EDD()->customers->count();
}
$customers = edd_get_customers( array( 'number' => $number, 'offset' => $offset ) );
if ( ! empty( $customers ) ) {
foreach ( $customers as $customer ) {
// Get payments by email and user ID
$select = "SELECT ID FROM {$wpdb->posts} p ";
$join = "LEFT JOIN {$wpdb->postmeta} m ON p.ID = m.post_id ";
$where = "WHERE p.post_type = 'edd_payment' ";
if ( ! empty( $customer->user_id ) && intval( $customer->user_id ) > 0 ) {
$where .= "AND ( ( m.meta_key = '_edd_payment_user_email' AND m.meta_value = '{$customer->email}' ) OR ( m.meta_key = '_edd_payment_customer_id' AND m.meta_value = '{$customer->id}' ) OR ( m.meta_key = '_edd_payment_user_id' AND m.meta_value = '{$customer->user_id}' ) )";
} else {
$where .= "AND ( ( m.meta_key = '_edd_payment_user_email' AND m.meta_value = '{$customer->email}' ) OR ( m.meta_key = '_edd_payment_customer_id' AND m.meta_value = '{$customer->id}' ) ) ";
}
$sql = $select . $join . $where;
$found_payments = $wpdb->get_col( $sql );
$unique_payment_ids = array_unique( array_filter( $found_payments ) );
if ( ! empty( $unique_payment_ids ) ) {
$unique_ids_string = implode( ',', $unique_payment_ids );
$customer_data = array( 'payment_ids' => $unique_ids_string );
$purchase_value_sql = "SELECT SUM( m.meta_value ) FROM {$wpdb->postmeta} m LEFT JOIN {$wpdb->posts} p ON m.post_id = p.ID WHERE m.post_id IN ( {$unique_ids_string} ) AND p.post_status IN ( 'publish', 'revoked' ) AND m.meta_key = '_edd_payment_total'";
$purchase_value = $wpdb->get_col( $purchase_value_sql );
$purchase_count_sql = "SELECT COUNT( m.post_id ) FROM {$wpdb->postmeta} m LEFT JOIN {$wpdb->posts} p ON m.post_id = p.ID WHERE m.post_id IN ( {$unique_ids_string} ) AND p.post_status IN ( 'publish', 'revoked' ) AND m.meta_key = '_edd_payment_total'";
$purchase_count = $wpdb->get_col( $purchase_count_sql );
if ( ! empty( $purchase_value ) && ! empty( $purchase_count ) ) {
$purchase_value = $purchase_value[0];
$purchase_count = $purchase_count[0];
$customer_data['purchase_count'] = $purchase_count;
$customer_data['purchase_value'] = $purchase_value;
}
} else {
$customer_data['purchase_count'] = 0;
$customer_data['purchase_value'] = 0;
$customer_data['payment_ids'] = '';
}
if ( ! empty( $customer_data ) ) {
$customer = new EDD_Customer( $customer->id );
$customer->update( $customer_data );
}
}
// More Payments found so upgrade them
$step++;
$redirect = add_query_arg( array(
'page' => 'edd-upgrades',
'edd-upgrade' => 'upgrade_customer_payments_association',
'step' => urlencode( $step ),
'number' => urlencode( $number ),
'total' => urlencode( $total ),
), admin_url( 'index.php' ) );
edd_redirect( $redirect );
// No more customers found, finish up
} else {
edd_set_upgrade_complete( 'upgrade_customer_payments_association' );
delete_option( 'edd_doing_upgrade' );
edd_redirect( admin_url() );
}
}
/**
* Upgrade the User meta API Key storage to swap keys/values for performance
*
* @since 2.4
* @deprecated 3.1.2
* @return void
*/
function edd_upgrade_user_api_keys() {
global $wpdb;
if ( ! current_user_can( 'manage_shop_settings' ) ) {
wp_die( __( 'You do not have permission to do shop upgrades', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
}
edd_set_time_limit();
$number = 10;
$step = isset( $_GET['step'] )
? absint( $_GET['step'] )
: 1;
$offset = $step == 1
? 0
: ( $step - 1 ) * $number;
if ( $step < 2 ) {
// Check if we have any users with API Keys before moving on
$sql = "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = 'edd_user_public_key' LIMIT 1";
$has_key = $wpdb->get_col( $sql );
// We had no key, just complete
if ( empty( $has_key ) ) {
edd_set_upgrade_complete( 'upgrade_user_api_keys' );
delete_option( 'edd_doing_upgrade' );
edd_redirect( admin_url() );
}
}
$total = isset( $_GET['total'] )
? absint( $_GET['total'] )
: false;
if ( empty( $total ) || $total <= 1 ) {
$total = $wpdb->get_var( "SELECT count(user_id) FROM $wpdb->usermeta WHERE meta_key = 'edd_user_public_key'" );
}
$keys_sql = $wpdb->prepare( "SELECT user_id, meta_key, meta_value FROM $wpdb->usermeta WHERE meta_key = 'edd_user_public_key' OR meta_key = 'edd_user_secret_key' ORDER BY user_id ASC LIMIT %d,%d;", $offset, $number );
$found_keys = $wpdb->get_results( $keys_sql );
if ( ! empty( $found_keys ) ) {
foreach ( $found_keys as $key ) {
$user_id = $key->user_id;
$meta_key = $key->meta_key;
$meta_value = $key->meta_value;
// Generate a new entry
update_user_meta( $user_id, $meta_value, $meta_key );
// Delete the old one
delete_user_meta( $user_id, $meta_key );
}
// More Payments found so upgrade them
$step++;
$redirect = add_query_arg( array(
'page' => 'edd-upgrades',
'edd-upgrade' => 'upgrade_user_api_keys',
'step' => urlencode( $step ),
'number' => urlencode( $number ),
'total' => urlencode( $total ) ) );
edd_redirect( $redirect );
// No more customers found, finish up
} else {
edd_set_upgrade_complete( 'upgrade_user_api_keys' );
delete_option( 'edd_doing_upgrade' );
edd_redirect( admin_url() );
}
}
/** 2.9.2 Upgrades ***********************************************************/
/**
* Output the results of the file-download log data update
*
* @since 2.9.2
* @deprecated 3.1.2
*/
function edd_upgrade_render_update_file_download_log_data() {
$migration_complete = edd_has_upgrade_completed( 'update_file_download_log_data' );
if ( $migration_complete ) : ?>
<div id="edd-sl-migration-complete" class="notice notice-success">
<p>
<?php _e( '<strong>Migration complete:</strong> You have already completed the update to the file download logs.', 'easy-digital-downloads' ); ?>
</p>
</div>
<?php
delete_option( 'edd_doing_upgrade' );
return;
endif; ?>
<div id="edd-migration-ready" class="notice notice-success" style="display: none;">
<p><?php _e( '<strong>Upgrades Complete:</strong> You may now safely navigate away from this page.', 'easy-digital-downloads' ); ?></p>
</div>
<div id="edd-migration-nav-warn" class="notice notice-warning">
<p><?php _e( '<strong>Important:</strong> Do not navigate away from this page until all upgrades complete.', 'easy-digital-downloads' ); ?></p>
</div>
<style>
.dashicons.dashicons-yes {
display: none;
color: rgb(0, 128, 0);
vertical-align: middle;
}
</style>
<script>
jQuery( function($) {
$(document).ready(function () {
$(document).on("DOMNodeInserted", function (e) {
var element = e.target;
if (element.id === 'edd-batch-success') {
element = $(element);
element.parent().prev().find('.edd-migration.allowed').hide();
element.parent().prev().find('.edd-migration.unavailable').show();
var element_wrapper = element.parents().eq(4),
next_step_wrapper = element_wrapper.next();
element_wrapper.find('.dashicons.dashicons-yes').show();
if (next_step_wrapper.find('.postbox').length) {
next_step_wrapper.find('.edd-migration.allowed').show();
next_step_wrapper.find('.edd-migration.unavailable').hide();
if (auto_start_next_step) {
next_step_wrapper.find('.edd-export-form').submit();
}
} else {
$('#edd-migration-nav-warn').hide();
$('#edd-migration-ready').slideDown();
}
}
});
});
});
</script>
<div class="metabox-holder">
<div class="postbox">
<h2 class="hndle">
<span><?php _e( 'Update file download logs', 'easy-digital-downloads' ); ?></span>
<span class="dashicons dashicons-yes"></span>
</h2>
<div class="inside migrate-file-download-logs-control">
<p>
<?php _e( 'This will update the file download logs to remove some <abbr title="Personally Identifiable Information">PII</abbr> and make file download counts more accurate.', 'easy-digital-downloads' ); ?>
</p>
<form method="post" id="edd-fix-file-download-logs-form" class="edd-export-form edd-import-export-form">
<span class="step-instructions-wrapper">
<?php wp_nonce_field( 'edd_ajax_export', 'edd_ajax_export' ); ?>
<?php if ( ! $migration_complete ) : ?>
<span class="edd-migration allowed">
<input type="submit" id="migrate-logs-submit" value="<?php _e( 'Update File Download Logs', 'easy-digital-downloads' ); ?>" class="button-primary"/>
</span>
<?php else: ?>
<input type="submit" disabled id="migrate-logs-submit" value="<?php _e( 'Update File Download Logs', 'easy-digital-downloads' ); ?>" class="button-secondary"/>
&mdash; <?php _e( 'File download logs have already been updated.', 'easy-digital-downloads' ); ?>
<?php endif; ?>
<input type="hidden" name="edd-export-class" value="EDD_File_Download_Log_Migration" />
<span class="spinner"></span>
</span>
</form>
</div><!-- .inside -->
</div><!-- .postbox -->
</div>
<?php
}
/**
* Register the batch file-download log migration
*
* @since 2.9.2
* @deprecated 3.1.2
*/
function edd_register_batch_file_download_log_migration() {
add_action( 'edd_batch_export_class_include', 'edd_include_file_download_log_migration_batch_processor', 10, 1 );
}
/**
* Include the file-download log batch processor
*
* @since 2.9.2
* @deprecated 3.1.2
*
* @param string $class
*/
function edd_include_file_download_log_migration_batch_processor( $class = '' ) {
if ( 'EDD_File_Download_Log_Migration' === $class ) {
require_once EDD_PLUGIN_DIR . 'includes/admin/upgrades/classes/class-file-download-log-migration.php';
}
}

View File

@ -76,12 +76,17 @@ function edd_upgrades_screen() {
if ( ! empty( $action ) ) :
// Redirect URL
$redirect = add_query_arg( array(
'edd_action' => sanitize_key( $action ),
'step' => absint( $step ),
'total' => absint( $total ),
'custom' => absint( $custom ),
), admin_url( 'index.php' ) ); ?>
$redirect = add_query_arg(
array(
'edd_action' => sanitize_key( $action ),
'step' => absint( $step ),
'total' => absint( $total ),
'custom' => absint( $custom ),
'_wpnonce' => wp_create_nonce( 'edd-upgrade' ),
),
admin_url( 'index.php' )
);
?>
<div id="edd-upgrade-status">
<p><?php _e( 'The upgrade process has started, please be patient. This could take several minutes. You will be automatically redirected when the upgrade is finished.', 'easy-digital-downloads' ); ?></p>
@ -113,7 +118,8 @@ function edd_upgrades_screen() {
// Trigger upgrades on page load
var data = {
action: 'edd_trigger_upgrades'
action: 'edd_trigger_upgrades',
nonce: '<?php echo esc_attr( wp_create_nonce( 'edd-upgrade' ) ); ?>'
};
jQuery.post( ajaxurl, data, function (response) {

View File

@ -753,14 +753,11 @@ class Data_Migrator {
*/
$order_data = apply_filters( 'edd_30_migration_order_creation_data', $order_data, $payment_meta, $cart_details, $meta );
update_option( '_edd_v30_doing_order_migration', true, false );
// Remove all order status transition actions.
remove_all_actions( 'edd_transition_order_status' );
remove_all_actions( 'edd_transition_order_item_status' );
remove_action( 'edd_order_item_added', 'edd_recalculate_order_item_download' );
remove_action( 'edd_order_item_updated', 'edd_recalculate_order_item_download' );
remove_action( 'edd_order_item_deleted', 'edd_recalculate_order_item_download' );
remove_action( 'edd_order_adjustment_added', 'edd_recalculate_order_adjustment_download' );
remove_action( 'edd_order_adjustment_updated', 'edd_recalculate_order_adjustment_download' );
$order_id = edd_add_order( $order_data );
@ -1351,6 +1348,8 @@ class Data_Migrator {
*/
do_action( 'edd_30_migrate_order', $order_id, $payment_meta, $meta );
delete_option( '_edd_v30_doing_order_migration' );
return $order_id;
}

View File

@ -92,6 +92,26 @@ class Orders extends Base {
}
}
/**
* Recalculates all customer values.
*
* @since 3.1.2
* @return void
*/
private function recalculate_customer_values() {
$customers = edd_get_customers(
array(
'number' => 9999999,
)
);
if ( ! empty( $customers ) ) {
foreach ( $customers as $customer ) {
$customer->recalculate_stats();
}
}
}
/**
* Calculate the percentage completed.
*

View File

@ -29,9 +29,6 @@ $view_url = edd_get_admin_url(
<# } #>
<div>
<# if ( false !== data.orderItem ) { #>
{{ data.orderItem.productName }}:&nbsp;
<# } #>
<# if ( '' !== data.description ) { #>
{{ data.description }}
<# } #>
@ -40,7 +37,9 @@ $view_url = edd_get_admin_url(
<br />
<small>
<# } #>
<# if ( 'credit' === data.type ) { #>
<# if ( false !== data.orderItem ) { #>
<?php esc_html_e( 'Fee', 'easy-digital-downloads' ); ?>: {{ data.orderItem.productName }}
<# } else if ( 'credit' === data.type ) { #>
<?php esc_html_e( 'Order Credit', 'easy-digital-downloads' ); ?>
<# } else { #>
<?php esc_html_e( 'Order Fee', 'easy-digital-downloads' ); ?>