@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined( 'ABSPATH' ) ) { exit; |
|
1 | +<?php if (!defined('ABSPATH')) { exit; |
|
2 | 2 | } |
3 | 3 | |
4 | 4 | class wps_statistics_ctr { |
@@ -9,14 +9,14 @@ discard block |
||
9 | 9 | function __construct() { |
10 | 10 | |
11 | 11 | // End if(). |
12 | - add_action( 'admin_menu', array( &$this, 'register_stats_menu' ), 250 ); |
|
13 | - add_action( 'save_post', array( &$this, 'wps_statistics_save_customer_infos' ), 10, 2 ); |
|
14 | - add_action( 'post_submitbox_misc_actions', array( $this, 'wps_statistics_meta_box_content' ) ); |
|
12 | + add_action('admin_menu', array(&$this, 'register_stats_menu'), 250); |
|
13 | + add_action('save_post', array(&$this, 'wps_statistics_save_customer_infos'), 10, 2); |
|
14 | + add_action('post_submitbox_misc_actions', array($this, 'wps_statistics_meta_box_content')); |
|
15 | 15 | |
16 | 16 | // Add Javascript Files & CSS File in admin |
17 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts' ) ); |
|
17 | + add_action('admin_enqueue_scripts', array($this, 'add_scripts')); |
|
18 | 18 | |
19 | - add_action( 'wp_ajax_wps_statistics_custom_date_view', array( $this, 'wps_statistics_custom_date_view' ) ); |
|
19 | + add_action('wp_ajax_wps_statistics_custom_date_view', array($this, 'wps_statistics_custom_date_view')); |
|
20 | 20 | |
21 | 21 | $this->wps_stats_mdl = new wps_statistics_mdl(); |
22 | 22 | } |
@@ -24,20 +24,20 @@ discard block |
||
24 | 24 | /** |
25 | 25 | * Add Javascript & CSS files |
26 | 26 | */ |
27 | - function add_scripts( $hook ) { |
|
27 | + function add_scripts($hook) { |
|
28 | 28 | |
29 | 29 | global $current_screen; |
30 | - if ( ! in_array( $current_screen->post_type, array( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ), true ) && $hook != 'wpshop_shop_order_page_wpshop_statistics' ) { |
|
30 | + if (!in_array($current_screen->post_type, array(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS), true) && $hook != 'wpshop_shop_order_page_wpshop_statistics') { |
|
31 | 31 | return; |
32 | 32 | } |
33 | 33 | |
34 | - wp_enqueue_script( 'wps_statistics_js_chart', WPSHOP_JS_URL . 'Chart.js' ); |
|
35 | - wp_enqueue_script( 'jquery' ); |
|
36 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
37 | - wp_enqueue_script( 'jquery-form' ); |
|
34 | + wp_enqueue_script('wps_statistics_js_chart', WPSHOP_JS_URL . 'Chart.js'); |
|
35 | + wp_enqueue_script('jquery'); |
|
36 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
37 | + wp_enqueue_script('jquery-form'); |
|
38 | 38 | |
39 | - wp_register_style( 'jquery-ui-wpsstats', '//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css', '', WPSHOP_VERSION ); |
|
40 | - wp_enqueue_style( 'jquery-ui-wpsstats' ); |
|
39 | + wp_register_style('jquery-ui-wpsstats', '//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css', '', WPSHOP_VERSION); |
|
40 | + wp_enqueue_style('jquery-ui-wpsstats'); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -45,15 +45,15 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @param WP_Post $post Définition complète du post actuellement en cours de modification / Current edited post entire definition. |
47 | 47 | */ |
48 | - function wps_statistics_meta_box_content( $post ) { |
|
49 | - if ( ! empty( $post ) && WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS !== $post->post_type ) { |
|
48 | + function wps_statistics_meta_box_content($post) { |
|
49 | + if (!empty($post) && WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS !== $post->post_type) { |
|
50 | 50 | return; |
51 | 51 | } |
52 | 52 | $user_meta = ''; |
53 | - if ( ! empty( $post ) && ! empty( $post->post_author ) ) { |
|
54 | - $user_meta = get_user_meta( $post->post_author, 'wps_statistics_exclude_customer', true ); |
|
53 | + if (!empty($post) && !empty($post->post_author)) { |
|
54 | + $user_meta = get_user_meta($post->post_author, 'wps_statistics_exclude_customer', true); |
|
55 | 55 | } |
56 | - $output = '<span class="misc-pub-section" ><input type="checkbox" name="wps_statistics_exclude_customer" id="wps_statistics_exclude_customer" ' . checked( $user_meta, true, false ) . '/> <label for="wps_statistics_exclude_customer">' . __( 'Exclude this customer from WPShop Statistics', 'wpshop' ) . '</label></span>'; |
|
56 | + $output = '<span class="misc-pub-section" ><input type="checkbox" name="wps_statistics_exclude_customer" id="wps_statistics_exclude_customer" ' . checked($user_meta, true, false) . '/> <label for="wps_statistics_exclude_customer">' . __('Exclude this customer from WPShop Statistics', 'wpshop') . '</label></span>'; |
|
57 | 57 | |
58 | 58 | echo $output; |
59 | 59 | // End if(). |
@@ -65,15 +65,15 @@ discard block |
||
65 | 65 | * @param integer $post_id L'identifiant du post actuellement en cours de modification / Current edited post identifier. |
66 | 66 | * @param WP_Post $post Définition complète du post actuellement en cours de modification / Current edited post entire definition. |
67 | 67 | */ |
68 | - function wps_statistics_save_customer_infos( $post_id, $post ) { |
|
68 | + function wps_statistics_save_customer_infos($post_id, $post) { |
|
69 | 69 | |
70 | - $action = ! empty( $_POST['action'] ) ? sanitize_text_field( $_POST['action'] ) : ''; |
|
70 | + $action = !empty($_POST['action']) ? sanitize_text_field($_POST['action']) : ''; |
|
71 | 71 | // WPCS: CSRF ok. |
72 | - $wps_statistics_exclude_customer = isset( $_POST['wps_statistics_exclude_customer'] ) && ( 'on' === $_POST['wps_statistics_exclude_customer'] ) ? true : false; |
|
72 | + $wps_statistics_exclude_customer = isset($_POST['wps_statistics_exclude_customer']) && ('on' === $_POST['wps_statistics_exclude_customer']) ? true : false; |
|
73 | 73 | // WPCS: CSRF ok. |
74 | - if ( ( ! empty( $action ) && ( 'autosave' !== $action ) ) && ( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS === get_post_type( $post_id ) ) ) { |
|
75 | - if ( isset( $wps_statistics_exclude_customer ) ) { |
|
76 | - update_user_meta( $post->post_author, 'wps_statistics_exclude_customer', $wps_statistics_exclude_customer ); |
|
74 | + if ((!empty($action) && ('autosave' !== $action)) && (WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS === get_post_type($post_id))) { |
|
75 | + if (isset($wps_statistics_exclude_customer)) { |
|
76 | + update_user_meta($post->post_author, 'wps_statistics_exclude_customer', $wps_statistics_exclude_customer); |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | function register_stats_menu() { |
85 | 85 | |
86 | - add_submenu_page( 'edit.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER, __( 'Statistics', 'wpshop' ), __( 'Statistics', 'wpshop' ), 'wpshop_view_statistics', 'wpshop_statistics', array( $this, 'wps_display_statistics' ) ); |
|
86 | + add_submenu_page('edit.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER, __('Statistics', 'wpshop'), __('Statistics', 'wpshop'), 'wpshop_view_statistics', 'wpshop_statistics', array($this, 'wps_display_statistics')); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | $main_stats_count = 5; |
97 | 97 | |
98 | 98 | $ordered_customers = array(); |
99 | - foreach ( $shop_orders as $order ) { |
|
99 | + foreach ($shop_orders as $order) { |
|
100 | 100 | $user_id = $order['order_postmeta']['customer_id']; |
101 | - $wps_statistics_exclude_customer = get_user_meta( $user_id, 'wps_statistics_exclude_customer', true ); |
|
102 | - $excluded_from_statistics = ( ! empty( $wps_statistics_exclude_customer ) ) ? true : false; |
|
101 | + $wps_statistics_exclude_customer = get_user_meta($user_id, 'wps_statistics_exclude_customer', true); |
|
102 | + $excluded_from_statistics = (!empty($wps_statistics_exclude_customer)) ? true : false; |
|
103 | 103 | |
104 | - if ( false === $excluded_from_statistics ) { |
|
104 | + if (false === $excluded_from_statistics) { |
|
105 | 105 | $customer_id = null; |
106 | 106 | $args = array( |
107 | 107 | 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, |
@@ -111,22 +111,22 @@ discard block |
||
111 | 111 | 'post_status' => 'all', |
112 | 112 | 'posts_per_page' => 1, |
113 | 113 | ); |
114 | - $customer = new WP_Query( $args ); |
|
114 | + $customer = new WP_Query($args); |
|
115 | 115 | |
116 | - if ( ! isset( $ordered_customers[ $user_id ]['count'] ) ) { |
|
117 | - $ordered_customers[ $user_id ]['count'] = 0; |
|
118 | - $ordered_customers[ $user_id ]['total_amount'] = 0; |
|
116 | + if (!isset($ordered_customers[$user_id]['count'])) { |
|
117 | + $ordered_customers[$user_id]['count'] = 0; |
|
118 | + $ordered_customers[$user_id]['total_amount'] = 0; |
|
119 | 119 | } |
120 | - $ordered_customers[ $user_id ]['count']++; |
|
121 | - $ordered_customers[ $user_id ]['id'] = $user_id; |
|
122 | - $ordered_customers[ $user_id ]['post_id'] = $customer->post->ID; |
|
123 | - $ordered_customers[ $user_id ]['name'] = ( ! empty( $order['order_info'] ) && ! empty( $order['order_info']['billing'] ) && ! empty( $order['order_info']['billing']['address'] ) && ! empty( $order['order_info']['billing']['address']['address_last_name'] ) && ! empty( $order['order_info']['billing']['address']['address_first_name'] ) ) ? $order['order_info']['billing']['address']['address_first_name'] . ' ' . $order['order_info']['billing']['address']['address_last_name'] : ''; |
|
120 | + $ordered_customers[$user_id]['count']++; |
|
121 | + $ordered_customers[$user_id]['id'] = $user_id; |
|
122 | + $ordered_customers[$user_id]['post_id'] = $customer->post->ID; |
|
123 | + $ordered_customers[$user_id]['name'] = (!empty($order['order_info']) && !empty($order['order_info']['billing']) && !empty($order['order_info']['billing']['address']) && !empty($order['order_info']['billing']['address']['address_last_name']) && !empty($order['order_info']['billing']['address']['address_first_name'])) ? $order['order_info']['billing']['address']['address_first_name'] . ' ' . $order['order_info']['billing']['address']['address_last_name'] : ''; |
|
124 | 124 | ; |
125 | - $ordered_customers[ $user_id ]['total_amount'] += $order['order_postmeta']['order_grand_total']; |
|
125 | + $ordered_customers[$user_id]['total_amount'] += $order['order_postmeta']['order_grand_total']; |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
129 | - require( wpshop_tools::get_template_part( WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps-statistics' ) ); |
|
129 | + require(wpshop_tools::get_template_part(WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps-statistics')); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -136,14 +136,14 @@ discard block |
||
136 | 136 | * |
137 | 137 | * @return [type] [description] |
138 | 138 | */ |
139 | - function get_average_time_between_orders( $order_list ) { |
|
139 | + function get_average_time_between_orders($order_list) { |
|
140 | 140 | |
141 | 141 | $time_between_orders = 0; |
142 | 142 | $last_date = null; |
143 | - foreach ( $order_list as $order ) { |
|
144 | - if ( null !== $last_date ) { |
|
145 | - $last_order = new DateTime( $last_date ); |
|
146 | - $current_order = new DateTime( $order['order_postmeta']['order_date'] ); |
|
143 | + foreach ($order_list as $order) { |
|
144 | + if (null !== $last_date) { |
|
145 | + $last_order = new DateTime($last_date); |
|
146 | + $current_order = new DateTime($order['order_postmeta']['order_date']); |
|
147 | 147 | $time_between_orders += $last_order->getTimestamp() - $current_order->getTimestamp(); |
148 | 148 | } else { |
149 | 149 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $last_date = $order['order_postmeta']['order_date']; |
153 | 153 | } |
154 | 154 | |
155 | - return round( $time_between_orders / count( $order_list ) ); |
|
155 | + return round($time_between_orders / count($order_list)); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * |
161 | 161 | * @return boolean The boolean state allowing to know if the shop is out of bounds for time since last order |
162 | 162 | */ |
163 | - function check_current_time_since_last_order( $list_orders ) { |
|
163 | + function check_current_time_since_last_order($list_orders) { |
|
164 | 164 | |
165 | 165 | $average_check = array( |
166 | 166 | 'status' => false, |
@@ -168,20 +168,20 @@ discard block |
||
168 | 168 | 'average' => null, |
169 | 169 | 'duration' => null, |
170 | 170 | ); |
171 | - $current_date = new DateTime( current_time( 'Y-m-d H:i:s', 0 ) ); |
|
171 | + $current_date = new DateTime(current_time('Y-m-d H:i:s', 0)); |
|
172 | 172 | |
173 | - if ( ! empty( $list_orders ) ) { |
|
174 | - $last_order = array_slice( $list_orders, 0, 1 ); |
|
175 | - foreach ( $last_order as $order ) { |
|
173 | + if (!empty($list_orders)) { |
|
174 | + $last_order = array_slice($list_orders, 0, 1); |
|
175 | + foreach ($last_order as $order) { |
|
176 | 176 | $average_check['last_date'] = $order['order_postmeta']['order_date']; |
177 | 177 | } |
178 | - $last_order_dateTime = new DateTime( $average_check['last_date'] ); |
|
178 | + $last_order_dateTime = new DateTime($average_check['last_date']); |
|
179 | 179 | |
180 | 180 | $duration_since_last_order = $current_date->getTimestamp() - $last_order_dateTime->getTimestamp(); |
181 | 181 | $average_check['duration'] = $duration_since_last_order; |
182 | - $average_check['average'] = $this->get_average_time_between_orders( $list_orders ); |
|
182 | + $average_check['average'] = $this->get_average_time_between_orders($list_orders); |
|
183 | 183 | |
184 | - $average_check['status'] = ( $average_check['duration'] > $average_check['average'] ? true : false ); |
|
184 | + $average_check['status'] = ($average_check['duration'] > $average_check['average'] ? true : false); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | return $average_check; |
@@ -190,44 +190,44 @@ discard block |
||
190 | 190 | /** |
191 | 191 | * Main Statistics output |
192 | 192 | */ |
193 | - function wps_display_main_statistics( $shop_orders = null ) { |
|
193 | + function wps_display_main_statistics($shop_orders = null) { |
|
194 | 194 | |
195 | 195 | global $current_month_offset; |
196 | 196 | |
197 | - if ( null === $shop_orders ) { |
|
197 | + if (null === $shop_orders) { |
|
198 | 198 | $shop_orders = $this->wps_stats_mdl->wps_orders_all(); |
199 | 199 | } |
200 | 200 | |
201 | - $current_month_offset = (int) current_time( 'm' ); |
|
202 | - $current_month_offset = isset( $_GET['month'] ) ? (int) $_GET['month'] : $current_month_offset; |
|
201 | + $current_month_offset = (int)current_time('m'); |
|
202 | + $current_month_offset = isset($_GET['month']) ? (int)$_GET['month'] : $current_month_offset; |
|
203 | 203 | |
204 | - $current_month_start = date( 'Y-m-d 00:00:00', strtotime( 'first day of this month', time() ) ); |
|
205 | - $current_month_end = date( 'Y-m-d 23:59:59', strtotime( 'last day of this month', time() ) ); |
|
204 | + $current_month_start = date('Y-m-d 00:00:00', strtotime('first day of this month', time())); |
|
205 | + $current_month_end = date('Y-m-d 23:59:59', strtotime('last day of this month', time())); |
|
206 | 206 | |
207 | - $last_month_start = date( 'Y-m-d 00:00:00', strtotime( 'first day of last month', time() ) ); |
|
208 | - $last_month_end = date( 'Y-m-d 23:59:59', strtotime( 'last day of last month', time() ) ); |
|
209 | - $one_month_ago = date( 'Y-m-d 23:59:59', strtotime( '-1 month', time() ) ); |
|
207 | + $last_month_start = date('Y-m-d 00:00:00', strtotime('first day of last month', time())); |
|
208 | + $last_month_end = date('Y-m-d 23:59:59', strtotime('last day of last month', time())); |
|
209 | + $one_month_ago = date('Y-m-d 23:59:59', strtotime('-1 month', time())); |
|
210 | 210 | |
211 | 211 | $dates = array( |
212 | - __( 'Current month', 'wpshop' ) => array( |
|
212 | + __('Current month', 'wpshop') => array( |
|
213 | 213 | 'after' => $current_month_start, |
214 | 214 | 'before' => $current_month_end, |
215 | 215 | 'inclusive' => true, |
216 | 216 | ), |
217 | - sprintf( __( 'One month ago (%s)', 'wpshop' ), mysql2date( get_option( 'date_format' ), $one_month_ago, true ) ) => array( |
|
217 | + sprintf(__('One month ago (%s)', 'wpshop'), mysql2date(get_option('date_format'), $one_month_ago, true)) => array( |
|
218 | 218 | 'after' => $last_month_start, |
219 | 219 | 'before' => $one_month_ago, |
220 | 220 | 'inclusive' => true, |
221 | 221 | ), |
222 | - __( 'Last month', 'wpshop' ) => array( |
|
222 | + __('Last month', 'wpshop') => array( |
|
223 | 223 | 'after' => $last_month_start, |
224 | 224 | 'before' => $last_month_end, |
225 | 225 | 'inclusive' => true, |
226 | 226 | ), |
227 | - __( 'From the beginning', 'wpshop' ) => null, |
|
227 | + __('From the beginning', 'wpshop') => null, |
|
228 | 228 | ); |
229 | 229 | |
230 | - require_once( wpshop_tools::get_template_part( WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_main' ) ); |
|
230 | + require_once(wpshop_tools::get_template_part(WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_main')); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -237,43 +237,43 @@ discard block |
||
237 | 237 | * @param string $start Optionnal. The start date to get stats for. |
238 | 238 | * @param string $end Optionnal. The end date to get stats for. |
239 | 239 | */ |
240 | - function wps_display_custom_statistics( $shop_orders, $start = null, $end = null ) { |
|
240 | + function wps_display_custom_statistics($shop_orders, $start = null, $end = null) { |
|
241 | 241 | |
242 | - $current_month_start = date( 'Y-m-d', strtotime( 'first day of this month', time() ) ); |
|
243 | - $current_month_end = date( 'Y-m-d', strtotime( 'last day of this month', time() ) ); |
|
242 | + $current_month_start = date('Y-m-d', strtotime('first day of this month', time())); |
|
243 | + $current_month_end = date('Y-m-d', strtotime('last day of this month', time())); |
|
244 | 244 | |
245 | - $last_month_start = date( 'Y-m-d', strtotime( 'first day of last month', time() ) ); |
|
246 | - $last_month_end = date( 'Y-m-d', strtotime( 'last day of last month', time() ) ); |
|
245 | + $last_month_start = date('Y-m-d', strtotime('first day of last month', time())); |
|
246 | + $last_month_end = date('Y-m-d', strtotime('last day of last month', time())); |
|
247 | 247 | |
248 | 248 | $date_start = null !== $start ? $start : $current_month_start; |
249 | 249 | $date_end = null !== $end ? $end : $current_month_end; |
250 | 250 | |
251 | 251 | $stats_translations = array( |
252 | - 'numberOfSales' => __( 'Number of sales', 'wpshop' ), |
|
253 | - 'sales' => __( 'sales', 'wpshop' ), |
|
254 | - 'salesAmount' => __( 'Sales amount', 'wpshop' ), |
|
252 | + 'numberOfSales' => __('Number of sales', 'wpshop'), |
|
253 | + 'sales' => __('sales', 'wpshop'), |
|
254 | + 'salesAmount' => __('Sales amount', 'wpshop'), |
|
255 | 255 | 'wpshopCurrency' => wpshop_tools::wpshop_get_currency(), |
256 | 256 | ); |
257 | 257 | |
258 | 258 | $orders_total_amount = $orders_total_shipping_cost = $order_count = 0; |
259 | 259 | $orders_number_stats = $orders_amount_stats = array(); |
260 | - if ( ! empty( $shop_orders ) ) { |
|
261 | - foreach ( $shop_orders as $order ) { |
|
260 | + if (!empty($shop_orders)) { |
|
261 | + foreach ($shop_orders as $order) { |
|
262 | 262 | $order_data = $order['order_postmeta']; |
263 | - if ( ( $date_start <= $order_data['order_date'] ) && ( $date_end >= $order_data['order_date'] ) ) { |
|
263 | + if (($date_start <= $order_data['order_date']) && ($date_end >= $order_data['order_date'])) { |
|
264 | 264 | $orders_total_amount += $order_data['order_grand_total']; |
265 | 265 | $order_count++; |
266 | 266 | |
267 | - $time = strtotime( date( 'Ymd', strtotime( $order_data['order_date'] ) ) ) . '000'; |
|
268 | - if ( ! isset( $orders_number_stats[ $time ] ) ) { |
|
269 | - $orders_number_stats[ $time ] = 0; |
|
267 | + $time = strtotime(date('Ymd', strtotime($order_data['order_date']))) . '000'; |
|
268 | + if (!isset($orders_number_stats[$time])) { |
|
269 | + $orders_number_stats[$time] = 0; |
|
270 | 270 | } |
271 | - $orders_number_stats[ $time ]++; |
|
271 | + $orders_number_stats[$time]++; |
|
272 | 272 | |
273 | - if ( ! isset( $orders_amount_stats[ $time ] ) ) { |
|
274 | - $orders_amount_stats[ $time ] = 0; |
|
273 | + if (!isset($orders_amount_stats[$time])) { |
|
274 | + $orders_amount_stats[$time] = 0; |
|
275 | 275 | } |
276 | - $orders_amount_stats[ $time ] += $order_data['order_grand_total']; |
|
276 | + $orders_amount_stats[$time] += $order_data['order_grand_total']; |
|
277 | 277 | |
278 | 278 | $orders_total_shipping_cost += $order_data['order_shipping_cost']; |
279 | 279 | } |
@@ -281,24 +281,24 @@ discard block |
||
281 | 281 | } |
282 | 282 | |
283 | 283 | $orders_number_for_stats = null; |
284 | - if ( ! empty( $orders_number_stats ) ) { |
|
284 | + if (!empty($orders_number_stats)) { |
|
285 | 285 | $orders_numbers = array(); |
286 | - foreach ( $orders_number_stats as $time => $number ) { |
|
286 | + foreach ($orders_number_stats as $time => $number) { |
|
287 | 287 | $orders_numbers[] = "[$time, $number]"; |
288 | 288 | } |
289 | - $orders_number_for_stats = implode( ',', $orders_numbers ); |
|
289 | + $orders_number_for_stats = implode(',', $orders_numbers); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | $orders_amount_for_stats = null; |
293 | - if ( ! empty( $orders_amount_stats ) ) { |
|
293 | + if (!empty($orders_amount_stats)) { |
|
294 | 294 | $orders_amounts = array(); |
295 | - foreach ( $orders_amount_stats as $time => $amount ) { |
|
295 | + foreach ($orders_amount_stats as $time => $amount) { |
|
296 | 296 | $orders_amounts[] = "[$time, $amount]"; |
297 | 297 | } |
298 | - $orders_amount_for_stats = implode( ',', $orders_amounts ); |
|
298 | + $orders_amount_for_stats = implode(',', $orders_amounts); |
|
299 | 299 | } |
300 | 300 | |
301 | - $user_subscription_number = new WP_User_Query( array( |
|
301 | + $user_subscription_number = new WP_User_Query(array( |
|
302 | 302 | 'date_query' => array( |
303 | 303 | array( |
304 | 304 | 'after' => $date_start, |
@@ -307,9 +307,9 @@ discard block |
||
307 | 307 | ), |
308 | 308 | ), |
309 | 309 | 'count_total' => true, |
310 | - ) ); |
|
310 | + )); |
|
311 | 311 | |
312 | - require( wpshop_tools::get_template_part( WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_custom' ) ); |
|
312 | + require(wpshop_tools::get_template_part(WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_custom')); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | /** |
@@ -317,12 +317,12 @@ discard block |
||
317 | 317 | */ |
318 | 318 | function wps_statistics_custom_date_view() { |
319 | 319 | |
320 | - check_ajax_referer( 'wps_statistics_custom_date_view' ); |
|
320 | + check_ajax_referer('wps_statistics_custom_date_view'); |
|
321 | 321 | |
322 | - $start_date = ! empty( $_POST ) && ! empty( $_POST['wps_statistics_start_date'] ) ? sanitize_text_field( $_POST['wps_statistics_start_date'] ) : date( 'Y-m-d', strtotime( 'first day of this month', time() ) ); |
|
323 | - $end_date = ! empty( $_POST ) && ! empty( $_POST['wps_statistics_end_date'] ) ? sanitize_text_field( $_POST['wps_statistics_end_date'] ) : date( 'Y-m-d', strtotime( 'last day of this month', time() ) ); |
|
322 | + $start_date = !empty($_POST) && !empty($_POST['wps_statistics_start_date']) ? sanitize_text_field($_POST['wps_statistics_start_date']) : date('Y-m-d', strtotime('first day of this month', time())); |
|
323 | + $end_date = !empty($_POST) && !empty($_POST['wps_statistics_end_date']) ? sanitize_text_field($_POST['wps_statistics_end_date']) : date('Y-m-d', strtotime('last day of this month', time())); |
|
324 | 324 | |
325 | - $order_list = $this->wps_stats_mdl->wps_orders_all( array( |
|
325 | + $order_list = $this->wps_stats_mdl->wps_orders_all(array( |
|
326 | 326 | 'date_query' => array( |
327 | 327 | array( |
328 | 328 | 'after' => $date_start, |
@@ -330,13 +330,13 @@ discard block |
||
330 | 330 | 'inclusive' => true, |
331 | 331 | ), |
332 | 332 | ), |
333 | - ) ); |
|
333 | + )); |
|
334 | 334 | |
335 | 335 | ob_start(); |
336 | - $this->wps_display_custom_statistics( $order_list, $start_date, $end_date ); |
|
336 | + $this->wps_display_custom_statistics($order_list, $start_date, $end_date); |
|
337 | 337 | $output = ob_get_clean(); |
338 | 338 | |
339 | - wp_die( $output ); |
|
339 | + wp_die($output); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | } |