installed plugin Easy Digital Downloads
version 3.1.0.3
This commit is contained in:
@ -0,0 +1,136 @@
|
||||
<?php
|
||||
/**
|
||||
* Recount download earnings and stats AND store earnings
|
||||
*
|
||||
* This class handles batch processing of recounting earnings and stats for all downloads and store totals
|
||||
*
|
||||
* @subpackage Admin/Tools/EDD_Tools_Recount_All_Stats
|
||||
* @copyright Copyright (c) 2021, Sandhills Development, LLC
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
||||
* @since 2.5
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* EDD_Tools_Recount_All_Stats Class
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
class EDD_Tools_Recount_All_Stats extends EDD_Batch_Export {
|
||||
|
||||
/**
|
||||
* @var int[]
|
||||
*/
|
||||
private $download_ids;
|
||||
|
||||
/**
|
||||
* Our export type. Used for export-type specific filters/actions
|
||||
* @var string
|
||||
* @since 2.5
|
||||
*/
|
||||
public $export_type = '';
|
||||
|
||||
/**
|
||||
* Allows for a non-download batch processing to be run.
|
||||
* @since 2.5
|
||||
* @var boolean
|
||||
*/
|
||||
public $is_void = true;
|
||||
|
||||
/**
|
||||
* Sets the number of items to pull on each step
|
||||
* @since 2.5
|
||||
* @var integer
|
||||
*/
|
||||
public $per_step = 30;
|
||||
|
||||
/**
|
||||
* Return the calculated completion percentage
|
||||
*
|
||||
* @since 2.5
|
||||
* @return int
|
||||
*/
|
||||
public function get_percentage_complete() {
|
||||
$percentage = 100;
|
||||
$total = array_sum( (array) wp_count_posts( 'download' ) );
|
||||
|
||||
if ( $total > 0 ) {
|
||||
$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
|
||||
}
|
||||
|
||||
if ( $percentage > 100 ) {
|
||||
$percentage = 100;
|
||||
}
|
||||
|
||||
return $percentage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a step
|
||||
*
|
||||
* @since 2.5
|
||||
* @return bool
|
||||
*/
|
||||
public function process_step() {
|
||||
if ( ! $this->can_export() ) {
|
||||
wp_die( __( 'You do not have permission to perform this action.', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
|
||||
}
|
||||
|
||||
$download_ids = $this->get_download_ids();
|
||||
|
||||
if ( ! empty( $download_ids ) && is_array( $download_ids ) ) {
|
||||
foreach ( $this->get_download_ids() as $download_id ) {
|
||||
edd_recalculate_download_sales_earnings( $download_id );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $download_ids ) ) {
|
||||
$this->done = false;
|
||||
return true;
|
||||
} else {
|
||||
$this->delete_data( 'edd_recount_all_total' );
|
||||
$this->delete_data( 'edd_temp_recount_all_stats' );
|
||||
$this->delete_data( 'edd_temp_payment_items' );
|
||||
$this->delete_data( 'edd_temp_download_ids' );
|
||||
$this->delete_data( 'edd_temp_processed_payments' );
|
||||
$this->done = true;
|
||||
$this->message = __( 'Earnings and sales stats successfully recounted.', 'easy-digital-downloads' );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the download IDs to process during this step.
|
||||
*
|
||||
* @since 3.0
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
private function get_download_ids() {
|
||||
if ( null === $this->download_ids ) {
|
||||
$this->download_ids = get_posts( array(
|
||||
'post_status' => 'any',
|
||||
'post_type' => 'download',
|
||||
'posts_per_page' => $this->per_step,
|
||||
'offset' => ( $this->step - 1 ) * $this->per_step,
|
||||
'fields' => 'ids',
|
||||
) );
|
||||
}
|
||||
|
||||
return $this->download_ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an option
|
||||
*
|
||||
* @since 2.5
|
||||
* @param string $key The option_name to delete
|
||||
* @return void
|
||||
*/
|
||||
protected function delete_data( $key ) {
|
||||
global $wpdb;
|
||||
$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
|
||||
}
|
||||
}
|
@ -0,0 +1,147 @@
|
||||
<?php
|
||||
/**
|
||||
* Recount all cutomer stats
|
||||
*
|
||||
* This class handles batch processing of recounting all customer stats
|
||||
*
|
||||
* @subpackage Admin/Tools/EDD_Tools_Recount_Customer_Stats
|
||||
* @copyright Copyright (c) 2015, Chris Klosowski
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
||||
* @since 2.5
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* EDD_Tools_Recount_Stats Class
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
class EDD_Tools_Recount_Customer_Stats extends EDD_Batch_Export {
|
||||
|
||||
/**
|
||||
* Our export type. Used for export-type specific filters/actions
|
||||
* @var string
|
||||
* @since 2.5
|
||||
*/
|
||||
public $export_type = '';
|
||||
|
||||
/**
|
||||
* Allows for a non-download batch processing to be run.
|
||||
* @since 2.5
|
||||
* @var boolean
|
||||
*/
|
||||
public $is_void = true;
|
||||
|
||||
/**
|
||||
* Sets the number of items to pull on each step
|
||||
* @since 2.5
|
||||
* @var integer
|
||||
*/
|
||||
public $per_step = 5;
|
||||
|
||||
/**
|
||||
* Get the Export Data
|
||||
*
|
||||
* @since 2.5
|
||||
* @global object $wpdb Used to query the database using the WordPress
|
||||
* Database API
|
||||
* @return bool True if results were found for this batch, false if not.
|
||||
*/
|
||||
public function get_data() {
|
||||
|
||||
$args = array(
|
||||
'limit' => $this->per_step,
|
||||
'offset' => $this->per_step * ( $this->step - 1 ),
|
||||
'orderby' => 'id',
|
||||
'order' => 'DESC',
|
||||
);
|
||||
|
||||
$customers = edd_get_customers( $args );
|
||||
|
||||
if ( $customers ) {
|
||||
foreach ( $customers as $customer ) {
|
||||
$customer->recalculate_stats();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the calculated completion percentage
|
||||
*
|
||||
* @since 2.5
|
||||
* @return int
|
||||
*/
|
||||
public function get_percentage_complete() {
|
||||
|
||||
$total = edd_count_customers();
|
||||
$percentage = 100;
|
||||
|
||||
if( $total > 0 ) {
|
||||
$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
|
||||
}
|
||||
|
||||
if( $percentage > 100 ) {
|
||||
$percentage = 100;
|
||||
}
|
||||
|
||||
return $percentage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the properties specific to the payments export
|
||||
*
|
||||
* @since 2.5
|
||||
* @param array $request The Form Data passed into the batch processing
|
||||
*/
|
||||
public function set_properties( $request ) { }
|
||||
|
||||
/**
|
||||
* Process a step
|
||||
*
|
||||
* @since 2.5
|
||||
* @return bool
|
||||
*/
|
||||
public function process_step() {
|
||||
|
||||
if ( ! $this->can_export() ) {
|
||||
wp_die( __( 'You do not have permission to export data.', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
|
||||
}
|
||||
|
||||
$had_data = $this->get_data();
|
||||
|
||||
if( $had_data ) {
|
||||
$this->done = false;
|
||||
return true;
|
||||
} else {
|
||||
$this->done = true;
|
||||
$this->message = __( 'Customer stats successfully recounted.', 'easy-digital-downloads' );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function headers() {
|
||||
edd_set_time_limit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the export
|
||||
*
|
||||
* @since 2.5
|
||||
* @return void
|
||||
*/
|
||||
public function export() {
|
||||
|
||||
// Set headers
|
||||
$this->headers();
|
||||
|
||||
edd_die();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,164 @@
|
||||
<?php
|
||||
/**
|
||||
* Recount download earnings and stats
|
||||
*
|
||||
* This class handles batch processing of recounting earnings and stats
|
||||
*
|
||||
* @subpackage Admin/Tools/EDD_Tools_Recount_Stats
|
||||
* @copyright Copyright (c) 2021, Sandhills Development, LLC
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
||||
* @since 2.5
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* EDD_Tools_Recount_Stats Class
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
class EDD_Tools_Recount_Download_Stats extends EDD_Batch_Export {
|
||||
|
||||
/**
|
||||
* Our export type. Used for export-type specific filters/actions
|
||||
* @var string
|
||||
* @since 2.5
|
||||
*/
|
||||
public $export_type = '';
|
||||
|
||||
/**
|
||||
* Allows for a non-download batch processing to be run.
|
||||
* @since 2.5
|
||||
* @var boolean
|
||||
*/
|
||||
public $is_void = true;
|
||||
|
||||
/**
|
||||
* Sets the number of items to pull on each step
|
||||
* @since 2.5
|
||||
* @var integer
|
||||
*/
|
||||
public $per_step = 30;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $message = '';
|
||||
|
||||
/**
|
||||
* ID of the download we're recounting stats for
|
||||
* @var int|false
|
||||
*/
|
||||
protected $download_id = false;
|
||||
|
||||
/**
|
||||
* Get the Export Data
|
||||
*
|
||||
* @since 2.5
|
||||
* @global object $wpdb Used to query the database using the WordPress
|
||||
* Database API
|
||||
* @return bool
|
||||
*/
|
||||
public function get_data() {
|
||||
|
||||
$accepted_statuses = apply_filters( 'edd_recount_accepted_statuses', edd_get_gross_order_statuses() );
|
||||
|
||||
// These arguments are no longer used, but keeping the filter here to apply the deprecation notice.
|
||||
$deprecated_args = edd_apply_filters_deprecated( 'edd_recount_download_stats_args', array(
|
||||
array(
|
||||
'post_parent' => $this->download_id,
|
||||
'post_type' => 'edd_log',
|
||||
'posts_per_page' => $this->per_step,
|
||||
'post_status' => 'publish',
|
||||
'paged' => $this->step,
|
||||
'log_type' => 'sale',
|
||||
'fields' => 'ids',
|
||||
)
|
||||
), '3.0' );
|
||||
|
||||
if ( ! empty( $this->download_id ) && is_numeric( $this->download_id ) ) {
|
||||
edd_recalculate_download_sales_earnings( $this->download_id );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the calculated completion percentage
|
||||
*
|
||||
* @since 2.5
|
||||
* @return int
|
||||
*/
|
||||
public function get_percentage_complete() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the properties specific to the payments export
|
||||
*
|
||||
* @since 2.5
|
||||
* @param array $request The Form Data passed into the batch processing
|
||||
*/
|
||||
public function set_properties( $request ) {
|
||||
$this->download_id = isset( $request['download_id'] ) ? sanitize_text_field( $request['download_id'] ) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a step
|
||||
*
|
||||
* @since 2.5
|
||||
* @return bool
|
||||
*/
|
||||
public function process_step() {
|
||||
if ( ! $this->can_export() ) {
|
||||
wp_die( __( 'You do not have permission to perform this action.', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
|
||||
}
|
||||
|
||||
$more_to_do = $this->get_data();
|
||||
|
||||
if( $more_to_do ) {
|
||||
$this->done = false;
|
||||
return true;
|
||||
} else {
|
||||
$this->delete_data( 'edd_recount_total_' . $this->download_id );
|
||||
$this->delete_data( 'edd_temp_recount_download_stats' );
|
||||
$this->done = true;
|
||||
$this->message = sprintf( __( 'Earnings and sales stats successfully recounted for %s.', 'easy-digital-downloads' ), get_the_title( $this->download_id ) );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function headers() {
|
||||
edd_set_time_limit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the export
|
||||
*
|
||||
* @since 2.5
|
||||
* @return void
|
||||
*/
|
||||
public function export() {
|
||||
|
||||
// Set headers
|
||||
$this->headers();
|
||||
|
||||
edd_die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an option
|
||||
*
|
||||
* @since 2.5
|
||||
* @param string $key The option_name to delete
|
||||
* @return void
|
||||
*/
|
||||
protected function delete_data( $key ) {
|
||||
global $wpdb;
|
||||
$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
<?php
|
||||
/**
|
||||
* Recount all cutomer stats
|
||||
*
|
||||
* This class handles batch processing of recounting a single customer's stats
|
||||
*
|
||||
* @subpackage Admin/Tools/EDD_Tools_Recount_Customer_Stats
|
||||
* @copyright Copyright (c) 2015, Chris Klosowski
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
||||
* @since 2.5
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* EDD_Tools_Recount_Stats Class
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
class EDD_Tools_Recount_Single_Customer_Stats extends EDD_Batch_Export {
|
||||
|
||||
/**
|
||||
* Our export type. Used for export-type specific filters/actions
|
||||
* @var string
|
||||
* @since 2.5
|
||||
*/
|
||||
public $export_type = '';
|
||||
|
||||
/**
|
||||
* Allows for a non-download batch processing to be run.
|
||||
* @since 2.5
|
||||
* @var boolean
|
||||
*/
|
||||
public $is_void = true;
|
||||
|
||||
/**
|
||||
* Sets the number of items to pull on each step
|
||||
* @since 2.5
|
||||
* @var integer
|
||||
*/
|
||||
public $per_step = 10;
|
||||
|
||||
/**
|
||||
* Get the Export Data
|
||||
*
|
||||
* @since 2.5
|
||||
* @global object $wpdb Used to query the database using the WordPress
|
||||
* Database API
|
||||
* @return bool True if data was found, false if not.
|
||||
*/
|
||||
public function get_data() {
|
||||
|
||||
$customer = new EDD_Customer( $this->customer_id );
|
||||
if ( $customer ) {
|
||||
$customer->recalculate_stats();
|
||||
$this->result_data = array(
|
||||
'purchase_count' => (int) $customer->purchase_count,
|
||||
'purchase_value' => esc_html( edd_currency_filter( edd_format_amount( $customer->purchase_value ) ) ),
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the calculated completion percentage
|
||||
*
|
||||
* @since 2.5
|
||||
* @return int
|
||||
*/
|
||||
public function get_percentage_complete() {
|
||||
|
||||
$total = edd_count_orders(
|
||||
array(
|
||||
'customer_id' => $this->customer_id,
|
||||
)
|
||||
);
|
||||
|
||||
$percentage = 100;
|
||||
|
||||
if ( $total > 0 ) {
|
||||
$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
|
||||
}
|
||||
|
||||
if ( $percentage > 100 ) {
|
||||
$percentage = 100;
|
||||
}
|
||||
|
||||
return $percentage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the properties specific to the payments export
|
||||
*
|
||||
* @since 2.5
|
||||
* @param array $request The Form Data passed into the batch processing
|
||||
*/
|
||||
public function set_properties( $request ) {
|
||||
$this->customer_id = isset( $request['customer_id'] ) ? sanitize_text_field( $request['customer_id'] ) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a step
|
||||
*
|
||||
* @since 2.5
|
||||
* @return bool
|
||||
*/
|
||||
public function process_step() {
|
||||
|
||||
if ( ! $this->can_export() ) {
|
||||
wp_die( esc_html__( 'You do not have permission to modify this data.', 'easy-digital-downloads' ), esc_html__( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
|
||||
}
|
||||
|
||||
$had_data = $this->get_data();
|
||||
|
||||
if ( ! $had_data ) {
|
||||
$this->done = false;
|
||||
return true;
|
||||
}
|
||||
$this->done = true;
|
||||
$this->message = esc_html__( 'Customer stats successfully recounted.', 'easy-digital-downloads' );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function headers() {
|
||||
edd_set_time_limit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the export
|
||||
*
|
||||
* @since 2.5
|
||||
* @return void
|
||||
*/
|
||||
public function export() {
|
||||
|
||||
// Set headers
|
||||
$this->headers();
|
||||
|
||||
edd_die();
|
||||
}
|
||||
}
|
@ -0,0 +1,258 @@
|
||||
<?php
|
||||
/**
|
||||
* Recount store earnings
|
||||
*
|
||||
* This class handles batch processing of recounting earnings
|
||||
*
|
||||
* @subpackage Admin/Tools/EDD_Tools_Recount_Store_Earnings
|
||||
* @copyright Copyright (c) 2015, Chris Klosowski
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
||||
* @since 2.5
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* EDD_Tools_Recount_Store_Earnings Class
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
class EDD_Tools_Recount_Store_Earnings extends EDD_Batch_Export {
|
||||
|
||||
/**
|
||||
* Our export type. Used for export-type specific filters/actions
|
||||
* @var string
|
||||
* @since 2.5
|
||||
*/
|
||||
public $export_type = '';
|
||||
|
||||
/**
|
||||
* Allows for a non-download batch processing to be run.
|
||||
* @since 2.5
|
||||
* @var boolean
|
||||
*/
|
||||
public $is_void = true;
|
||||
|
||||
/**
|
||||
* Sets the number of items to pull on each step
|
||||
* @since 2.5
|
||||
* @var integer
|
||||
*/
|
||||
public $per_step = 100;
|
||||
|
||||
/**
|
||||
* Get the Export Data
|
||||
*
|
||||
* @since 2.5
|
||||
* @global object $wpdb Used to query the database using the WordPress
|
||||
* Database API
|
||||
* @return bool True if results were found, false if not.
|
||||
*/
|
||||
public function get_data() {
|
||||
|
||||
if ( $this->step == 1 ) {
|
||||
$this->delete_data( 'edd_temp_recount_earnings' );
|
||||
}
|
||||
|
||||
$total = get_option( 'edd_temp_recount_earnings', false );
|
||||
|
||||
if ( false === $total ) {
|
||||
$total = (float) 0;
|
||||
$this->store_data( 'edd_temp_recount_earnings', $total );
|
||||
}
|
||||
|
||||
$accepted_statuses = apply_filters( 'edd_recount_accepted_statuses', edd_get_gross_order_statuses() );
|
||||
|
||||
$args = apply_filters(
|
||||
'edd_recount_earnings_args',
|
||||
array(
|
||||
'number' => $this->per_step,
|
||||
'offset' => $this->per_step * ( $this->step - 1 ),
|
||||
'status' => $accepted_statuses,
|
||||
'fields' => 'total',
|
||||
'no_found_rows' => true,
|
||||
'type' => array( 'sale', 'refund' ),
|
||||
)
|
||||
);
|
||||
|
||||
$orders = edd_get_orders( $args );
|
||||
|
||||
if ( ! empty( $orders ) ) {
|
||||
$total += array_sum( $orders );
|
||||
|
||||
if ( $total < 0 ) {
|
||||
$total = 0;
|
||||
}
|
||||
|
||||
$total = round( $total, edd_currency_decimal_filter() );
|
||||
|
||||
$this->store_data( 'edd_temp_recount_earnings', $total );
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
update_option( 'edd_earnings_total', $total, false );
|
||||
set_transient( 'edd_earnings_total', $total, 86400 );
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the calculated completion percentage
|
||||
*
|
||||
* @since 2.5
|
||||
* @return int
|
||||
*/
|
||||
public function get_percentage_complete() {
|
||||
|
||||
$total = $this->get_stored_data( 'edd_recount_earnings_total' );
|
||||
|
||||
if ( false === $total ) {
|
||||
$accepted_statuses = apply_filters( 'edd_recount_accepted_statuses', edd_get_gross_order_statuses() );
|
||||
$args = apply_filters(
|
||||
'edd_recount_earnings_total_args',
|
||||
array(
|
||||
'status' => $accepted_statuses,
|
||||
'type' => array( 'sale', 'refund' ),
|
||||
)
|
||||
);
|
||||
$total = apply_filters( 'edd_recount_store_earnings_total', edd_count_orders( $args ) );
|
||||
|
||||
$this->store_data( 'edd_recount_earnings_total', $total );
|
||||
}
|
||||
|
||||
$percentage = 100;
|
||||
|
||||
if ( $total > 0 ) {
|
||||
$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
|
||||
}
|
||||
|
||||
if ( $percentage > 100 ) {
|
||||
$percentage = 100;
|
||||
}
|
||||
|
||||
return $percentage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the properties specific to the payments export
|
||||
*
|
||||
* @since 2.5
|
||||
* @param array $request The Form Data passed into the batch processing
|
||||
*/
|
||||
public function set_properties( $request ) {}
|
||||
|
||||
/**
|
||||
* Process a step
|
||||
*
|
||||
* @since 2.5
|
||||
* @return bool
|
||||
*/
|
||||
public function process_step() {
|
||||
|
||||
if ( ! $this->can_export() ) {
|
||||
wp_die( __( 'You do not have permission to export data.', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
|
||||
}
|
||||
|
||||
$had_data = $this->get_data();
|
||||
|
||||
if( $had_data ) {
|
||||
$this->done = false;
|
||||
return true;
|
||||
} else {
|
||||
delete_transient( 'edd_stats_earnings' );
|
||||
delete_transient( 'edd_stats_sales' );
|
||||
delete_transient( 'edd_estimated_monthly_stats' . true );
|
||||
delete_transient( 'edd_estimated_monthly_stats' . false );
|
||||
|
||||
$this->delete_data( 'edd_recount_earnings_total' );
|
||||
$this->delete_data( 'edd_temp_recount_earnings' );
|
||||
$this->done = true;
|
||||
$this->message = __( 'Store earnings successfully recounted.', 'easy-digital-downloads' );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function headers() {
|
||||
edd_set_time_limit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the export
|
||||
*
|
||||
* @since 2.5
|
||||
* @return void
|
||||
*/
|
||||
public function export() {
|
||||
|
||||
// Set headers
|
||||
$this->headers();
|
||||
|
||||
edd_die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a key, get the information from the Database Directly
|
||||
*
|
||||
* @since 2.5
|
||||
* @param string $key The option_name
|
||||
* @return mixed Returns the data from the database
|
||||
*/
|
||||
private function get_stored_data( $key ) {
|
||||
global $wpdb;
|
||||
$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
|
||||
|
||||
if ( empty( $value ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$maybe_json = json_decode( $value );
|
||||
if ( ! is_null( $maybe_json ) ) {
|
||||
$value = json_decode( $value, true );
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give a key, store the value
|
||||
*
|
||||
* @since 2.5
|
||||
* @param string $key The option_name
|
||||
* @param mixed $value The value to store
|
||||
* @return void
|
||||
*/
|
||||
private function store_data( $key, $value ) {
|
||||
global $wpdb;
|
||||
|
||||
$value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value );
|
||||
|
||||
$data = array(
|
||||
'option_name' => $key,
|
||||
'option_value' => $value,
|
||||
'autoload' => 'no',
|
||||
);
|
||||
|
||||
$formats = array(
|
||||
'%s', '%s', '%s',
|
||||
);
|
||||
|
||||
$wpdb->replace( $wpdb->options, $data, $formats );
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an option
|
||||
*
|
||||
* @since 2.5
|
||||
* @param string $key The option_name to delete
|
||||
* @return void
|
||||
*/
|
||||
private function delete_data( $key ) {
|
||||
global $wpdb;
|
||||
$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,291 @@
|
||||
<?php
|
||||
/**
|
||||
* Reset store earnings and stats.
|
||||
*
|
||||
* This class handles batch processing of resetting store and download sales and earnings stats.
|
||||
*
|
||||
* @package EDD
|
||||
* @subpackage Admin\Tools
|
||||
* @copyright Copyright (c) 2018, Easy Digital Downloads, LLC
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
||||
* @since 2.5
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* EDD_Tools_Reset_Stats class.
|
||||
*
|
||||
* @since 2.5
|
||||
* @since 3.0 Updated to work with new query methods.
|
||||
*/
|
||||
class EDD_Tools_Reset_Stats extends EDD_Batch_Export {
|
||||
|
||||
/**
|
||||
* Our export type. Used for export-type specific filters/actions.
|
||||
*
|
||||
* @since 2.5
|
||||
* @var string
|
||||
*/
|
||||
public $export_type = '';
|
||||
|
||||
/**
|
||||
* Allows for a non-download batch processing to be run.
|
||||
*
|
||||
* @since 2.5
|
||||
* @var bool
|
||||
*/
|
||||
public $is_void = true;
|
||||
|
||||
/**
|
||||
* Sets the number of items to pull on each step.
|
||||
*
|
||||
* @since 2.5
|
||||
* @var int
|
||||
*/
|
||||
public $per_step = 1;
|
||||
|
||||
/**
|
||||
* Retrieve the export data.
|
||||
*
|
||||
* @since 2.5
|
||||
*
|
||||
* @return array|false $data The data for the CSV file, false otherwise.
|
||||
*/
|
||||
public function get_data() {
|
||||
global $wpdb;
|
||||
|
||||
$tables = $this->get_stored_data( 'edd_reset_tables_to_truncate' );
|
||||
|
||||
if ( ! is_array( $tables ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$offset = ( $this->step - 1 ) * $this->per_step;
|
||||
$step_items = array_slice( $tables, $offset, $this->per_step );
|
||||
|
||||
if ( $step_items ) {
|
||||
$query = "TRUNCATE TABLE {$step_items[0]}";
|
||||
edd_debug_log( var_export($query, true), true );
|
||||
$wpdb->query( $query );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the percentage completed.
|
||||
*
|
||||
* @since 2.5
|
||||
*
|
||||
* @return float Percentage complete.
|
||||
*/
|
||||
public function get_percentage_complete() {
|
||||
$items = $this->get_stored_data( 'edd_reset_tables_to_truncate' );
|
||||
$total = count( $items );
|
||||
|
||||
$percentage = 100;
|
||||
|
||||
if ( $total > 0 ) {
|
||||
$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
|
||||
}
|
||||
|
||||
if ( $percentage > 100 ) {
|
||||
$percentage = 100;
|
||||
}
|
||||
|
||||
return $percentage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the properties specific to the export.
|
||||
*
|
||||
* @since 2.5
|
||||
*
|
||||
* @param array $request Form data passed into the batch processor.
|
||||
*/
|
||||
public function set_properties( $request ) {}
|
||||
|
||||
/**
|
||||
* Process a step.
|
||||
*
|
||||
* @since 2.5
|
||||
*
|
||||
* @return bool True if more data exists, false otherwise.
|
||||
*/
|
||||
public function process_step() {
|
||||
if ( ! $this->can_export() ) {
|
||||
wp_die( esc_html__( 'You do not have permission to export data.', 'easy-digital-downloads' ), esc_html__( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
|
||||
}
|
||||
|
||||
$had_data = $this->get_data();
|
||||
|
||||
if ( $had_data ) {
|
||||
$this->done = false;
|
||||
return true;
|
||||
} else {
|
||||
update_option( 'edd_earnings_total', 0, false );
|
||||
update_option( 'edd_earnings_total_without_tax', 0, false );
|
||||
delete_transient( 'edd_earnings_total' );
|
||||
delete_transient( 'edd_earnings_total_without_tax' );
|
||||
delete_transient( 'edd_estimated_monthly_stats' . true );
|
||||
delete_transient( 'edd_estimated_monthly_stats' . false );
|
||||
$this->delete_data( 'edd_reset_tables_to_truncate' );
|
||||
|
||||
// Reset the sequential order numbers
|
||||
if ( edd_get_option( 'enable_sequential' ) ) {
|
||||
delete_option( 'edd_last_payment_number' );
|
||||
}
|
||||
|
||||
$this->done = true;
|
||||
$this->message = __( 'Your store has been successfully reset.', 'easy-digital-downloads' );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Export headers.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function headers() {
|
||||
edd_set_time_limit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the export.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function export() {
|
||||
|
||||
// Set headers.
|
||||
$this->headers();
|
||||
|
||||
edd_die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch data prior to batch processing starting.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function pre_fetch() {
|
||||
if ( 1 === $this->step ) {
|
||||
$this->delete_data( 'edd_reset_tables_to_truncate' );
|
||||
}
|
||||
|
||||
$tables = get_option( 'edd_reset_tables_to_truncate', false );
|
||||
|
||||
if ( false === $tables ) {
|
||||
$tables = array();
|
||||
|
||||
foreach ( EDD()->components as $component ) {
|
||||
/** @var $component EDD\Component */
|
||||
|
||||
// Objects
|
||||
$object = $component->get_interface( 'table' );
|
||||
if ( $object instanceof \EDD\Database\Table && $object->exists() ) {
|
||||
if ( 'adjustments' === $object->name ) {
|
||||
continue;
|
||||
}
|
||||
$tables[] = $object->table_name;
|
||||
}
|
||||
|
||||
// Meta
|
||||
$meta = $component->get_interface( 'meta' );
|
||||
if ( $meta instanceof \EDD\Database\Table && $meta->exists() ) {
|
||||
if ( 'adjustmentmeta' === $meta->name ) {
|
||||
continue;
|
||||
}
|
||||
$tables[] = $meta->table_name;
|
||||
}
|
||||
}
|
||||
|
||||
$tables = apply_filters( 'edd_reset_tables_to_truncate', $tables );
|
||||
|
||||
$this->store_data( 'edd_reset_tables_to_truncate', $tables );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a key, get the information from the database directly.
|
||||
*
|
||||
* @since 2.5
|
||||
*
|
||||
* @param string $key Option name.
|
||||
* @return mixed Returns the data from the database.
|
||||
*/
|
||||
private function get_stored_data( $key ) {
|
||||
global $wpdb;
|
||||
|
||||
$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s", $key ) );
|
||||
|
||||
if ( empty( $value ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$maybe_json = json_decode( $value );
|
||||
if ( ! is_null( $maybe_json ) ) {
|
||||
$value = json_decode( $value, true );
|
||||
}
|
||||
|
||||
return (array) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a value in the wp_options table.
|
||||
*
|
||||
* @since 2.5
|
||||
*
|
||||
* @param string $key Option name.
|
||||
* @param mixed $value Option value.
|
||||
*/
|
||||
private function store_data( $key = '', $value = '' ) {
|
||||
global $wpdb;
|
||||
|
||||
// Bail if no key was passed.
|
||||
if ( empty( $key ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse value.
|
||||
$value = is_array( $value )
|
||||
? wp_json_encode( $value )
|
||||
: esc_attr( $value );
|
||||
|
||||
// Prepare data.
|
||||
$data = array(
|
||||
'option_name' => $key,
|
||||
'option_value' => $value,
|
||||
'autoload' => 'no',
|
||||
);
|
||||
|
||||
$formats = array( '%s', '%s', '%s' );
|
||||
|
||||
// Update database.
|
||||
$wpdb->replace( $wpdb->options, $data, $formats );
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an option.
|
||||
*
|
||||
* @since 2.5
|
||||
*
|
||||
* @param string $key Option name.
|
||||
*/
|
||||
private function delete_data( $key = '' ) {
|
||||
global $wpdb;
|
||||
|
||||
// Bail if no key was passed.
|
||||
if ( empty( $key ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Delete from the database.
|
||||
$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
|
||||
}
|
||||
}
|
@ -0,0 +1,264 @@
|
||||
<?php
|
||||
/**
|
||||
* Logs UI
|
||||
*
|
||||
* @package EDD
|
||||
* @subpackage Admin/Tools
|
||||
* @copyright Copyright (c) 2018, Easy Digital Downloads, LLC
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
||||
* @since 3.0
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Setup the logs view
|
||||
*
|
||||
* @since 3.0
|
||||
*
|
||||
* @param type $type
|
||||
* @return boolean
|
||||
*/
|
||||
function edd_logs_view_setup( $type = '' ) {
|
||||
|
||||
// Bail if cannot view
|
||||
if ( ! current_user_can( 'view_shop_reports' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Includes
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
|
||||
require_once EDD_PLUGIN_DIR . 'includes/admin/reporting/class-base-logs-list-table.php';
|
||||
require_once EDD_PLUGIN_DIR . 'includes/admin/reporting/class-' . sanitize_key( $type ) . '-logs-list-table.php';
|
||||
|
||||
// Done!
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the log page
|
||||
*
|
||||
* @since 3.0
|
||||
*
|
||||
* @param EDD_Base_Log_List_Table $logs_table List table class to work with
|
||||
* @param string $tag Type of log to view
|
||||
*/
|
||||
function edd_logs_view_page( $logs_table, $tag = '' ) {
|
||||
$tag = sanitize_key( $tag );
|
||||
$logs_table->prepare_items(); ?>
|
||||
|
||||
<div class="wrap">
|
||||
<?php
|
||||
/**
|
||||
* Fires at the top of the logs view.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
do_action( "edd_logs_{$tag}_top" ); ?>
|
||||
|
||||
<form id="edd-logs-filter" method="get" action="<?php echo esc_url( edd_get_admin_url( array( 'page' => 'edd-tools', 'tab' => sanitize_key( $tag ) ) ) ); ?>">
|
||||
<input type="hidden" name="post_type" value="download" />
|
||||
<input type="hidden" name="page" value="edd-tools" />
|
||||
<input type="hidden" name="tab" value="<?php echo esc_attr( $tag ); ?>" />
|
||||
<?php
|
||||
wp_nonce_field( -1, 'edd_filter', false );
|
||||
$logs_table->views();
|
||||
$logs_table->advanced_filters();
|
||||
?>
|
||||
</form>
|
||||
<?php
|
||||
$logs_table->display();
|
||||
?>
|
||||
|
||||
<?php
|
||||
/**
|
||||
* Fires at the bottom of the logs view.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
do_action( "edd_logs_{$tag}_bottom" ); ?>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/** 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
|
||||
*
|
||||
* @since 1.4
|
||||
* @uses EDD_File_Downloads_Log_Table::prepare_items()
|
||||
* @uses EDD_File_Downloads_Log_Table::search_box()
|
||||
* @uses EDD_File_Downloads_Log_Table::display()
|
||||
* @return void
|
||||
*/
|
||||
function edd_logs_view_file_downloads() {
|
||||
|
||||
// Setup or bail
|
||||
if ( ! edd_logs_view_setup( 'file-downloads' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$logs_table = new EDD_File_Downloads_Log_Table();
|
||||
|
||||
edd_logs_view_page( $logs_table, 'file_downloads' );
|
||||
}
|
||||
add_action( 'edd_logs_view_file_downloads', 'edd_logs_view_file_downloads' );
|
||||
|
||||
/**
|
||||
* Gateway Error Logs
|
||||
*
|
||||
* @since 1.4
|
||||
* @uses EDD_File_Downloads_Log_Table::prepare_items()
|
||||
* @uses EDD_File_Downloads_Log_Table::display()
|
||||
* @return void
|
||||
*/
|
||||
function edd_logs_view_gateway_errors() {
|
||||
|
||||
// Setup or bail
|
||||
if ( ! edd_logs_view_setup( 'gateway-error' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$logs_table = new EDD_Gateway_Error_Log_Table();
|
||||
|
||||
edd_logs_view_page( $logs_table, 'gateway_errors' );
|
||||
}
|
||||
add_action( 'edd_logs_view_gateway_errors', 'edd_logs_view_gateway_errors' );
|
||||
|
||||
/**
|
||||
* API Request Logs
|
||||
*
|
||||
* @since 1.5
|
||||
* @uses EDD_API_Request_Log_Table::prepare_items()
|
||||
* @uses EDD_API_Request_Log_Table::search_box()
|
||||
* @uses EDD_API_Request_Log_Table::display()
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function edd_logs_view_api_requests() {
|
||||
|
||||
// Setup or bail
|
||||
if ( ! edd_logs_view_setup( 'api-requests' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$logs_table = new EDD_API_Request_Log_Table();
|
||||
|
||||
edd_logs_view_page( $logs_table, 'api_requests' );
|
||||
}
|
||||
add_action( 'edd_logs_view_api_requests', 'edd_logs_view_api_requests' );
|
||||
|
||||
|
||||
/**
|
||||
* Default Log Views
|
||||
*
|
||||
* @since 1.4
|
||||
* @return array $views Log Views
|
||||
*/
|
||||
function edd_log_default_views() {
|
||||
/**
|
||||
* Filters the default logs views.
|
||||
*
|
||||
* @since 1.4
|
||||
* @since 3.0 Removed sales log.
|
||||
*
|
||||
* @param array $views Logs views. Each key/value pair represents the view slug
|
||||
* and label, respectively.
|
||||
*/
|
||||
return apply_filters( 'edd_log_views', array(
|
||||
'file_downloads' => __( 'File Downloads', 'easy-digital-downloads' ),
|
||||
'gateway_errors' => __( 'Payment Errors', 'easy-digital-downloads' ),
|
||||
'api_requests' => __( 'API Requests', 'easy-digital-downloads' )
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the Reports page views drop down
|
||||
*
|
||||
* @since 1.3
|
||||
* @since 3.0 Deprecated, and modified to look like the 3.0 approach
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function edd_log_views() {
|
||||
static $once = false;
|
||||
|
||||
// Only once
|
||||
if ( true === $once ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only once
|
||||
$once = true; ?>
|
||||
|
||||
<!-- EDD 3.0 Hack -->
|
||||
</div></div>
|
||||
<form method="get" class="edd-old-log-filters" action="<?php echo esc_url( edd_get_admin_url( array( 'page' => 'edd-payment-history' ) ) ); ?>">
|
||||
<?php edd_admin_filter_bar( 'old_logs' ); ?>
|
||||
</form>
|
||||
<div class="tablenav top"><div>
|
||||
<!-- EDD 3.0 Hack -->
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Output old logs filter bar items
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
function edd_old_logs_filter_bar_items() {
|
||||
$views = edd_log_default_views();
|
||||
$current_view = isset( $_GET['view'] ) && array_key_exists( $_GET['view'], edd_log_default_views() )
|
||||
? sanitize_text_field( $_GET['view'] )
|
||||
: 'file_downloads'; ?>
|
||||
|
||||
<span id="edd-type-filter">
|
||||
<select id="edd-logs-view" name="view">
|
||||
<?php foreach ( $views as $view_id => $label ) : ?>
|
||||
<option value="<?php echo esc_attr( $view_id ); ?>" <?php selected( $view_id, $current_view ); ?>><?php echo esc_html( $label ); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</span>
|
||||
|
||||
<?php
|
||||
/**
|
||||
* Fires immediately after the logs view actions are rendered in the Logs screen.
|
||||
*
|
||||
* @since 1.3
|
||||
*/
|
||||
do_action( 'edd_log_view_actions' ); ?>
|
||||
|
||||
<button type="submit "class="button button-secondary"><?php _e( 'Filter', 'easy-digital-downloads' ); ?></button>
|
||||
|
||||
<input type="hidden" name="post_type" value="download" />
|
||||
<input type="hidden" name="page" value="edd-tools" />
|
||||
<input type="hidden" name="tab" value="logs" /><?php
|
||||
}
|
||||
add_action( 'edd_admin_filter_bar_old_logs', 'edd_old_logs_filter_bar_items' );
|
@ -0,0 +1,133 @@
|
||||
<?php
|
||||
/**
|
||||
* Tools Actions
|
||||
*
|
||||
* @package EDD
|
||||
* @subpackage Admin/Tools
|
||||
* @copyright Copyright (c) 2018, Easy Digital Downloads, LLC
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
||||
* @since 2.5
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Register the recount batch processor
|
||||
* @since 2.5
|
||||
*/
|
||||
function edd_register_batch_recount_store_earnings_tool() {
|
||||
add_action( 'edd_batch_export_class_include', 'edd_include_recount_store_earnings_tool_batch_processer', 10, 1 );
|
||||
}
|
||||
add_action( 'edd_register_batch_exporter', 'edd_register_batch_recount_store_earnings_tool', 10 );
|
||||
|
||||
/**
|
||||
* Loads the tools batch processing class for recounting store earnings
|
||||
*
|
||||
* @since 2.5
|
||||
* @param string $class The class being requested to run for the batch export
|
||||
* @return void
|
||||
*/
|
||||
function edd_include_recount_store_earnings_tool_batch_processer( $class ) {
|
||||
|
||||
if ( 'EDD_Tools_Recount_Store_Earnings' === $class ) {
|
||||
require_once EDD_PLUGIN_DIR . 'includes/admin/tools/class-edd-tools-recount-store-earnings.php';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the recount download batch processor
|
||||
* @since 2.5
|
||||
*/
|
||||
function edd_register_batch_recount_download_tool() {
|
||||
add_action( 'edd_batch_export_class_include', 'edd_include_recount_download_tool_batch_processer', 10, 1 );
|
||||
}
|
||||
add_action( 'edd_register_batch_exporter', 'edd_register_batch_recount_download_tool', 10 );
|
||||
|
||||
/**
|
||||
* Loads the tools batch processing class for recounting download stats
|
||||
*
|
||||
* @since 2.5
|
||||
* @param string $class The class being requested to run for the batch export
|
||||
* @return void
|
||||
*/
|
||||
function edd_include_recount_download_tool_batch_processer( $class ) {
|
||||
|
||||
if ( 'EDD_Tools_Recount_Download_Stats' === $class ) {
|
||||
require_once EDD_PLUGIN_DIR . 'includes/admin/tools/class-edd-tools-recount-download-stats.php';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the recount all stats batch processor
|
||||
* @since 2.5
|
||||
*/
|
||||
function edd_register_batch_recount_all_tool() {
|
||||
add_action( 'edd_batch_export_class_include', 'edd_include_recount_all_tool_batch_processer', 10, 1 );
|
||||
}
|
||||
add_action( 'edd_register_batch_exporter', 'edd_register_batch_recount_all_tool', 10 );
|
||||
|
||||
/**
|
||||
* Loads the tools batch processing class for recounting all stats
|
||||
*
|
||||
* @since 2.5
|
||||
* @param string $class The class being requested to run for the batch export
|
||||
* @return void
|
||||
*/
|
||||
function edd_include_recount_all_tool_batch_processer( $class ) {
|
||||
|
||||
if ( 'EDD_Tools_Recount_All_Stats' === $class ) {
|
||||
require_once EDD_PLUGIN_DIR . 'includes/admin/tools/class-edd-tools-recount-all-stats.php';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the reset stats batch processor
|
||||
* @since 2.5
|
||||
*/
|
||||
function edd_register_batch_reset_tool() {
|
||||
add_action( 'edd_batch_export_class_include', 'edd_include_reset_tool_batch_processer', 10, 1 );
|
||||
}
|
||||
add_action( 'edd_register_batch_exporter', 'edd_register_batch_reset_tool', 10 );
|
||||
|
||||
/**
|
||||
* Loads the tools batch processing class for resetting store and product earnings
|
||||
*
|
||||
* @since 2.5
|
||||
* @param string $class The class being requested to run for the batch export
|
||||
* @return void
|
||||
*/
|
||||
function edd_include_reset_tool_batch_processer( $class ) {
|
||||
|
||||
if ( 'EDD_Tools_Reset_Stats' === $class ) {
|
||||
require_once EDD_PLUGIN_DIR . 'includes/admin/tools/class-edd-tools-reset-stats.php';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the reset customer stats batch processor
|
||||
* @since 2.5
|
||||
*/
|
||||
function edd_register_batch_customer_recount_tool() {
|
||||
add_action( 'edd_batch_export_class_include', 'edd_include_customer_recount_tool_batch_processer', 10, 1 );
|
||||
}
|
||||
add_action( 'edd_register_batch_exporter', 'edd_register_batch_customer_recount_tool', 10 );
|
||||
|
||||
/**
|
||||
* Loads the tools batch processing class for resetting all customer stats
|
||||
*
|
||||
* @since 2.5
|
||||
* @param string $class The class being requested to run for the batch export
|
||||
* @return void
|
||||
*/
|
||||
function edd_include_customer_recount_tool_batch_processer( $class ) {
|
||||
|
||||
if ( 'EDD_Tools_Recount_Customer_Stats' === $class ) {
|
||||
require_once EDD_PLUGIN_DIR . 'includes/admin/tools/class-edd-tools-recount-customer-stats.php';
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user