updated plugin Easy Digital Downloads
version 3.1.1.4.2
This commit is contained in:
@ -282,3 +282,35 @@ function edd_add_extentions_link() {
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process bulk edit actions via AJAX
|
||||
*
|
||||
* @deprecated 3.1.1.4
|
||||
* @since 1.4.4
|
||||
* @return void
|
||||
*/
|
||||
function edd_save_bulk_edit() {
|
||||
|
||||
$post_ids = ! empty( $_POST['post_ids'] )
|
||||
? wp_parse_id_list( $_POST['post_ids'] )
|
||||
: array();
|
||||
|
||||
if ( ! empty( $post_ids ) && is_array( $post_ids ) ) {
|
||||
$price = isset( $_POST['price'] )
|
||||
? strip_tags( stripslashes( $_POST['price'] ) )
|
||||
: 0;
|
||||
|
||||
foreach ( $post_ids as $post_id ) {
|
||||
if ( ! current_user_can( 'edit_post', $post_id ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ! empty( $price ) ) {
|
||||
update_post_meta( $post_id, 'edd_price', edd_sanitize_amount( $price ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
die();
|
||||
}
|
||||
|
@ -51,6 +51,11 @@ class EDD_Notices {
|
||||
*/
|
||||
public function add_notice( $args = array() ) {
|
||||
|
||||
// Avoid malformed notices variable
|
||||
if ( ! is_array( $this->notices ) ) {
|
||||
$this->notices = array();
|
||||
}
|
||||
|
||||
// Parse args
|
||||
$r = wp_parse_args( $args, array(
|
||||
'id' => '',
|
||||
@ -59,6 +64,11 @@ class EDD_Notices {
|
||||
'is_dismissible' => true,
|
||||
) );
|
||||
|
||||
// Prevent a notice from being added more than once.
|
||||
if ( ! empty( $r['id'] ) && array_key_exists( $r['id'], $this->notices ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$default_class = 'updated';
|
||||
|
||||
// One message as string
|
||||
@ -93,9 +103,10 @@ class EDD_Notices {
|
||||
}
|
||||
|
||||
// CSS Classes
|
||||
$classes = ! empty( $r['class'] )
|
||||
? array( $r['class'] )
|
||||
: array( $default_class );
|
||||
$classes = array( $default_class );
|
||||
if ( ! empty( $r['class'] ) ) {
|
||||
$classes = explode( ' ', $r['class'] );
|
||||
}
|
||||
|
||||
// Add dismissible class
|
||||
if ( ! empty( $r['is_dismissible'] ) ) {
|
||||
@ -106,13 +117,8 @@ class EDD_Notices {
|
||||
$message = '<div class="notice ' . implode( ' ', array_map( 'sanitize_html_class', $classes ) ) . '">' . $message . '</div>';
|
||||
$message = str_replace( "'", "\'", $message );
|
||||
|
||||
// Avoid malformed notices variable
|
||||
if ( ! is_array( $this->notices ) ) {
|
||||
$this->notices = array();
|
||||
}
|
||||
|
||||
// Add notice to notices array
|
||||
$this->notices[] = $message;
|
||||
$this->notices[ $r['id'] ] = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -48,7 +48,8 @@ function edd_admin_add_discount( $data = array() ) {
|
||||
edd_redirect( add_query_arg( 'edd-message', 'discount_invalid_code' ) );
|
||||
}
|
||||
|
||||
if ( ! is_numeric( $data['amount'] ) ) {
|
||||
$sanitized_amount = (float) edd_sanitize_amount( $data['amount'] );
|
||||
if ( empty( $data['amount'] ) || 0.00 === $sanitized_amount ) {
|
||||
edd_redirect( add_query_arg( 'edd-message', 'discount_invalid_amount' ) );
|
||||
}
|
||||
|
||||
@ -73,6 +74,10 @@ function edd_admin_add_discount( $data = array() ) {
|
||||
$to_add[ $column ] = $value;
|
||||
break;
|
||||
|
||||
case 'amount':
|
||||
$to_add['amount'] = edd_sanitize_amount( $value );
|
||||
break;
|
||||
|
||||
default:
|
||||
$to_add[ $column ] = is_array( $value )
|
||||
? array_map( 'sanitize_text_field', $value )
|
||||
@ -180,7 +185,8 @@ function edd_admin_edit_discount( $data = array() ) {
|
||||
wp_die( __( 'Invalid discount', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
|
||||
}
|
||||
|
||||
if ( empty( $data['amount'] ) || ! is_numeric( $data['amount'] ) ) {
|
||||
$sanitized_amount = (float) edd_sanitize_amount( $data['amount'] );
|
||||
if ( empty( $data['amount'] ) || 0.00 === $sanitized_amount ) {
|
||||
edd_redirect( add_query_arg( 'edd-message', 'discount_invalid_amount' ) );
|
||||
}
|
||||
|
||||
@ -203,7 +209,11 @@ function edd_admin_edit_discount( $data = array() ) {
|
||||
$to_update['id'] = $value;
|
||||
break;
|
||||
|
||||
default :
|
||||
case 'amount':
|
||||
$to_update['amount'] = edd_sanitize_amount( $value );
|
||||
break;
|
||||
|
||||
default:
|
||||
$to_update[ $column ] = sanitize_text_field( $value );
|
||||
break;
|
||||
}
|
||||
|
@ -346,7 +346,11 @@ add_action( 'bulk_edit_custom_box', 'edd_price_field_quick_edit', 10, 2 );
|
||||
* @return void
|
||||
*/
|
||||
function edd_price_save_quick_edit( $post_id ) {
|
||||
if ( ! isset( $_POST['post_type']) || 'download' !== $_POST['post_type'] ) {
|
||||
if ( ! isset( $_REQUEST['_edd_regprice'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! isset( $_REQUEST['post_type'] ) || 'download' !== $_REQUEST['post_type'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -358,40 +362,6 @@ function edd_price_save_quick_edit( $post_id ) {
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
if ( isset( $_REQUEST['_edd_regprice'] ) ) {
|
||||
update_post_meta( $post_id, 'edd_price', strip_tags( stripslashes( $_REQUEST['_edd_regprice'] ) ) );
|
||||
}
|
||||
update_post_meta( $post_id, 'edd_price', wp_strip_all_tags( stripslashes( $_REQUEST['_edd_regprice'] ) ) );
|
||||
}
|
||||
add_action( 'save_post', 'edd_price_save_quick_edit' );
|
||||
|
||||
/**
|
||||
* Process bulk edit actions via AJAX
|
||||
*
|
||||
* @since 1.4.4
|
||||
* @return void
|
||||
*/
|
||||
function edd_save_bulk_edit() {
|
||||
|
||||
$post_ids = ! empty( $_POST['post_ids'] )
|
||||
? wp_parse_id_list( $_POST['post_ids'] )
|
||||
: array();
|
||||
|
||||
if ( ! empty( $post_ids ) && is_array( $post_ids ) ) {
|
||||
$price = isset( $_POST['price'] )
|
||||
? strip_tags( stripslashes( $_POST['price'] ) )
|
||||
: 0;
|
||||
|
||||
foreach ( $post_ids as $post_id ) {
|
||||
if ( ! current_user_can( 'edit_post', $post_id ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ! empty( $price ) ) {
|
||||
update_post_meta( $post_id, 'edd_price', edd_sanitize_amount( $price ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
die();
|
||||
}
|
||||
add_action( 'wp_ajax_edd_save_bulk_edit', 'edd_save_bulk_edit' );
|
||||
|
@ -162,15 +162,6 @@ function edd_update_payment_details( $data = array() ) {
|
||||
$previous_customer->remove_payment( $order_id, false );
|
||||
$customer->attach_payment( $order_id, false );
|
||||
|
||||
// If purchase was completed and not ever refunded, adjust stats of customers
|
||||
if ( 'revoked' === $new_status || 'complete' === $new_status ) {
|
||||
$previous_customer->recalculate_stats();
|
||||
|
||||
if ( ! empty( $customer ) ) {
|
||||
$customer->recalculate_stats();
|
||||
}
|
||||
}
|
||||
|
||||
$order_update_args['customer_id'] = $customer->id;
|
||||
}
|
||||
|
||||
|
@ -978,6 +978,14 @@ class EDD_Payment_History_Table extends List_Table {
|
||||
*/
|
||||
private function parse_search( $search, $args ) {
|
||||
|
||||
// Order ID/number.
|
||||
if ( is_numeric( $search ) ) {
|
||||
$args['id'] = $search;
|
||||
$args['order_number'] = $search;
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
// Transaction ID
|
||||
if ( is_string( $search ) && ( false !== strpos( $search, 'txn:' ) ) ) {
|
||||
$args['txn'] = trim( str_replace( 'txn:', '', $search ) );
|
||||
@ -999,13 +1007,6 @@ class EDD_Payment_History_Table extends List_Table {
|
||||
return $args;
|
||||
}
|
||||
|
||||
// Order ID
|
||||
if ( is_numeric( $search ) ) {
|
||||
$args['id'] = $search;
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
// The customer’s name or ID prefixed by customer:
|
||||
if ( ! is_array( $search ) && ( false !== strpos( $search, 'customer:' ) ) ) {
|
||||
$search = trim( str_replace( 'customer:', '', $search ) );
|
||||
|
@ -92,13 +92,13 @@ function edd_payments_contextual_help() {
|
||||
) );
|
||||
|
||||
$screen->add_help_tab( array(
|
||||
'id' => 'edd-payments-search',
|
||||
'title' => __( 'Search', 'easy-digital-downloads' ),
|
||||
'content' =>
|
||||
'id' => 'edd-payments-search',
|
||||
'title' => __( 'Search', 'easy-digital-downloads' ),
|
||||
'content' =>
|
||||
'<p>' . __( 'The order history can be searched in several different ways.', 'easy-digital-downloads' ) . '</p>' .
|
||||
'<p>' . __( 'You can enter:', 'easy-digital-downloads' ) . '</p>' .
|
||||
'<ul>
|
||||
<li>' . __( 'The order ID', 'easy-digital-downloads' ) . '</li>
|
||||
<li>' . __( 'The specific order ID', 'easy-digital-downloads' ) . '</li>
|
||||
<li>' . __( 'The 32-character order key', 'easy-digital-downloads' ) . '</li>
|
||||
<li>' . __( 'The customer\'s email address', 'easy-digital-downloads' ) . '</li>
|
||||
<li>' . sprintf(
|
||||
|
@ -28,6 +28,14 @@ class EDD_Batch_Sales_Export extends EDD_Batch_Export {
|
||||
*/
|
||||
public $export_type = 'sales';
|
||||
|
||||
/**
|
||||
* The array of order IDs.
|
||||
*
|
||||
* @since 3.1.1.4
|
||||
* @var array
|
||||
*/
|
||||
private $orders;
|
||||
|
||||
/**
|
||||
* Set the CSV columns
|
||||
*
|
||||
@ -61,20 +69,15 @@ class EDD_Batch_Sales_Export extends EDD_Batch_Export {
|
||||
public function get_data() {
|
||||
$data = array();
|
||||
|
||||
$args = array(
|
||||
'number' => 30,
|
||||
'offset' => ( $this->step * 30 ) - 30,
|
||||
'order' => 'ASC',
|
||||
$args = array_merge(
|
||||
$this->get_order_item_args(),
|
||||
array(
|
||||
'number' => 30,
|
||||
'offset' => ( $this->step * 30 ) - 30,
|
||||
'order' => 'ASC',
|
||||
)
|
||||
);
|
||||
|
||||
if ( ! empty( $this->start ) || ! empty( $this->end ) ) {
|
||||
$args['date_query'] = $this->get_date_query();
|
||||
}
|
||||
|
||||
if ( 0 !== $this->download_id ) {
|
||||
$args['product_id'] = $this->download_id;
|
||||
}
|
||||
|
||||
$items = edd_get_order_items( $args );
|
||||
|
||||
foreach ( $items as $item ) {
|
||||
@ -112,16 +115,7 @@ class EDD_Batch_Sales_Export extends EDD_Batch_Export {
|
||||
* @return int
|
||||
*/
|
||||
public function get_percentage_complete() {
|
||||
$args = array();
|
||||
|
||||
if ( ! empty( $this->start ) || ! empty( $this->end ) ) {
|
||||
$args['date_query'] = $this->get_date_query();
|
||||
}
|
||||
|
||||
if ( 0 !== $this->download_id ) {
|
||||
$args['product_id'] = $this->download_id;
|
||||
}
|
||||
|
||||
$args = $this->get_order_item_args();
|
||||
$total = edd_count_order_items( $args );
|
||||
$percentage = 100;
|
||||
|
||||
@ -136,9 +130,52 @@ class EDD_Batch_Sales_Export extends EDD_Batch_Export {
|
||||
return $percentage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default order item parameters based on the class properties.
|
||||
*
|
||||
* @since 3.1.1.4
|
||||
* @return array
|
||||
*/
|
||||
private function get_order_item_args() {
|
||||
$args = array();
|
||||
if ( ! empty( $this->start ) || ! empty( $this->end ) ) {
|
||||
$args['date_query'] = $this->get_date_query();
|
||||
}
|
||||
|
||||
if ( ! empty( $this->download_id ) ) {
|
||||
$args['product_id'] = $this->download_id;
|
||||
}
|
||||
|
||||
if ( ! empty( $this->orders ) ) {
|
||||
$args['order_id__in'] = $this->orders;
|
||||
}
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
public function set_properties( $request ) {
|
||||
$this->start = isset( $request['orders-export-start'] ) ? sanitize_text_field( $request['orders-export-start'] ) : '';
|
||||
$this->end = isset( $request['orders-export-end'] ) ? sanitize_text_field( $request['orders-export-end'] ) . ' 23:59:59' : '';
|
||||
$this->start = isset( $request['sales-export-start'] ) ? sanitize_text_field( $request['sales-export-start'] ) : '';
|
||||
$this->end = isset( $request['sales-export-end'] ) ? sanitize_text_field( $request['sales-export-end'] ) . ' 23:59:59' : '';
|
||||
$this->download_id = isset( $request['download_id'] ) ? absint( $request['download_id'] ) : 0;
|
||||
$this->orders = $this->get_orders();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the array of complete order IDs for the time period.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function get_orders() {
|
||||
$args = array(
|
||||
'fields' => 'ids',
|
||||
'type' => 'sale',
|
||||
'number' => 999999999,
|
||||
'status__in' => edd_get_complete_order_statuses(),
|
||||
);
|
||||
if ( ! empty( $this->start ) || ! empty( $this->end ) ) {
|
||||
$args['date_query'] = $this->get_date_query();
|
||||
}
|
||||
|
||||
return edd_get_orders( $args );
|
||||
}
|
||||
}
|
||||
|
@ -328,13 +328,23 @@ class EDD_Batch_Export extends EDD_Export {
|
||||
* @return array
|
||||
*/
|
||||
protected function get_date_query() {
|
||||
return array(
|
||||
array(
|
||||
'after' => $this->start ? date( 'Y-m-d 00:00:00', strtotime( $this->start ) ) : '',
|
||||
'before' => $this->end ? date( 'Y-m-d 23:59:59', strtotime( $this->end ) ) : '',
|
||||
'inclusive' => true,
|
||||
),
|
||||
$time_zone = edd_get_timezone_id();
|
||||
$date_query = array(
|
||||
'after' => '',
|
||||
'before' => '',
|
||||
'inclusive' => true,
|
||||
);
|
||||
}
|
||||
|
||||
if ( $this->start ) {
|
||||
$date = edd_get_utc_equivalent_date( EDD()->utils->date( $this->start . '00:00:00', $time_zone, false ) );
|
||||
$date_query['after'] = $date->format( 'Y-m-d H:i:s' );
|
||||
}
|
||||
|
||||
if ( $this->end ) {
|
||||
$date = edd_get_utc_equivalent_date( EDD()->utils->date( $this->end . '23:59:59', $time_zone, false ) );
|
||||
$date_query['before'] = $date->format( 'Y-m-d H:i:s' );
|
||||
}
|
||||
|
||||
return array( $date_query );
|
||||
}
|
||||
}
|
||||
|
@ -23,37 +23,17 @@ defined( 'ABSPATH' ) || exit;
|
||||
function edd_overview_sales_earnings_chart() {
|
||||
global $wpdb;
|
||||
|
||||
$dates = Reports\get_dates_filter( 'objects' );
|
||||
$chart_dates = Reports\parse_dates_for_range( null, 'now', false );
|
||||
$day_by_day = Reports\get_dates_filter_day_by_day();
|
||||
$hour_by_hour = Reports\get_dates_filter_hour_by_hour();
|
||||
$column = Reports\get_taxes_excluded_filter() ? '(total - tax)' : 'total';
|
||||
$currency = Reports\get_filter_value( 'currencies' );
|
||||
$dates = Reports\get_dates_filter( 'objects' );
|
||||
$chart_dates = Reports\parse_dates_for_range( null, 'now', false );
|
||||
$column = Reports\get_taxes_excluded_filter() ? '(total - tax)' : 'total';
|
||||
$currency = Reports\get_filter_value( 'currencies' );
|
||||
$period = Reports\get_graph_period();
|
||||
|
||||
if ( empty( $currency ) || 'convert' === $currency ) {
|
||||
$column .= ' / rate';
|
||||
}
|
||||
|
||||
$sql_clauses = array(
|
||||
'select' => 'DATE_FORMAT(date_created, "%%Y-%%m") AS date',
|
||||
'where' => '',
|
||||
'groupby' => '',
|
||||
);
|
||||
|
||||
// Default to 'monthly'.
|
||||
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'MONTH', 'date_created' );
|
||||
$sql_clauses['orderby'] = 'MONTH(date_created)';
|
||||
|
||||
// Now drill down to the smallest unit.
|
||||
if ( $hour_by_hour ) {
|
||||
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'HOUR', 'date_created' );
|
||||
$sql_clauses['orderby'] = 'HOUR(date_created)';
|
||||
$sql_clauses['select'] = 'DATE_FORMAT(date_created, "%%Y-%%m-%%d %%H:00:00") AS date';
|
||||
} elseif ( $day_by_day ) {
|
||||
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'DATE', 'date_created' );
|
||||
$sql_clauses['orderby'] = 'DATE(date_created)';
|
||||
$sql_clauses['select'] = 'DATE_FORMAT(date_created, "%%Y-%%m-%%d") AS date';
|
||||
}
|
||||
$sql_clauses = Reports\get_sql_clauses( $period );
|
||||
|
||||
if ( ! empty( $currency ) && array_key_exists( strtoupper( $currency ), edd_get_currencies() ) ) {
|
||||
$sql_clauses['where'] = $wpdb->prepare( " AND currency = %s ", strtoupper( $currency ) );
|
||||
@ -86,7 +66,7 @@ function edd_overview_sales_earnings_chart() {
|
||||
|
||||
$sales_results = $wpdb->get_results(
|
||||
$wpdb->prepare(
|
||||
"SELECT COUNT(id) AS sales, {$sql_clauses['select']}
|
||||
"SELECT COUNT(*) AS sales, {$sql_clauses['select']}
|
||||
FROM {$wpdb->edd_orders} edd_o
|
||||
WHERE date_created >= %s AND date_created <= %s
|
||||
AND status IN( {$statuses} )
|
||||
@ -122,14 +102,13 @@ function edd_overview_sales_earnings_chart() {
|
||||
$date_of_db_value = EDD()->utils->date( $earnings_result->date );
|
||||
|
||||
// Add any sales/earnings that happened during this hour.
|
||||
if ( $hour_by_hour ) {
|
||||
$date_of_db_value = edd_get_edd_timezone_equivalent_date_from_utc( $date_of_db_value );
|
||||
if ( 'hour' === $period ) {
|
||||
// If the date of this db value matches the date on this line graph/chart, set the y axis value for the chart to the number in the DB result.
|
||||
if ( $date_of_db_value->format( 'Y-m-d H' ) === $date_on_chart->format( 'Y-m-d H' ) ) {
|
||||
$earnings[ $timestamp ][1] += $earnings_result->earnings;
|
||||
}
|
||||
// Add any sales/earnings that happened during this day.
|
||||
} elseif ( $day_by_day ) {
|
||||
} elseif ( 'day' === $period ) {
|
||||
// If the date of this db value matches the date on this line graph/chart, set the y axis value for the chart to the number in the DB result.
|
||||
if ( $date_of_db_value->format( 'Y-m-d' ) === $date_on_chart->format( 'Y-m-d' ) ) {
|
||||
$earnings[ $timestamp ][1] += $earnings_result->earnings;
|
||||
@ -148,14 +127,13 @@ function edd_overview_sales_earnings_chart() {
|
||||
$date_of_db_value = EDD()->utils->date( $sales_result->date );
|
||||
|
||||
// Add any sales/earnings that happened during this hour.
|
||||
if ( $hour_by_hour ) {
|
||||
$date_of_db_value = edd_get_edd_timezone_equivalent_date_from_utc( $date_of_db_value );
|
||||
if ( 'hour' === $period ) {
|
||||
// If the date of this db value matches the date on this line graph/chart, set the y axis value for the chart to the number in the DB result.
|
||||
if ( $date_of_db_value->format( 'Y-m-d H' ) === $date_on_chart->format( 'Y-m-d H' ) ) {
|
||||
$sales[ $timestamp ][1] += $sales_result->sales;
|
||||
}
|
||||
// Add any sales/earnings that happened during this day.
|
||||
} elseif ( $day_by_day ) {
|
||||
} elseif ( 'day' === $period ) {
|
||||
// If the date of this db value matches the date on this line graph/chart, set the y axis value for the chart to the number in the DB result.
|
||||
if ( $date_of_db_value->format( 'Y-m-d' ) === $date_on_chart->format( 'Y-m-d' ) ) {
|
||||
$sales[ $timestamp ][1] += $sales_result->sales;
|
||||
@ -170,9 +148,9 @@ function edd_overview_sales_earnings_chart() {
|
||||
}
|
||||
|
||||
// Move the chart along to the next hour/day/month to get ready for the next loop.
|
||||
if ( $hour_by_hour ) {
|
||||
if ( 'hour' === $period ) {
|
||||
$chart_dates['start']->addHour( 1 );
|
||||
} elseif ( $day_by_day ) {
|
||||
} elseif ( 'day' === $period ) {
|
||||
$chart_dates['start']->addDays( 1 );
|
||||
} else {
|
||||
$chart_dates['start']->addMonth( 1 );
|
||||
@ -194,30 +172,12 @@ function edd_overview_sales_earnings_chart() {
|
||||
function edd_overview_refunds_chart() {
|
||||
global $wpdb;
|
||||
|
||||
$dates = Reports\get_dates_filter( 'objects' );
|
||||
$chart_dates = Reports\parse_dates_for_range( null, 'now', false );
|
||||
$day_by_day = Reports\get_dates_filter_day_by_day();
|
||||
$hour_by_hour = Reports\get_dates_filter_hour_by_hour();
|
||||
$column = Reports\get_taxes_excluded_filter() ? 'total - tax' : 'total';
|
||||
$currency = Reports\get_filter_value( 'currencies' );
|
||||
|
||||
$sql_clauses = array(
|
||||
'select' => 'date_created AS date',
|
||||
'where' => '',
|
||||
);
|
||||
|
||||
// Default to 'monthly'.
|
||||
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'MONTH', 'date_created' );
|
||||
$sql_clauses['orderby'] = 'MONTH(date_created)';
|
||||
|
||||
// Now drill down to the smallest unit.
|
||||
if ( $hour_by_hour ) {
|
||||
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'HOUR', 'date_created' );
|
||||
$sql_clauses['orderby'] = 'HOUR(date_created)';
|
||||
} elseif ( $day_by_day ) {
|
||||
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'DATE', 'date_created' );
|
||||
$sql_clauses['orderby'] = 'DATE(date_created)';
|
||||
}
|
||||
$dates = Reports\get_dates_filter( 'objects' );
|
||||
$chart_dates = Reports\parse_dates_for_range( null, 'now', false );
|
||||
$column = Reports\get_taxes_excluded_filter() ? 'total - tax' : 'total';
|
||||
$currency = Reports\get_filter_value( 'currencies' );
|
||||
$period = Reports\get_graph_period();
|
||||
$sql_clauses = Reports\get_sql_clauses( $period );
|
||||
|
||||
if ( empty( $currency ) || 'convert' === $currency ) {
|
||||
$column = sprintf( '(%s) / rate', $column );
|
||||
@ -227,7 +187,7 @@ function edd_overview_refunds_chart() {
|
||||
|
||||
$results = $wpdb->get_results(
|
||||
$wpdb->prepare(
|
||||
"SELECT COUNT(id) AS number, SUM({$column}) AS amount, {$sql_clauses['select']}
|
||||
"SELECT COUNT(*) AS number, SUM({$column}) AS amount, {$sql_clauses['select']}
|
||||
FROM {$wpdb->edd_orders} edd_o
|
||||
WHERE status IN (%s, %s) AND date_created >= %s AND date_created <= %s AND type = 'refund'
|
||||
{$sql_clauses['where']}
|
||||
@ -240,7 +200,7 @@ function edd_overview_refunds_chart() {
|
||||
)
|
||||
);
|
||||
|
||||
$number = array();
|
||||
$number = array();
|
||||
$amount = array();
|
||||
|
||||
// Initialise all arrays with timestamps and set values to 0.
|
||||
@ -259,15 +219,14 @@ function edd_overview_refunds_chart() {
|
||||
$date_of_db_value = EDD()->utils->date( $result->date );
|
||||
|
||||
// Add any refunds that happened during this hour.
|
||||
if ( $hour_by_hour ) {
|
||||
$date_of_db_value = edd_get_edd_timezone_equivalent_date_from_utc( $date_of_db_value );
|
||||
if ( 'hour' === $period ) {
|
||||
// If the date of this db value matches the date on this line graph/chart, set the y axis value for the chart to the number in the DB result.
|
||||
if ( $date_of_db_value->format( 'Y-m-d H' ) === $date_on_chart->format( 'Y-m-d H' ) ) {
|
||||
$number[ $timestamp ][1] += $result->number;
|
||||
$amount[ $timestamp ][1] += abs( $result->amount );
|
||||
}
|
||||
// Add any refunds that happened during this day.
|
||||
} elseif ( $day_by_day ) {
|
||||
} elseif ( 'day' === $period ) {
|
||||
// If the date of this db value matches the date on this line graph/chart, set the y axis value for the chart to the number in the DB result.
|
||||
if ( $date_of_db_value->format( 'Y-m-d' ) === $date_on_chart->format( 'Y-m-d' ) ) {
|
||||
$number[ $timestamp ][1] += $result->number;
|
||||
@ -284,9 +243,9 @@ function edd_overview_refunds_chart() {
|
||||
}
|
||||
|
||||
// Move the chart along to the next hour/day/month to get ready for the next loop.
|
||||
if ( $hour_by_hour ) {
|
||||
if ( 'hour' === $period ) {
|
||||
$chart_dates['start']->addHour( 1 );
|
||||
} elseif ( $day_by_day ) {
|
||||
} elseif ( 'day' === $period ) {
|
||||
$chart_dates['start']->addDays( 1 );
|
||||
} else {
|
||||
$chart_dates['start']->addMonth( 1 );
|
||||
@ -297,5 +256,4 @@ function edd_overview_refunds_chart() {
|
||||
'number' => array_values( $number ),
|
||||
'amount' => array_values( $amount ),
|
||||
);
|
||||
|
||||
}
|
||||
|
@ -735,45 +735,17 @@ function edd_register_downloads_report( $reports ) {
|
||||
'data_callback' => function () use ( $download_data, $currency ) {
|
||||
global $wpdb;
|
||||
|
||||
$dates = Reports\get_dates_filter( 'objects' );
|
||||
$day_by_day = Reports\get_dates_filter_day_by_day();
|
||||
$hour_by_hour = Reports\get_dates_filter_hour_by_hour();
|
||||
$chart_dates = Reports\parse_dates_for_range( null, 'now', false );
|
||||
|
||||
$sql_clauses = array(
|
||||
'select' => 'edd_oi.date_created AS date',
|
||||
'where' => '',
|
||||
'groupby' => '',
|
||||
);
|
||||
$dates = Reports\get_dates_filter( 'objects' );
|
||||
$chart_dates = Reports\parse_dates_for_range( null, 'now', false );
|
||||
$period = Reports\get_graph_period();
|
||||
$sql_clauses = Reports\get_sql_clauses( $period, 'edd_oi.date_created' );
|
||||
|
||||
$union_clauses = array(
|
||||
'select' => 'date',
|
||||
'where' => '',
|
||||
'groupby' => '',
|
||||
'groupby' => 'date',
|
||||
'orderby' => 'date',
|
||||
);
|
||||
|
||||
// Default to 'monthly'.
|
||||
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'MONTH', 'edd_oi.date_created' );
|
||||
$sql_clauses['orderby'] = 'MONTH(edd_oi.date_created)';
|
||||
|
||||
$union_clauses['groupby'] = Reports\get_groupby_date_string( 'MONTH', 'date' );
|
||||
$union_clauses['orderby'] = 'MONTH(date)';
|
||||
|
||||
// Now drill down to the smallest unit.
|
||||
if ( $hour_by_hour ) {
|
||||
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'HOUR', 'edd_oi.date_created' );
|
||||
$sql_clauses['orderby'] = 'HOUR(edd_oi.date_created)';
|
||||
|
||||
$union_clauses['groupby'] = Reports\get_groupby_date_string( 'HOUR', 'date' );
|
||||
$union_clauses['orderby'] = 'HOUR(date)';
|
||||
} elseif ( $day_by_day ) {
|
||||
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'DATE', 'edd_oi.date_created' );
|
||||
$sql_clauses['orderby'] = 'DATE(edd_oi.date_created)';
|
||||
|
||||
$union_clauses['groupby'] = Reports\get_groupby_date_string( 'DATE', 'date' );
|
||||
$union_clauses['orderby'] = 'DATE(date)';
|
||||
}
|
||||
|
||||
$price_id = isset( $download_data['price_id'] ) && is_numeric( $download_data['price_id'] )
|
||||
? sprintf( 'AND price_id = %d', absint( $download_data['price_id'] ) )
|
||||
: '';
|
||||
@ -782,14 +754,12 @@ function edd_register_downloads_report( $reports ) {
|
||||
$earnings_status_string = implode( ', ', array_fill( 0, count( $earnings_statuses ), '%s' ) );
|
||||
|
||||
$order_item_earnings = $wpdb->prepare(
|
||||
"SELECT SUM(edd_oi.total / edd_oi.rate) AS earnings, %1s
|
||||
"SELECT SUM(edd_oi.total / edd_oi.rate) AS earnings, {$sql_clauses['select']}
|
||||
FROM {$wpdb->edd_order_items} edd_oi
|
||||
INNER JOIN {$wpdb->edd_orders} edd_o ON edd_oi.order_id = edd_o.id
|
||||
WHERE edd_oi.product_id = %d %1s AND edd_oi.date_created >= %s AND edd_oi.date_created <= %s AND edd_o.status IN ({$earnings_status_string})
|
||||
WHERE edd_oi.product_id = %d {$price_id} AND edd_oi.date_created >= %s AND edd_oi.date_created <= %s AND edd_o.status IN ({$earnings_status_string})
|
||||
GROUP BY {$sql_clauses['groupby']}",
|
||||
$sql_clauses['select'],
|
||||
$download_data['download_id'],
|
||||
$price_id,
|
||||
$dates['start']->copy()->format( 'mysql' ),
|
||||
$dates['end']->copy()->format( 'mysql' ),
|
||||
...$earnings_statuses
|
||||
@ -803,20 +773,18 @@ function edd_register_downloads_report( $reports ) {
|
||||
$adjustments_status_string = implode( ', ', array_fill( 0, count( $adjustments_statuses ), '%s' ) );
|
||||
|
||||
$order_adjustments = $wpdb->prepare(
|
||||
"SELECT SUM(edd_oa.total / edd_oa.rate) AS earnings, %1s
|
||||
"SELECT SUM(edd_oa.total / edd_oa.rate) AS earnings, {$sql_clauses['select']}
|
||||
FROM {$wpdb->edd_order_adjustments} edd_oa
|
||||
INNER JOIN {$wpdb->edd_order_items} edd_oi ON
|
||||
edd_oi.id = edd_oa.object_id
|
||||
AND edd_oi.product_id = %d
|
||||
%1s
|
||||
{$price_id}
|
||||
AND edd_oi.date_created >= %s AND edd_oi.date_created <= %s
|
||||
INNER JOIN {$wpdb->edd_orders} edd_o ON edd_oi.order_id = edd_o.id AND edd_o.type = 'sale' AND edd_o.status IN ({$adjustments_status_string})
|
||||
WHERE edd_oa.object_type = 'order_item'
|
||||
AND edd_oa.type != 'discount'
|
||||
GROUP BY {$sql_clauses['groupby']}",
|
||||
$sql_clauses['select'],
|
||||
$download_data['download_id'],
|
||||
$price_id,
|
||||
$dates['start']->copy()->format( 'mysql' ),
|
||||
$dates['end']->copy()->format( 'mysql' ),
|
||||
...$adjustments_statuses
|
||||
@ -865,16 +833,16 @@ function edd_register_downloads_report( $reports ) {
|
||||
|
||||
// Loop through each date there were sales/earnings, which we queried from the database.
|
||||
foreach ( $earnings_results as $earnings_result ) {
|
||||
$date_of_db_value = edd_get_edd_timezone_equivalent_date_from_utc( EDD()->utils->date( $earnings_result->date ) );
|
||||
$date_of_db_value = EDD()->utils->date( $earnings_result->date );
|
||||
|
||||
// Add any sales/earnings that happened during this hour.
|
||||
if ( $hour_by_hour ) {
|
||||
if ( 'hour' === $period ) {
|
||||
// If the date of this db value matches the date on this line graph/chart, set the y axis value for the chart to the number in the DB result.
|
||||
if ( $date_of_db_value->format( 'Y-m-d H' ) === $date_on_chart->format( 'Y-m-d H' ) ) {
|
||||
$earnings[ $timestamp ][1] += $earnings_result->earnings;
|
||||
}
|
||||
// Add any sales/earnings that happened during this day.
|
||||
} elseif ( $day_by_day ) {
|
||||
} elseif ( 'day' === $period ) {
|
||||
// If the date of this db value matches the date on this line graph/chart, set the y axis value for the chart to the number in the DB result.
|
||||
if ( $date_of_db_value->format( 'Y-m-d' ) === $date_on_chart->format( 'Y-m-d' ) ) {
|
||||
$earnings[ $timestamp ][1] += $earnings_result->earnings;
|
||||
@ -890,16 +858,16 @@ function edd_register_downloads_report( $reports ) {
|
||||
|
||||
// Loop through each date there were sales/earnings, which we queried from the database.
|
||||
foreach ( $sales_results as $sales_result ) {
|
||||
$date_of_db_value = edd_get_edd_timezone_equivalent_date_from_utc( EDD()->utils->date( $sales_result->date ) );
|
||||
$date_of_db_value = EDD()->utils->date( $sales_result->date );
|
||||
|
||||
// Add any sales/earnings that happened during this hour.
|
||||
if ( $hour_by_hour ) {
|
||||
if ( 'hour' === $period ) {
|
||||
// If the date of this db value matches the date on this line graph/chart, set the y axis value for the chart to the number in the DB result.
|
||||
if ( $date_of_db_value->format( 'Y-m-d H' ) === $date_on_chart->format( 'Y-m-d H' ) ) {
|
||||
$sales[ $timestamp ][1] += $sales_result->sales;
|
||||
}
|
||||
// Add any sales/earnings that happened during this day.
|
||||
} elseif ( $day_by_day ) {
|
||||
} elseif ( 'day' === $period ) {
|
||||
// If the date of this db value matches the date on this line graph/chart, set the y axis value for the chart to the number in the DB result.
|
||||
if ( $date_of_db_value->format( 'Y-m-d' ) === $date_on_chart->format( 'Y-m-d' ) ) {
|
||||
$sales[ $timestamp ][1] += $sales_result->sales;
|
||||
@ -914,9 +882,9 @@ function edd_register_downloads_report( $reports ) {
|
||||
}
|
||||
|
||||
// Move the chart along to the next hour/day/month to get ready for the next loop.
|
||||
if ( $hour_by_hour ) {
|
||||
if ( 'hour' === $period ) {
|
||||
$chart_dates['start']->addHour( 1 );
|
||||
} elseif ( $day_by_day ) {
|
||||
} elseif ( 'day' === $period ) {
|
||||
$chart_dates['start']->addDays( 1 );
|
||||
} else {
|
||||
$chart_dates['start']->addMonth( 1 );
|
||||
@ -1562,27 +1530,9 @@ function edd_register_payment_gateways_report( $reports ) {
|
||||
global $wpdb;
|
||||
|
||||
$dates = Reports\get_dates_filter( 'objects' );
|
||||
$day_by_day = Reports\get_dates_filter_day_by_day();
|
||||
$hour_by_hour = Reports\get_dates_filter_hour_by_hour();
|
||||
$chart_dates = Reports\parse_dates_for_range( null, 'now', false );
|
||||
|
||||
$sql_clauses = array(
|
||||
'select' => 'date_created AS date',
|
||||
'where' => '',
|
||||
);
|
||||
|
||||
// Default to 'monthly'.
|
||||
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'MONTH', 'date_created' );
|
||||
$sql_clauses['orderby'] = 'MONTH(date_created)';
|
||||
|
||||
// Now drill down to the smallest unit.
|
||||
if ( $hour_by_hour ) {
|
||||
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'HOUR', 'date_created' );
|
||||
$sql_clauses['orderby'] = 'HOUR(date_created)';
|
||||
} elseif ( $day_by_day ) {
|
||||
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'DATE', 'date_created' );
|
||||
$sql_clauses['orderby'] = 'DATE(date_created)';
|
||||
}
|
||||
$period = Reports\get_graph_period();
|
||||
$sql_clauses = Reports\get_sql_clauses( $period, 'date_created' );
|
||||
|
||||
$gateway = Reports\get_filter_value( 'gateways' );
|
||||
$column = $exclude_taxes
|
||||
@ -1605,7 +1555,7 @@ function edd_register_payment_gateways_report( $reports ) {
|
||||
ORDER BY {$sql_clauses['orderby']} ASC",
|
||||
esc_sql( $gateway ), $dates['start']->copy()->format( 'mysql' ), $dates['end']->copy()->format( 'mysql' ) ) );
|
||||
|
||||
$sales = array();
|
||||
$sales = array();
|
||||
$earnings = array();
|
||||
|
||||
/**
|
||||
@ -1625,17 +1575,17 @@ function edd_register_payment_gateways_report( $reports ) {
|
||||
|
||||
// Loop through each date there were sales/earnings, which we queried from the database.
|
||||
foreach ( $results as $result ) {
|
||||
$date_of_db_value = edd_get_edd_timezone_equivalent_date_from_utc( EDD()->utils->date( $result->date ) );
|
||||
$date_of_db_value = EDD()->utils->date( $result->date );
|
||||
|
||||
// Add any sales/earnings that happened during this hour.
|
||||
if ( $hour_by_hour ) {
|
||||
if ( 'hour' === $period ) {
|
||||
// If the date of this db value matches the date on this line graph/chart, set the y axis value for the chart to the number in the DB result.
|
||||
if ( $date_of_db_value->format( 'Y-m-d H' ) === $date_on_chart->format( 'Y-m-d H' ) ) {
|
||||
$sales[ $timestamp ][1] += $result->sales;
|
||||
$earnings[ $timestamp ][1] += $result->earnings;
|
||||
}
|
||||
// Add any sales/earnings that happened during this day.
|
||||
} elseif ( $day_by_day ) {
|
||||
} elseif ( 'day' === $period ) {
|
||||
// If the date of this db value matches the date on this line graph/chart, set the y axis value for the chart to the number in the DB result.
|
||||
if ( $date_of_db_value->format( 'Y-m-d' ) === $date_on_chart->format( 'Y-m-d' ) ) {
|
||||
$sales[ $timestamp ][1] += $result->sales;
|
||||
@ -1652,9 +1602,9 @@ function edd_register_payment_gateways_report( $reports ) {
|
||||
}
|
||||
|
||||
// Move the chart along to the next hour/day/month to get ready for the next loop.
|
||||
if ( $hour_by_hour ) {
|
||||
if ( 'hour' === $period ) {
|
||||
$chart_dates['start']->addHour( 1 );
|
||||
} elseif ( $day_by_day ) {
|
||||
} elseif ( 'day' === $period ) {
|
||||
$chart_dates['start']->addDays( 1 );
|
||||
} else {
|
||||
$chart_dates['start']->addMonth( 1 );
|
||||
@ -2060,29 +2010,10 @@ function edd_register_file_downloads_report( $reports ) {
|
||||
'data_callback' => function () use ( $filter, $download_data ) {
|
||||
global $wpdb;
|
||||
|
||||
$dates = Reports\get_dates_filter( 'objects' );
|
||||
$chart_dates = Reports\parse_dates_for_range( null, 'now', false );
|
||||
$day_by_day = Reports\get_dates_filter_day_by_day();
|
||||
$hour_by_hour = Reports\get_dates_filter_hour_by_hour();
|
||||
|
||||
$sql_clauses = array(
|
||||
'select' => 'date_created AS date',
|
||||
'where' => '',
|
||||
'groupby' => '',
|
||||
);
|
||||
|
||||
// Default to 'monthly'.
|
||||
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'MONTH', 'date_created' );
|
||||
$sql_clauses['orderby'] = 'MONTH(date_created)';
|
||||
|
||||
// Now drill down to the smallest unit.
|
||||
if ( $hour_by_hour ) {
|
||||
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'HOUR', 'date_created' );
|
||||
$sql_clauses['orderby'] = 'HOUR(date_created)';
|
||||
} elseif ( $day_by_day ) {
|
||||
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'DATE', 'date_created' );
|
||||
$sql_clauses['orderby'] = 'DATE(date_created)';
|
||||
}
|
||||
$dates = Reports\get_dates_filter( 'objects' );
|
||||
$chart_dates = Reports\parse_dates_for_range( null, 'now', false );
|
||||
$period = Reports\get_graph_period();
|
||||
$sql_clauses = Reports\get_sql_clauses( $period );
|
||||
|
||||
$product_id = '';
|
||||
$price_id = '';
|
||||
@ -2114,16 +2045,16 @@ function edd_register_file_downloads_report( $reports ) {
|
||||
$file_downloads[ $timestamp ][1] = 0;
|
||||
|
||||
foreach ( $results as $result ) {
|
||||
$date_of_db_value = edd_get_edd_timezone_equivalent_date_from_utc( EDD()->utils->date( $result->date ) );
|
||||
$date_of_db_value = EDD()->utils->date( $result->date );
|
||||
|
||||
// Add any file downloads that happened during this hour.
|
||||
if ( $hour_by_hour ) {
|
||||
if ( 'hour' === $period ) {
|
||||
// If the date of this db value matches the date on this line graph/chart, set the y axis value for the chart to the number in the DB result.
|
||||
if ( $date_of_db_value->format( 'Y-m-d H' ) === $date_on_chart->format( 'Y-m-d H' ) ) {
|
||||
$file_downloads[ $timestamp ][1] += absint( $result->total );
|
||||
}
|
||||
// Add any file downloads that happened during this day.
|
||||
} elseif ( $day_by_day ) {
|
||||
} elseif ( 'day' === $period ) {
|
||||
// If the date of this db value matches the date on this line graph/chart, set the y axis value for the chart to the number in the DB result.
|
||||
if ( $date_of_db_value->format( 'Y-m-d' ) === $date_on_chart->format( 'Y-m-d' ) ) {
|
||||
$file_downloads[ $timestamp ][1] += absint( $result->total );
|
||||
@ -2138,9 +2069,9 @@ function edd_register_file_downloads_report( $reports ) {
|
||||
}
|
||||
|
||||
// Move the chart along to the next hour/day/month to get ready for the next loop.
|
||||
if ( $hour_by_hour ) {
|
||||
if ( 'hour' === $period ) {
|
||||
$chart_dates['start']->addHour( 1 );
|
||||
} elseif ( $day_by_day ) {
|
||||
} elseif ( 'day' === $period ) {
|
||||
$chart_dates['start']->addDays( 1 );
|
||||
} else {
|
||||
$chart_dates['start']->addMonth( 1 );
|
||||
@ -2400,28 +2331,9 @@ function edd_register_discounts_report( $reports ) {
|
||||
global $wpdb;
|
||||
|
||||
$dates = Reports\get_dates_filter( 'objects' );
|
||||
$day_by_day = Reports\get_dates_filter_day_by_day();
|
||||
$hour_by_hour = Reports\get_dates_filter_hour_by_hour();
|
||||
$chart_dates = Reports\parse_dates_for_range( null, 'now', false );
|
||||
|
||||
|
||||
$sql_clauses = array(
|
||||
'select' => 'edd_oa.date_created AS date',
|
||||
'where' => '',
|
||||
);
|
||||
|
||||
// Default to 'monthly'.
|
||||
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'MONTH', 'edd_oa.date_created' );
|
||||
$sql_clauses['orderby'] = 'MONTH(edd_oa.date_created)';
|
||||
|
||||
// Now drill down to the smallest unit.
|
||||
if ( $hour_by_hour ) {
|
||||
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'HOUR', 'edd_oa.date_created' );
|
||||
$sql_clauses['orderby'] = 'HOUR(edd_oa.date_created)';
|
||||
} elseif ( $day_by_day ) {
|
||||
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'DATE', 'edd_oa.date_created' );
|
||||
$sql_clauses['orderby'] = 'DATE(edd_oa.date_created)';
|
||||
}
|
||||
$period = Reports\get_graph_period();
|
||||
$sql_clauses = Reports\get_sql_clauses( $period, 'edd_oa.date_created' );
|
||||
|
||||
$discount_code = ! empty( $d->code )
|
||||
? $wpdb->prepare( 'AND type = %s AND description = %s', 'discount', esc_sql( $d->code ) )
|
||||
@ -2447,16 +2359,16 @@ function edd_register_discounts_report( $reports ) {
|
||||
|
||||
// Loop through each date in which there were discount codes used, which we queried from the database.
|
||||
foreach ( $results as $result ) {
|
||||
$date_of_db_value = edd_get_edd_timezone_equivalent_date_from_utc( EDD()->utils->date( $result->date ) );
|
||||
$date_of_db_value = EDD()->utils->date( $result->date );
|
||||
|
||||
// Add any discount codes that were used during this hour.
|
||||
if ( $hour_by_hour ) {
|
||||
if ( 'hour' === $period ) {
|
||||
// If the date of this db value matches the date on this line graph/chart, set the y axis value for the chart to the number in the DB result.
|
||||
if ( $date_of_db_value->format( 'Y-m-d H' ) === $date_on_chart->format( 'Y-m-d H' ) ) {
|
||||
$discount_usage[ $timestamp ][1] += abs( $result->total );
|
||||
}
|
||||
// Add any discount codes that were used during this day.
|
||||
} elseif ( $day_by_day ) {
|
||||
} elseif ( 'day' === $period ) {
|
||||
// If the date of this db value matches the date on this line graph/chart, set the y axis value for the chart to the number in the DB result.
|
||||
if ( $date_of_db_value->format( 'Y-m-d' ) === $date_on_chart->format( 'Y-m-d' ) ) {
|
||||
$discount_usage[ $timestamp ][1] += abs( $result->total );
|
||||
@ -2471,9 +2383,9 @@ function edd_register_discounts_report( $reports ) {
|
||||
}
|
||||
|
||||
// Move the chart along to the next hour/day/month to get ready for the next loop.
|
||||
if ( $hour_by_hour ) {
|
||||
if ( 'hour' === $period ) {
|
||||
$chart_dates['start']->addHour( 1 );
|
||||
} elseif ( $day_by_day ) {
|
||||
} elseif ( 'day' === $period ) {
|
||||
$chart_dates['start']->addDays( 1 );
|
||||
} else {
|
||||
$chart_dates['start']->addMonth( 1 );
|
||||
@ -2645,23 +2557,9 @@ function edd_register_customer_report( $reports ) {
|
||||
global $wpdb;
|
||||
|
||||
$dates = Reports\get_dates_filter( 'objects' );
|
||||
$day_by_day = Reports\get_dates_filter_day_by_day();
|
||||
$hour_by_hour = Reports\get_dates_filter_hour_by_hour();
|
||||
$chart_dates = Reports\parse_dates_for_range( null, 'now', false );
|
||||
|
||||
$sql_clauses = array(
|
||||
'select' => 'date_created AS date',
|
||||
'groupby' => Reports\get_groupby_date_string( 'MONTH', 'date_created' ),
|
||||
'orderby' => 'MONTH(date_created)',
|
||||
);
|
||||
|
||||
if ( $hour_by_hour ) {
|
||||
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'HOUR', 'date_created' );
|
||||
$sql_clauses['orderby'] = 'HOUR(date_created)';
|
||||
} elseif ( $day_by_day ) {
|
||||
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'DATE', 'date_created' );
|
||||
$sql_clauses['orderby'] = 'DATE(date_created)';
|
||||
}
|
||||
$period = Reports\get_graph_period();
|
||||
$sql_clauses = Reports\get_sql_clauses( $period );
|
||||
|
||||
$results = $wpdb->get_results( $wpdb->prepare(
|
||||
"SELECT COUNT(c.id) AS total, {$sql_clauses['select']}
|
||||
@ -2684,16 +2582,16 @@ function edd_register_customer_report( $reports ) {
|
||||
$customers[ $timestamp ][1] = 0;
|
||||
|
||||
foreach ( $results as $result ) {
|
||||
$date_of_db_value = edd_get_edd_timezone_equivalent_date_from_utc( EDD()->utils->date( $result->date ) );
|
||||
$date_of_db_value = EDD()->utils->date( $result->date );
|
||||
|
||||
// Add any new customers that were created during this hour.
|
||||
if ( $hour_by_hour ) {
|
||||
if ( 'hour' === $period ) {
|
||||
// If the date of this db value matches the date on this line graph/chart, set the y axis value for the chart to the number in the DB result.
|
||||
if ( $date_of_db_value->format( 'Y-m-d H' ) === $date_on_chart->format( 'Y-m-d H' ) ) {
|
||||
$customers[ $timestamp ][1] += $result->total;
|
||||
}
|
||||
// Add any new customers that were created during this day.
|
||||
} elseif ( $day_by_day ) {
|
||||
} elseif ( 'day' === $period ) {
|
||||
// If the date of this db value matches the date on this line graph/chart, set the y axis value for the chart to the number in the DB result.
|
||||
if ( $date_of_db_value->format( 'Y-m-d' ) === $date_on_chart->format( 'Y-m-d' ) ) {
|
||||
$customers[ $timestamp ][1] += $result->total;
|
||||
@ -2708,9 +2606,9 @@ function edd_register_customer_report( $reports ) {
|
||||
}
|
||||
|
||||
// Move the chart along to the next hour/day/month to get ready for the next loop.
|
||||
if ( $hour_by_hour ) {
|
||||
if ( 'hour' === $period ) {
|
||||
$chart_dates['start']->addHour( 1 );
|
||||
} elseif ( $day_by_day ) {
|
||||
} elseif ( 'day' === $period ) {
|
||||
$chart_dates['start']->addDays( 1 );
|
||||
} else {
|
||||
$chart_dates['start']->addMonth( 1 );
|
||||
|
@ -399,3 +399,43 @@ function edd_tax_settings_display_tax_disabled_notice() {
|
||||
|
||||
}
|
||||
add_action( 'edd_settings_tab_top_taxes_rates', 'edd_tax_settings_display_tax_disabled_notice', 10 );
|
||||
|
||||
/**
|
||||
* Display help text at the top of the Licenses tab.
|
||||
*
|
||||
* @since 3.1.1.4
|
||||
* @return void
|
||||
*/
|
||||
function edd_license_settings_help_text() {
|
||||
?>
|
||||
<div class="edd-licenses__description">
|
||||
<p>
|
||||
<?php esc_html_e( 'Manage extensions for Easy Digital Downloads which are not included with a pass. Having an active license for your extensions gives you access to updates when they\'re available.', 'easy-digital-downloads' ); ?>
|
||||
</p>
|
||||
<?php
|
||||
$pass_manager = new \EDD\Admin\Pass_Manager();
|
||||
if ( ! $pass_manager->highest_license_key ) :
|
||||
?>
|
||||
<p>
|
||||
<?php
|
||||
$url = edd_get_admin_url(
|
||||
array(
|
||||
'page' => 'edd-settings',
|
||||
'tab' => 'general',
|
||||
)
|
||||
);
|
||||
printf(
|
||||
wp_kses_post(
|
||||
/* translators: 1. opening anchor tag; 2. closing anchor tag */
|
||||
__( 'Have a pass? You\'re ready to set up EDD (Pro). %1$sActivate Your Pass%2$s' )
|
||||
),
|
||||
'<a href="' . esc_url( $url ) . '" class="button button-primary">',
|
||||
'</a>'
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
add_action( 'edd_settings_tab_top_licenses_main', 'edd_license_settings_help_text' );
|
||||
|
Reference in New Issue
Block a user