|
@@ -1,4 +1,4 @@ discard block |
|
|
block discarded – undo |
|
1
|
|
-<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
|
1
|
+<?php if (!defined('ABSPATH')) exit; |
|
2
|
2
|
/** |
|
3
|
3
|
* File for installer control class definition |
|
4
|
4
|
* |
|
@@ -24,7 +24,7 @@ discard block |
|
|
block discarded – undo |
|
24
|
24
|
} |
|
25
|
25
|
|
|
26
|
26
|
function add_scripts() { |
|
27
|
|
- add_action( 'admin_print_scripts', array($this, 'admin_print_script') ); |
|
|
27
|
+ add_action('admin_print_scripts', array($this, 'admin_print_script')); |
|
28
|
28
|
} |
|
29
|
29
|
|
|
30
|
30
|
function admin_print_script() { |
|
@@ -45,15 +45,15 @@ discard block |
|
|
block discarded – undo |
|
45
|
45
|
global $order_status, $wpdb; |
|
46
|
46
|
|
|
47
|
47
|
$this->add_dashboard_metaboxes(); |
|
48
|
|
- require_once( wpshop_tools::get_template_part( WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, "backend", "dashboard" ) ); |
|
|
48
|
+ require_once(wpshop_tools::get_template_part(WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, "backend", "dashboard")); |
|
49
|
49
|
} |
|
50
|
50
|
|
|
51
|
51
|
function wpshop_dashboard_orders() { |
|
52
|
52
|
$output = ''; |
|
53
|
|
- $orders = get_posts( array( 'posts_per_page' => 10, 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'post_status' => 'publish', 'orderby' => 'post_date', 'order' => 'DESC') ); |
|
|
53
|
+ $orders = get_posts(array('posts_per_page' => 10, 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'post_status' => 'publish', 'orderby' => 'post_date', 'order' => 'DESC')); |
|
54
|
54
|
// Display orders |
|
55
|
55
|
ob_start(); |
|
56
|
|
- require_once( wpshop_tools::get_template_part( WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, "backend", "wps_orders_on_dashboard" ) ); |
|
|
56
|
+ require_once(wpshop_tools::get_template_part(WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, "backend", "wps_orders_on_dashboard")); |
|
57
|
57
|
$output = ob_get_contents(); |
|
58
|
58
|
ob_end_clean(); |
|
59
|
59
|
|
|
@@ -63,24 +63,24 @@ discard block |
|
|
block discarded – undo |
|
63
|
63
|
|
|
64
|
64
|
function wpshop_rss_feed() { |
|
65
|
65
|
$output = ''; |
|
66
|
|
- include_once( ABSPATH . WPINC . '/feed.php' ); |
|
|
66
|
+ include_once(ABSPATH . WPINC . '/feed.php'); |
|
67
|
67
|
|
|
68
|
|
- $rss = fetch_feed( 'http://www.wpshop.fr/feed/' ); |
|
69
|
|
- if( ! is_wp_error( $rss ) ){ |
|
70
|
|
- $maxitems = $rss->get_item_quantity( 4 ); |
|
71
|
|
- $rss_items = $rss->get_items( 0, $maxitems ); |
|
|
68
|
+ $rss = fetch_feed('http://www.wpshop.fr/feed/'); |
|
|
69
|
+ if (!is_wp_error($rss)) { |
|
|
70
|
+ $maxitems = $rss->get_item_quantity(4); |
|
|
71
|
+ $rss_items = $rss->get_items(0, $maxitems); |
|
72
|
72
|
} |
|
73
|
73
|
else { |
|
74
|
74
|
$output .= '<p>' . __('WPShop News cannot be loaded', 'wpshop') . '</p>'; |
|
75
|
75
|
} |
|
76
|
76
|
|
|
77
|
|
- if ( $maxitems == 0 ) { |
|
|
77
|
+ if ($maxitems == 0) { |
|
78
|
78
|
$output .= '<p>' . __('No WPShop new has been found', 'wpshop') . '</p>'; |
|
79
|
79
|
} |
|
80
|
80
|
else { |
|
81
|
81
|
$output .= '<ul class="recent-orders">'; |
|
82
|
|
- foreach ( $rss_items as $item ) { |
|
83
|
|
- $output .= '<li><a href="' .$item->get_permalink() . '" title="' .$item->get_title(). '" target="_blank">' .$item->get_title(). '</a><br/>'; |
|
|
82
|
+ foreach ($rss_items as $item) { |
|
|
83
|
+ $output .= '<li><a href="' . $item->get_permalink() . '" title="' . $item->get_title() . '" target="_blank">' . $item->get_title() . '</a><br/>'; |
|
84
|
84
|
$output .= $item->get_content(); |
|
85
|
85
|
$output .= '</li>'; |
|
86
|
86
|
} |
|
@@ -90,40 +90,40 @@ discard block |
|
|
block discarded – undo |
|
90
|
90
|
} |
|
91
|
91
|
|
|
92
|
92
|
function wpshop_rss_tutorial_videos() { |
|
93
|
|
- $ini_get_checking = ini_get( 'allow_url_fopen' ); |
|
|
93
|
+ $ini_get_checking = ini_get('allow_url_fopen'); |
|
94
|
94
|
|
|
95
|
|
- if ( $ini_get_checking != 0 ) { |
|
96
|
|
- $content = @file_get_contents( 'http://www.wpshop.fr/rss_video.xml' ); |
|
97
|
|
- $videos_rss = ( $content !== false ) ? new SimpleXmlElement( $content ) : null; |
|
98
|
|
- if ( !empty($videos_rss) && !empty($videos_rss->channel) ) { |
|
|
95
|
+ if ($ini_get_checking != 0) { |
|
|
96
|
+ $content = @file_get_contents('http://www.wpshop.fr/rss_video.xml'); |
|
|
97
|
+ $videos_rss = ($content !== false) ? new SimpleXmlElement($content) : null; |
|
|
98
|
+ if (!empty($videos_rss) && !empty($videos_rss->channel)) { |
|
99
|
99
|
$videos_items = array(); |
|
100
|
|
- foreach( $videos_rss->channel->item as $i => $item ) { |
|
|
100
|
+ foreach ($videos_rss->channel->item as $i => $item) { |
|
101
|
101
|
$videos_items[] = $item; |
|
102
|
102
|
} |
|
103
|
|
- $rand_element = array_rand( $videos_items ); |
|
|
103
|
+ $rand_element = array_rand($videos_items); |
|
104
|
104
|
|
|
105
|
105
|
ob_start(); |
|
106
|
|
- require_once( wpshop_tools::get_template_part( WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, "backend", "dashboard", "videos" ) ); |
|
|
106
|
+ require_once(wpshop_tools::get_template_part(WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, "backend", "dashboard", "videos")); |
|
107
|
107
|
$output = ob_get_contents(); |
|
108
|
108
|
ob_end_clean(); |
|
109
|
109
|
} |
|
110
|
110
|
else { |
|
111
|
|
- $output = __('No tutorial videos can be loaded', 'wpshop' ); |
|
|
111
|
+ $output = __('No tutorial videos can be loaded', 'wpshop'); |
|
112
|
112
|
} |
|
113
|
113
|
} |
|
114
|
114
|
else { |
|
115
|
|
- $output = __( 'Your servor doesn\'t allow to open external files', 'wpshop'); |
|
|
115
|
+ $output = __('Your servor doesn\'t allow to open external files', 'wpshop'); |
|
116
|
116
|
} |
|
117
|
117
|
|
|
118
|
118
|
echo $output; |
|
119
|
119
|
} |
|
120
|
120
|
|
|
121
|
121
|
function wpshop_dashboard_get_changelog() { |
|
122
|
|
- $readme_file = fopen( WPSHOP_DIR.'/readme.txt', 'r' ); |
|
123
|
|
- if ( $readme_file ) { |
|
124
|
|
- $txt = file_get_contents( WPSHOP_DIR.'/readme.txt' ); |
|
125
|
|
- $pre_change_log = explode( '== Changelog ==', $txt ); |
|
126
|
|
- $versions = explode( '= Version', $pre_change_log[1] ); |
|
|
122
|
+ $readme_file = fopen(WPSHOP_DIR . '/readme.txt', 'r'); |
|
|
123
|
+ if ($readme_file) { |
|
|
124
|
+ $txt = file_get_contents(WPSHOP_DIR . '/readme.txt'); |
|
|
125
|
+ $pre_change_log = explode('== Changelog ==', $txt); |
|
|
126
|
+ $versions = explode('= Version', $pre_change_log[1]); |
|
127
|
127
|
|
|
128
|
128
|
echo $versions[1]; |
|
129
|
129
|
} |
|
@@ -133,16 +133,16 @@ discard block |
|
|
block discarded – undo |
|
133
|
133
|
* Add custom metaboxes to WPShop dashboard |
|
134
|
134
|
*/ |
|
135
|
135
|
function add_dashboard_metaboxes() { |
|
136
|
|
- add_meta_box( 'wps-right-now', '<i class="dashicons dashicons-info"></i>' . esc_html( 'Right Now', 'wpshop' ), array( $this, 'wps_dashboard_right_now' ), 'wpshop_dashboard', 'left_column' ); |
|
137
|
|
- add_meta_box( 'wps-dashboard-quick-links', '<i class="dashicons dashicons-performance"></i>' . esc_html( 'Quick Links', 'wpshop' ), array( $this, 'wps_dashboard_quick_links' ), 'wpshop_dashboard', 'left_column' ); |
|
|
136
|
+ add_meta_box('wps-right-now', '<i class="dashicons dashicons-info"></i>' . esc_html('Right Now', 'wpshop'), array($this, 'wps_dashboard_right_now'), 'wpshop_dashboard', 'left_column'); |
|
|
137
|
+ add_meta_box('wps-dashboard-quick-links', '<i class="dashicons dashicons-performance"></i>' . esc_html('Quick Links', 'wpshop'), array($this, 'wps_dashboard_quick_links'), 'wpshop_dashboard', 'left_column'); |
|
138
|
138
|
// add_meta_box( 'wps-dashboard-customer-stats', '<i class="dashicons dashicons-chart-pie"></i>' . esc_html( 'Customers stats', 'wpshop' ), array( $this, 'wps_dashboard_customer_stats' ), 'wpshop_dashboard', 'left_column' ); |
|
139
|
|
- add_meta_box( 'wps-dashboard-export', '<i class="dashicons dashicons-download"></i>' . esc_html( 'CSV export', 'wpshop' ), array( $this, 'wps_dashboard_export' ), 'wpshop_dashboard', 'left_column' ); |
|
140
|
|
- add_meta_box( 'wps-dashboard-orders', '<i class="dashicons dashicons-cart"></i>' . esc_html( 'Recent Orders', 'wpshop' ), array( $this, 'wps_dashboard_orders' ), 'wpshop_dashboard', 'left_column' ); |
|
|
139
|
+ add_meta_box('wps-dashboard-export', '<i class="dashicons dashicons-download"></i>' . esc_html('CSV export', 'wpshop'), array($this, 'wps_dashboard_export'), 'wpshop_dashboard', 'left_column'); |
|
|
140
|
+ add_meta_box('wps-dashboard-orders', '<i class="dashicons dashicons-cart"></i>' . esc_html('Recent Orders', 'wpshop'), array($this, 'wps_dashboard_orders'), 'wpshop_dashboard', 'left_column'); |
|
141
|
141
|
|
|
142
|
|
- add_meta_box( 'wps-dashboard-statistics', '<i class="dashicons dashicons-chart-area"></i>' . esc_html( 'Statistics', 'wpshop' ), array( $this, 'wps_dashboard_statistics' ), 'wpshop_dashboard', 'right_column' ); |
|
|
142
|
+ add_meta_box('wps-dashboard-statistics', '<i class="dashicons dashicons-chart-area"></i>' . esc_html('Statistics', 'wpshop'), array($this, 'wps_dashboard_statistics'), 'wpshop_dashboard', 'right_column'); |
|
143
|
143
|
|
|
144
|
|
- add_meta_box( 'wps-dashboard-infos', '<i class="dashicons dashicons-heart"></i>' . esc_html( 'WPShop : WordPress e-commerce', 'wpshop' ), array( $this, 'wps_dashboard_infos' ), 'wpshop_dashboard', 'right_column' ); |
|
145
|
|
- add_meta_box( 'wps-dashboard-feed', '<i class="dashicons dashicons-format-status"></i>' . esc_html( 'WPShop News', 'wpshop' ), array( $this, 'wps_dashboard_feed' ), 'wpshop_dashboard', 'right_column' ); |
|
|
144
|
+ add_meta_box('wps-dashboard-infos', '<i class="dashicons dashicons-heart"></i>' . esc_html('WPShop : WordPress e-commerce', 'wpshop'), array($this, 'wps_dashboard_infos'), 'wpshop_dashboard', 'right_column'); |
|
|
145
|
+ add_meta_box('wps-dashboard-feed', '<i class="dashicons dashicons-format-status"></i>' . esc_html('WPShop News', 'wpshop'), array($this, 'wps_dashboard_feed'), 'wpshop_dashboard', 'right_column'); |
|
146
|
146
|
} |
|
147
|
147
|
|
|
148
|
148
|
/** |
|
@@ -150,14 +150,14 @@ discard block |
|
|
block discarded – undo |
|
150
|
150
|
*/ |
|
151
|
151
|
function wps_dashboard_right_now() { |
|
152
|
152
|
global $wpdb; |
|
153
|
|
- require_once( wpshop_tools::get_template_part( WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, 'backend', 'metabox', 'right_now' ) ); |
|
|
153
|
+ require_once(wpshop_tools::get_template_part(WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, 'backend', 'metabox', 'right_now')); |
|
154
|
154
|
} |
|
155
|
155
|
|
|
156
|
156
|
/** |
|
157
|
157
|
* Display metabox with quick links |
|
158
|
158
|
*/ |
|
159
|
159
|
function wps_dashboard_quick_links() { |
|
160
|
|
- require_once( wpshop_tools::get_template_part( WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, 'backend', 'metabox', 'quicklinks' ) ); |
|
|
160
|
+ require_once(wpshop_tools::get_template_part(WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, 'backend', 'metabox', 'quicklinks')); |
|
161
|
161
|
} |
|
162
|
162
|
|
|
163
|
163
|
/** |
|
@@ -173,28 +173,28 @@ discard block |
|
|
block discarded – undo |
|
173
|
173
|
function wps_dashboard_statistics() { |
|
174
|
174
|
global $wpdb, $current_month_offset; |
|
175
|
175
|
|
|
176
|
|
- $current_month_offset = (int) current_time( 'm' ); |
|
177
|
|
- $current_month_offset = isset( $_GET['month'] ) ? (int) $_GET['month'] : $current_month_offset; |
|
|
176
|
+ $current_month_offset = (int)current_time('m'); |
|
|
177
|
+ $current_month_offset = isset($_GET['month']) ? (int)$_GET['month'] : $current_month_offset; |
|
178
|
178
|
|
|
179
|
|
- $current_month_start = date( 'Y-m-d 00:00:00', strtotime( 'first day of this month', time() ) ); |
|
180
|
|
- $current_month_end = date( 'Y-m-d 23:59:59', strtotime( 'last day of this month', time() ) ); |
|
|
179
|
+ $current_month_start = date('Y-m-d 00:00:00', strtotime('first day of this month', time())); |
|
|
180
|
+ $current_month_end = date('Y-m-d 23:59:59', strtotime('last day of this month', time())); |
|
181
|
181
|
|
|
182
|
|
- $last_month_start = date( 'Y-m-d 00:00:00', strtotime( 'first day of last month', time() ) ); |
|
183
|
|
- $last_month_end = date( 'Y-m-d 23:59:59', strtotime( 'last day of last month', time() ) ); |
|
184
|
|
- $one_month_ago = date( 'Y-m-d 23:59:59', strtotime( '-1 month', time() ) ); |
|
|
182
|
+ $last_month_start = date('Y-m-d 00:00:00', strtotime('first day of last month', time())); |
|
|
183
|
+ $last_month_end = date('Y-m-d 23:59:59', strtotime('last day of last month', time())); |
|
|
184
|
+ $one_month_ago = date('Y-m-d 23:59:59', strtotime('-1 month', time())); |
|
185
|
185
|
|
|
186
|
186
|
$dates = array( |
|
187
|
|
- __( 'Current month', 'wpshop' ) => array( |
|
|
187
|
+ __('Current month', 'wpshop') => array( |
|
188
|
188
|
'after' => $current_month_start, |
|
189
|
189
|
'before' => $current_month_end, |
|
190
|
190
|
'inclusive' => true, |
|
191
|
191
|
), |
|
192
|
|
- sprintf( __( 'One month ago (%s)', 'wpshop' ), mysql2date( get_option( 'date_format' ), $one_month_ago, true ) ) => array( |
|
|
192
|
+ sprintf(__('One month ago (%s)', 'wpshop'), mysql2date(get_option('date_format'), $one_month_ago, true)) => array( |
|
193
|
193
|
'after' => $last_month_start, |
|
194
|
194
|
'before' => $one_month_ago, |
|
195
|
195
|
'inclusive' => true, |
|
196
|
196
|
), |
|
197
|
|
- __( 'Last month', 'wpshop' ) => array( |
|
|
197
|
+ __('Last month', 'wpshop') => array( |
|
198
|
198
|
'after' => $last_month_start, |
|
199
|
199
|
'before' => $last_month_end, |
|
200
|
200
|
'inclusive' => true, |
|
@@ -222,7 +222,7 @@ discard block |
|
|
block discarded – undo |
|
222
|
222
|
), |
|
223
|
223
|
); |
|
224
|
224
|
|
|
225
|
|
- require_once( wpshop_tools::get_template_part( WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, 'backend', 'metabox', 'statistics' ) ); |
|
|
225
|
+ require_once(wpshop_tools::get_template_part(WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, 'backend', 'metabox', 'statistics')); |
|
226
|
226
|
} |
|
227
|
227
|
|
|
228
|
228
|
/** |
|
@@ -230,28 +230,28 @@ discard block |
|
|
block discarded – undo |
|
230
|
230
|
*/ |
|
231
|
231
|
function wps_dashboard_infos() { |
|
232
|
232
|
global $wpdb; |
|
233
|
|
- require_once( wpshop_tools::get_template_part( WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, 'backend', 'metabox', 'infos' ) ); |
|
|
233
|
+ require_once(wpshop_tools::get_template_part(WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, 'backend', 'metabox', 'infos')); |
|
234
|
234
|
} |
|
235
|
235
|
|
|
236
|
236
|
/** |
|
237
|
237
|
* Display metabox with shop main statistics |
|
238
|
238
|
*/ |
|
239
|
239
|
function wps_dashboard_feed() { |
|
240
|
|
- require_once( wpshop_tools::get_template_part( WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, 'backend', 'metabox', 'feed' ) ); |
|
|
240
|
+ require_once(wpshop_tools::get_template_part(WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, 'backend', 'metabox', 'feed')); |
|
241
|
241
|
} |
|
242
|
242
|
|
|
243
|
243
|
/** |
|
244
|
244
|
* Display metabox with recent orders list |
|
245
|
245
|
*/ |
|
246
|
246
|
function wps_dashboard_orders() { |
|
247
|
|
- require_once( wpshop_tools::get_template_part( WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, 'backend', 'metabox', 'orders' ) ); |
|
|
247
|
+ require_once(wpshop_tools::get_template_part(WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, 'backend', 'metabox', 'orders')); |
|
248
|
248
|
} |
|
249
|
249
|
|
|
250
|
250
|
/** |
|
251
|
251
|
* Display metabox for export |
|
252
|
252
|
*/ |
|
253
|
253
|
function wps_dashboard_export() { |
|
254
|
|
- if ( class_exists( 'wps_export_ctr' ) ) { |
|
|
254
|
+ if (class_exists('wps_export_ctr')) { |
|
255
|
255
|
$wps_export = new wps_export_ctr(); |
|
256
|
256
|
$wps_export->wps_export_tpl(); |
|
257
|
257
|
} |