phpcs sniff fixes for class-wc-report-sales-by-product.php

This commit is contained in:
Ron Rennick 2019-01-27 19:27:30 -04:00
parent f42c42066b
commit a93418b826
1 changed files with 16 additions and 16 deletions

View File

@ -12,8 +12,6 @@ if ( ! defined( 'ABSPATH' ) ) {
/** /**
* WC_Report_Sales_By_Product * WC_Report_Sales_By_Product
* *
* @author WooThemes
* @category Admin
* @package WooCommerce/Admin/Reports * @package WooCommerce/Admin/Reports
* @version 2.1.0 * @version 2.1.0
*/ */
@ -44,11 +42,13 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
* Constructor. * Constructor.
*/ */
public function __construct() { public function __construct() {
// @codingStandardsIgnoreStart
if ( isset( $_GET['product_ids'] ) && is_array( $_GET['product_ids'] ) ) { if ( isset( $_GET['product_ids'] ) && is_array( $_GET['product_ids'] ) ) {
$this->product_ids = array_filter( array_map( 'absint', $_GET['product_ids'] ) ); $this->product_ids = array_filter( array_map( 'absint', $_GET['product_ids'] ) );
} elseif ( isset( $_GET['product_ids'] ) ) { } elseif ( isset( $_GET['product_ids'] ) ) {
$this->product_ids = array_filter( array( absint( $_GET['product_ids'] ) ) ); $this->product_ids = array_filter( array( absint( $_GET['product_ids'] ) ) );
} }
// @codingStandardsIgnoreEnd
} }
/** /**
@ -78,8 +78,8 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
'relation' => 'OR', 'relation' => 'OR',
array( array(
'type' => 'order_item_meta', 'type' => 'order_item_meta',
'meta_key' => array( '_product_id', '_variation_id' ), 'meta_key' => array( '_product_id', '_variation_id' ), // phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_key
'meta_value' => $this->product_ids, 'meta_value' => $this->product_ids, // phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_value
'operator' => 'IN', 'operator' => 'IN',
), ),
), ),
@ -103,8 +103,8 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
'relation' => 'OR', 'relation' => 'OR',
array( array(
'type' => 'order_item_meta', 'type' => 'order_item_meta',
'meta_key' => array( '_product_id', '_variation_id' ), 'meta_key' => array( '_product_id', '_variation_id' ), // phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_key
'meta_value' => $this->product_ids, 'meta_value' => $this->product_ids, // phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_value
'operator' => 'IN', 'operator' => 'IN',
), ),
), ),
@ -148,9 +148,9 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
'item_count' => '#d4d9dc', 'item_count' => '#d4d9dc',
); );
$current_range = ! empty( $_GET['range'] ) ? sanitize_text_field( wp_unslash( $_GET['range'] ) ) : '7day'; $current_range = ! empty( $_GET['range'] ) ? sanitize_text_field( wp_unslash( $_GET['range'] ) ) : '7day'; //phpcs:ignore 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'; $current_range = '7day';
} }
@ -297,8 +297,8 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
'where_meta' => array( 'where_meta' => array(
array( array(
'type' => 'order_item_meta', 'type' => 'order_item_meta',
'meta_key' => '_line_subtotal', 'meta_key' => '_line_subtotal', // phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_key
'meta_value' => '0', 'meta_value' => '0', // phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_value
'operator' => '=', 'operator' => '=',
), ),
), ),
@ -398,7 +398,7 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
*/ */
public function get_export_button() { public function get_export_button() {
$current_range = ! empty( $_GET['range'] ) ? sanitize_text_field( wp_unslash( $_GET['range'] ) ) : '7day'; $current_range = ! empty( $_GET['range'] ) ? sanitize_text_field( wp_unslash( $_GET['range'] ) ) : '7day'; //phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification
?> ?>
<a <a
href="#" href="#"
@ -452,8 +452,8 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
'relation' => 'OR', 'relation' => 'OR',
array( array(
'type' => 'order_item_meta', 'type' => 'order_item_meta',
'meta_key' => array( '_product_id', '_variation_id' ), 'meta_key' => array( '_product_id', '_variation_id' ), // phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_key
'meta_value' => $this->product_ids, 'meta_value' => $this->product_ids, // phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_value
'operator' => 'IN', 'operator' => 'IN',
), ),
), ),
@ -489,8 +489,8 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
'relation' => 'OR', 'relation' => 'OR',
array( array(
'type' => 'order_item_meta', 'type' => 'order_item_meta',
'meta_key' => array( '_product_id', '_variation_id' ), 'meta_key' => array( '_product_id', '_variation_id' ), // phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_key
'meta_value' => $this->product_ids, 'meta_value' => $this->product_ids, // phpcs:ignore WordPress.VIP.SlowDBQuery.slow_db_query_meta_value
'operator' => 'IN', 'operator' => 'IN',
), ),
), ),
@ -506,7 +506,7 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
$order_item_amounts = $this->prepare_chart_data( $order_item_amounts, 'post_date', 'order_item_amount', $this->chart_interval, $this->start_date, $this->chart_groupby ); $order_item_amounts = $this->prepare_chart_data( $order_item_amounts, 'post_date', 'order_item_amount', $this->chart_interval, $this->start_date, $this->chart_groupby );
// Encode in json format. // Encode in json format.
$chart_data = json_encode( $chart_data = wp_json_encode(
array( array(
'order_item_counts' => array_values( $order_item_counts ), 'order_item_counts' => array_values( $order_item_counts ),
'order_item_amounts' => array_values( $order_item_amounts ), 'order_item_amounts' => array_values( $order_item_amounts ),