diff --git a/includes/admin/reports/class-wc-report-sales-by-date.php b/includes/admin/reports/class-wc-report-sales-by-date.php
index ed962614fd0..f0de521fd9e 100644
--- a/includes/admin/reports/class-wc-report-sales-by-date.php
+++ b/includes/admin/reports/class-wc-report-sales-by-date.php
@@ -1,16 +1,17 @@
report_data->order_items = (array) $this->get_order_report_data(
array(
'data' => array(
@@ -412,11 +413,11 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
$this->report_data->total_sales = wc_format_decimal( array_sum( wp_list_pluck( $this->report_data->orders, 'total_sales' ) ) - $this->report_data->total_refunds, 2 );
$this->report_data->net_sales = wc_format_decimal( $this->report_data->total_sales - $this->report_data->total_shipping - max( 0, $this->report_data->total_tax ) - max( 0, $this->report_data->total_shipping_tax ), 2 );
- // Calculate average based on net
+ // Calculate average based on net.
$this->report_data->average_sales = wc_format_decimal( $this->report_data->net_sales / ( $this->chart_interval + 1 ), 2 );
$this->report_data->average_total_sales = wc_format_decimal( $this->report_data->total_sales / ( $this->chart_interval + 1 ), 2 );
- // Total orders and discounts also includes those which have been refunded at some point
+ // Total orders and discounts also includes those which have been refunded at some point.
$this->report_data->total_coupons = number_format( array_sum( wp_list_pluck( $this->report_data->coupons, 'discount_amount' ) ), 2, '.', '' );
$this->report_data->total_refunded_orders = absint( count( $this->report_data->full_refunds ) );
@@ -441,26 +442,26 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
switch ( $this->chart_groupby ) {
case 'day':
- /* translators: %s: average total sales */
$average_total_sales_title = sprintf(
+ /* translators: %s: average total sales */
__( '%s average gross daily sales', 'woocommerce' ),
'' . wc_price( $data->average_total_sales ) . ''
);
- /* translators: %s: average sales */
$average_sales_title = sprintf(
+ /* translators: %s: average sales */
__( '%s average net daily sales', 'woocommerce' ),
'' . wc_price( $data->average_sales ) . ''
);
break;
case 'month':
default:
- /* translators: %s: average total sales */
$average_total_sales_title = sprintf(
+ /* translators: %s: average total sales */
__( '%s average gross monthly sales', 'woocommerce' ),
'' . wc_price( $data->average_total_sales ) . ''
);
- /* translators: %s: average sales */
$average_sales_title = sprintf(
+ /* translators: %s: average sales */
__( '%s average net monthly sales', 'woocommerce' ),
'' . wc_price( $data->average_sales ) . ''
);
@@ -468,8 +469,8 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
}
$legend[] = array(
- /* translators: %s: total sales */
'title' => sprintf(
+ /* translators: %s: total sales */
__( '%s gross sales in this period', 'woocommerce' ),
'' . wc_price( $data->total_sales ) . ''
),
@@ -486,8 +487,8 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
}
$legend[] = array(
- /* translators: %s: net sales */
'title' => sprintf(
+ /* translators: %s: net sales */
__( '%s net sales in this period', 'woocommerce' ),
'' . wc_price( $data->net_sales ) . ''
),
@@ -504,8 +505,8 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
}
$legend[] = array(
- /* translators: %s: total orders */
'title' => sprintf(
+ /* translators: %s: total orders */
__( '%s orders placed', 'woocommerce' ),
'' . $data->total_orders . ''
),
@@ -514,8 +515,8 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
);
$legend[] = array(
- /* translators: %s: total items */
'title' => sprintf(
+ /* translators: %s: total items */
__( '%s items purchased', 'woocommerce' ),
'' . $data->total_items . ''
),
@@ -523,8 +524,8 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
'highlight_series' => 0,
);
$legend[] = array(
- /* translators: 1: total refunds 2: total refunded orders 3: refunded items */
'title' => sprintf(
+ /* translators: 1: total refunds 2: total refunded orders 3: refunded items */
_n( '%1$s refunded %2$d order (%3$d item)', '%1$s refunded %2$d orders (%3$d items)', $this->report_data->total_refunded_orders, 'woocommerce' ),
'' . wc_price( $data->total_refunds ) . '',
$this->report_data->total_refunded_orders,
@@ -534,8 +535,8 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
'highlight_series' => 8,
);
$legend[] = array(
- /* translators: %s: total shipping */
'title' => sprintf(
+ /* translators: %s: total shipping */
__( '%s charged for shipping', 'woocommerce' ),
'' . wc_price( $data->total_shipping ) . ''
),
@@ -543,8 +544,8 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
'highlight_series' => 5,
);
$legend[] = array(
- /* translators: %s: total coupons */
'title' => sprintf(
+ /* translators: %s: total coupons */
__( '%s worth of coupons used', 'woocommerce' ),
'' . wc_price( $data->total_coupons ) . ''
),
@@ -578,9 +579,9 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
'refund_amount' => '#e74c3c',
);
- $current_range = ! empty( $_GET['range'] ) ? sanitize_text_field( $_GET['range'] ) : '7day';
+ $current_range = ! empty( $_GET['range'] ) ? sanitize_text_field( wp_unslash( $_GET['range'] ) ) : '7day'; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.NonceVerification.NoNonceVerification
- if ( ! in_array( $current_range, array( 'custom', 'year', 'last_month', 'month', '7day' ) ) ) {
+ if ( ! in_array( $current_range, array( 'custom', 'year', 'last_month', 'month', '7day' ), true ) ) {
$current_range = '7day';
}
@@ -594,18 +595,18 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
* Output an export link.
*/
public function get_export_button() {
- $current_range = ! empty( $_GET['range'] ) ? sanitize_text_field( $_GET['range'] ) : '7day';
+ $current_range = ! empty( $_GET['range'] ) ? sanitize_text_field( wp_unslash( $_GET['range'] ) ) : '7day'; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.NonceVerification.NoNonceVerification
?>
-
+
$this->prepare_chart_data( $this->report_data->order_counts, 'post_date', 'count', $this->chart_interval, $this->start_date, $this->chart_groupby ),
'order_item_counts' => $this->prepare_chart_data( $this->report_data->order_items, 'post_date', 'order_item_count', $this->chart_interval, $this->start_date, $this->chart_groupby ),
@@ -650,7 +651,7 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
$data['gross_order_amounts'][ $order_amount_key ][1] -= $data['refund_amounts'][ $order_amount_key ][1];
$data['net_order_amounts'][ $order_amount_key ] = $order_amount_value;
- // subtract the sum of the values from net order amounts
+ // Subtract the sum of the values from net order amounts.
$data['net_order_amounts'][ $order_amount_key ][1] -=
$data['refund_amounts'][ $order_amount_key ][1] +
$data['shipping_amounts'][ $order_amount_key ][1] +
@@ -658,11 +659,11 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
$data['tax_amounts'][ $order_amount_key ][1];
}
- // 3rd party filtering of report data
+ // 3rd party filtering of report data.
$data = apply_filters( 'woocommerce_admin_report_chart_data', $data );
- // Encode in json format
- $chart_data = json_encode(
+ // Encode in json format.
+ $chart_data = wp_json_encode(
array(
'order_counts' => array_values( $data['order_counts'] ),
'order_item_counts' => array_values( $data['order_item_counts'] ),
@@ -683,30 +684,30 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
var main_chart;
jQuery(function(){
- var order_data = jQuery.parseJSON( '' );
+ var order_data = jQuery.parseJSON( '' );
var drawGraph = function( highlight ) {
var series = [
{
label: "",
data: order_data.order_item_counts,
- color: 'chart_colours['item_count']; ?>',
- bars: { fillColor: 'chart_colours['item_count']; ?>', fill: true, show: true, lineWidth: 0, barWidth: barwidth; ?> * 0.5, align: 'center' },
+ color: 'chart_colours['item_count'] ); ?>',
+ bars: { fillColor: 'chart_colours['item_count'] ); ?>', fill: true, show: true, lineWidth: 0, barWidth: barwidth ); ?> * 0.5, align: 'center' },
shadowSize: 0,
hoverable: false
},
{
label: "",
data: order_data.order_counts,
- color: 'chart_colours['order_count']; ?>',
- bars: { fillColor: 'chart_colours['order_count']; ?>', fill: true, show: true, lineWidth: 0, barWidth: barwidth; ?> * 0.5, align: 'center' },
+ color: 'chart_colours['order_count'] ); ?>',
+ bars: { fillColor: 'chart_colours['order_count'] ); ?>', fill: true, show: true, lineWidth: 0, barWidth: barwidth ); ?> * 0.5, align: 'center' },
shadowSize: 0,
hoverable: false
},
{
label: "",
- data: [ [ , report_data->average_total_sales; ?> ], [ , report_data->average_total_sales; ?> ] ],
+ data: [ [ , report_data->average_total_sales ); ?> ], [ , report_data->average_total_sales ); ?> ] ],
yaxis: 2,
- color: 'chart_colours['average']; ?>',
+ color: 'chart_colours['average'] ); ?>',
points: { show: false },
lines: { show: true, lineWidth: 2, fill: false },
shadowSize: 0,
@@ -714,9 +715,9 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
},
{
label: "",
- data: [ [ , report_data->average_sales; ?> ], [ , report_data->average_sales; ?> ] ],
+ data: [ [ , report_data->average_sales ); ?> ], [ , report_data->average_sales ); ?> ] ],
yaxis: 2,
- color: 'chart_colours['net_average']; ?>',
+ color: 'chart_colours['net_average'] ); ?>',
points: { show: false },
lines: { show: true, lineWidth: 2, fill: false },
shadowSize: 0,
@@ -726,51 +727,51 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
label: "",
data: order_data.coupon_amounts,
yaxis: 2,
- color: 'chart_colours['coupon_amount']; ?>',
+ color: 'chart_colours['coupon_amount'] ); ?>',
points: { show: true, radius: 5, lineWidth: 2, fillColor: '#fff', fill: true },
lines: { show: true, lineWidth: 2, fill: false },
shadowSize: 0,
- get_currency_tooltip(); ?>
+ get_currency_tooltip(); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped ?>
},
{
label: "",
data: order_data.shipping_amounts,
yaxis: 2,
- color: 'chart_colours['shipping_amount']; ?>',
+ color: 'chart_colours['shipping_amount'] ); ?>',
points: { show: true, radius: 5, lineWidth: 2, fillColor: '#fff', fill: true },
lines: { show: true, lineWidth: 2, fill: false },
shadowSize: 0,
- prepend_tooltip: ""
+ prepend_tooltip: ""
},
{
label: "",
data: order_data.gross_order_amounts,
yaxis: 2,
- color: 'chart_colours['sales_amount']; ?>',
+ color: 'chart_colours['sales_amount'] ); ?>',
points: { show: true, radius: 5, lineWidth: 2, fillColor: '#fff', fill: true },
lines: { show: true, lineWidth: 2, fill: false },
shadowSize: 0,
- get_currency_tooltip(); ?>
+ get_currency_tooltip(); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped ?>
},
{
label: "",
data: order_data.net_order_amounts,
yaxis: 2,
- color: 'chart_colours['net_sales_amount']; ?>',
+ color: 'chart_colours['net_sales_amount'] ); ?>',
points: { show: true, radius: 6, lineWidth: 4, fillColor: '#fff', fill: true },
lines: { show: true, lineWidth: 5, fill: false },
shadowSize: 0,
- get_currency_tooltip(); ?>
+ get_currency_tooltip(); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped ?>
},
{
label: "",
data: order_data.refund_amounts,
yaxis: 2,
- color: 'chart_colours['refund_amount']; ?>',
+ color: 'chart_colours['refund_amount'] ); ?>',
points: { show: true, radius: 5, lineWidth: 2, fillColor: '#fff', fill: true },
lines: { show: true, lineWidth: 2, fill: false },
shadowSize: 0,
- prepend_tooltip: ""
+ prepend_tooltip: ""
},
];
@@ -807,9 +808,9 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
tickColor: 'transparent',
mode: "time",
timeformat: "chart_groupby ) ? '%d %b' : '%b'; ?>",
- monthNames: month_abbrev ) ); ?>,
+ monthNames: month_abbrev ) ); ?>,
tickLength: 1,
- minTickSize: [1, "chart_groupby; ?>"],
+ minTickSize: [1, "chart_groupby ); ?>"],
font: {
color: "#aaa"
}