__( 'General', 'easy-digital-downloads' ), 'api_keys' => __( 'API Keys', 'easy-digital-downloads' ), 'betas' => __( 'Beta Versions', 'easy-digital-downloads' ), 'logs' => __( 'Logs', 'easy-digital-downloads' ), 'system_info' => __( 'System Info', 'easy-digital-downloads' ), 'debug_log' => __( 'Debug Log', 'easy-digital-downloads' ), 'import_export' => __( 'Import/Export', 'easy-digital-downloads' ) ); // Unset the betas tab if not allowed if ( count( edd_get_beta_enabled_extensions() ) <= 0 ) { unset( $tabs['betas'] ); } } // Filter & return return apply_filters( 'edd_tools_tabs', $tabs ); } /** * Display the recount stats. * * @since 2.5 */ function edd_tools_recount_stats_display() { // Bail if the user does not have the required capabilities. if ( ! current_user_can( 'manage_shop_settings' ) ) { return; } do_action( 'edd_tools_recount_stats_before' ); ?>


Deletes all payment records, customers, and related log entries.', 'easy-digital-downloads' ); ?>

prepare_items(); $api_keys_table->display(); $docs_link = edd_link_helper( 'https://easydigitaldownloads.com/categories/docs/api-reference/', array( 'utm_medium' => 'tools', 'utm_content' => 'api-documentation', ) ); $ios_link = edd_link_helper( 'https://easydigitaldownloads.com/downloads/ios-sales-earnings-tracker/', array( 'utm_medium' => 'tools', 'utm_content' => 'ios-app', ) ); ?>

EDD REST API to retrieve store data in JSON or XML for external applications or devices, such as the EDD mobile app.', 'easy-digital-downloads' ), $docs_link, $ios_link ); ?>

$product ) : ?>
value="1"/>
'Extension Name' * * @since 2.6.11 * * @return array $extensions The array of extensions */ function edd_get_beta_enabled_extensions() { return (array) apply_filters( 'edd_beta_enabled_extensions', array() ); } /** * Check if a given extensions has beta support enabled * * @since 2.6.11 * * @param string $slug The slug of the extension to check * * @return bool True if enabled, false otherwise */ function edd_extension_has_beta_support( $slug ) { $enabled_betas = edd_get_option( 'enabled_betas', array() ); $return = false; if ( array_key_exists( $slug, $enabled_betas ) ) { $return = true; } return $return; } /** * Save enabled betas. * * @since 2.6.11 */ function edd_tools_enabled_betas_save() { if ( ! wp_verify_nonce( $_POST['edd_save_betas_nonce'], 'edd_save_betas_nonce' ) ) { return; } if ( ! current_user_can( 'manage_shop_settings' ) ) { return; } if ( ! empty( $_POST['enabled_betas'] ) ) { $enabled_betas = array_filter( array_map( 'edd_tools_enabled_betas_sanitize_value', $_POST['enabled_betas'] ) ); edd_update_option( 'enabled_betas', $enabled_betas ); } else { edd_delete_option( 'enabled_betas' ); } } add_action( 'edd_save_enabled_betas', 'edd_tools_enabled_betas_save' ); /** * Sanitize the supported beta values by making them booleans * * @since 2.6.11 * * @param mixed $value The value being sent in, determining if beta support is enabled. * * @return bool */ function edd_tools_enabled_betas_sanitize_value( $value ) { return filter_var( $value, FILTER_VALIDATE_BOOLEAN ); } /** * Save banned emails. * * @since 2.0 */ function edd_tools_banned_emails_save() { if ( ! wp_verify_nonce( $_POST['edd_banned_emails_nonce'], 'edd_banned_emails_nonce' ) ) { return; } if ( ! current_user_can( 'manage_shop_settings' ) ) { return; } if ( ! empty( $_POST['banned_emails'] ) ) { // Sanitize the input $emails = array_map( 'trim', explode( "\n", $_POST['banned_emails'] ) ); $emails = array_unique( $emails ); $emails = array_map( 'sanitize_text_field', $emails ); foreach ( $emails as $id => $email ) { if ( ! is_email( $email ) && $email[0] != '@' && $email[0] != '.' ) { unset( $emails[ $id ] ); } } } else { $emails = ''; } edd_update_option( 'banned_emails', $emails ); } add_action( 'edd_save_banned_emails', 'edd_tools_banned_emails_save' ); /** * Execute upgrade notice clear. * * @since 2.3.5 */ function edd_tools_clear_upgrade_notice() { if ( ! wp_verify_nonce( $_POST['edd_clear_upgrades_nonce'], 'edd_clear_upgrades_nonce' ) ) { return; } if ( ! current_user_can( 'manage_shop_settings' ) ) { return; } delete_option( 'edd_doing_upgrade' ); } add_action( 'edd_clear_doing_upgrade', 'edd_tools_clear_upgrade_notice' ); /** * Display the tools import/export tab. * * @since 2.0 */ function edd_tools_import_export_display() { if ( ! current_user_can( 'manage_shop_settings' ) ) { return; } do_action( 'edd_tools_import_export_before' ); ?>

Reports page.', 'easy-digital-downloads' ), esc_url( edd_get_admin_url( array( 'page' => 'edd-reports', 'view' => 'export', ) ) ) ); ?>

$edd_settings, 'edd_tax_rates' => $edd_tax_rates ) ); } add_action( 'edd_export_settings', 'edd_tools_import_export_process_export' ); /** * Process a settings import from a json file * * @since 1.7 * @return void */ function edd_tools_import_export_process_import() { if ( empty( $_POST['edd_import_nonce'] ) ) { return; } if ( ! wp_verify_nonce( $_POST['edd_import_nonce'], 'edd_import_nonce' ) ) { return; } if ( ! current_user_can( 'manage_shop_settings' ) ) { return; } if ( edd_get_file_extension( $_FILES['import_file']['name'] ) != 'json' ) { wp_die( __( 'Please upload a valid .json file', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 400 ) ); } $import_file = $_FILES['import_file']['tmp_name']; if ( empty( $import_file ) ) { wp_die( __( 'Please upload a file to import', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 400 ) ); } // Retrieve the settings from the file and convert the json object to an array $settings = edd_object_to_array( json_decode( file_get_contents( $import_file ) ) ); if ( ! isset( $settings['edd_settings'] ) ) { // Process a settings export from a pre 2.8 version of EDD update_option( 'edd_settings', $settings ); } else { // Update the settings from a 2.8+ export file $edd_settings = $settings['edd_settings']; update_option( 'edd_settings', $edd_settings ); $edd_tax_rates = $settings['edd_tax_rates']; if ( ! empty( $edd_tax_rates ) ) { foreach( $edd_tax_rates as $rate ) { $scope = 'country'; if ( ! empty( $rate['scope'] ) ) { $scope = $rate['scope']; } elseif ( empty( $rate['global'] ) && ! empty( $rate['state'] ) ) { $scope = 'region'; } elseif ( empty( $rate['country'] && empty( $rate['state'] ) ) ) { $scope = 'global'; } edd_add_tax_rate( array( 'name' => esc_attr( $rate['country'] ), 'status' => ! empty( $rate['status'] ) ? esc_attr( $rate['status'] ) : 'active', 'description' => esc_attr( $rate['state'] ), 'amount' => floatval( $rate['rate'] ), 'scope' => esc_attr( $scope ), ) ); } } } edd_redirect( edd_get_admin_url( array( 'page' => 'edd-tools', 'edd-message' => 'settings-imported', 'tab' => 'import_export', ) ) ); } add_action( 'edd_import_settings', 'edd_tools_import_export_process_import' ); /** * Display the debug log tab * * @since 2.8.7 */ function edd_tools_debug_log_display() { $edd_logs = EDD()->debug_log; // Setup fallback incase no file exists $path = $edd_logs->get_log_file_path(); $log = $edd_logs->get_file_contents(); $path_output = ! empty( $path ) ? wp_normalize_path( $path ) : esc_html__( 'No File', 'easy-digital-downloads' ); $log_output = ! empty( $log ) ? wp_normalize_path( $log ) : esc_html__( 'Log is Empty', 'easy-digital-downloads' ); ?>

Learn how to use EDD_Logging in your own code.)', 'easy-digital-downloads' ); ?>

"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 ) ) { submit_button( __( 'Clear Log', 'easy-digital-downloads' ), 'secondary edd-inline-button', 'edd-clear-debug-log', false ); } ?>

:

debug_log; if ( ! current_user_can( 'manage_shop_settings' ) ) { return; } check_admin_referer( 'edd-debug-log-action' ); if ( isset( $_REQUEST['edd-download-debug-log'] ) ) { nocache_headers(); header( 'Content-Type: text/plain' ); header( 'Content-Disposition: attachment; filename="edd-debug-log.txt"' ); echo wp_strip_all_tags( $_REQUEST['edd-debug-log-contents'] ); exit; } elseif ( isset( $_REQUEST['edd-clear-debug-log'] ) ) { // Clear the debug log. $edd_logs->clear_log_file(); edd_redirect( edd_get_admin_url( array( 'page' => 'edd-tools', 'tab' => 'debug_log' ) ) ); } } add_action( 'edd_submit_debug_log', 'edd_handle_submit_debug_log' ); /** * Redirects requests to the old sales log to the orders page. * * @since 3.0 */ function edd_redirect_sales_log() { if ( edd_is_admin_page( 'tools', 'logs' ) && ! empty( $_GET['view'] ) && 'sales' === $_GET['view'] ) { $query_args = array( 'page' => 'edd-payment-history' ); $args_to_remap = array( 'download' => 'product-id', 'start-date' => 'start-date', 'end-date' => 'end-date' ); foreach( $args_to_remap as $old_arg => $new_arg ) { if ( ! empty( $_GET[ $old_arg ] ) ) { $query_args[ $new_arg ] = urlencode( $_GET[ $old_arg ] ); } } wp_safe_redirect( esc_url_raw( add_query_arg( $query_args, edd_get_admin_base_url() ) ) ); exit; } } add_action( 'admin_init', 'edd_redirect_sales_log' ); /** * Renders the Logs tab in the Tools screen. * * @since 3.0 */ function edd_tools_tab_logs() { if ( ! current_user_can( 'view_shop_reports' ) ) { return; } require_once EDD_PLUGIN_DIR . 'includes/admin/tools/logs.php'; $current_view = 'file_downloads'; $log_views = edd_log_default_views(); if ( isset( $_GET['view'] ) && array_key_exists( $_GET['view'], $log_views ) ) { $current_view = sanitize_text_field( $_GET['view'] ); } /** * Fires when a given logs view should be rendered. * * The dynamic portion of the hook name, `$current_view`, represents the slug * of the logs view to render. * * @since 1.4 */ do_action( 'edd_logs_view_' . $current_view ); } add_action( 'edd_tools_tab_logs', 'edd_tools_tab_logs' );