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0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / includes / admin / class-wc-admin-status.php
woocommerce / includes / admin Last commit date
helper 3 years ago importers 3 years ago list-tables 3 years ago marketplace-suggestions 3 years ago meta-boxes 3 years ago notes 3 years ago plugin-updates 5 years ago reports 3 years ago settings 3 years ago views 3 years ago class-wc-admin-addons.php 3 years ago class-wc-admin-api-keys-table-list.php 6 years ago class-wc-admin-api-keys.php 6 years ago class-wc-admin-assets.php 3 years ago class-wc-admin-attributes.php 3 years ago class-wc-admin-customize.php 5 years ago class-wc-admin-dashboard-setup.php 3 years ago class-wc-admin-dashboard.php 3 years ago class-wc-admin-duplicate-product.php 5 years ago class-wc-admin-exporters.php 3 years ago class-wc-admin-help.php 4 years ago class-wc-admin-importers.php 5 years ago class-wc-admin-log-table-list.php 5 years ago class-wc-admin-menus.php 3 years ago class-wc-admin-meta-boxes.php 3 years ago class-wc-admin-notices.php 3 years ago class-wc-admin-permalink-settings.php 5 years ago class-wc-admin-pointers.php 3 years ago class-wc-admin-post-types.php 3 years ago class-wc-admin-profile.php 4 years ago class-wc-admin-reports.php 5 years ago class-wc-admin-settings.php 3 years ago class-wc-admin-setup-wizard.php 4 years ago class-wc-admin-status.php 3 years ago class-wc-admin-taxonomies.php 3 years ago class-wc-admin-webhooks-table-list.php 4 years ago class-wc-admin-webhooks.php 3 years ago class-wc-admin.php 4 years ago wc-admin-functions.php 3 years ago wc-meta-box-functions.php 3 years ago
class-wc-admin-status.php
440 lines
1 <?php
2 /**
3 * Debug/Status page
4 *
5 * @package WooCommerce\Admin\System Status
6 * @version 2.2.0
7 */
8
9 use Automattic\Jetpack\Constants;
10 use Automattic\WooCommerce\Utilities\ArrayUtil;
11
12 defined( 'ABSPATH' ) || exit;
13
14 /**
15 * WC_Admin_Status Class.
16 */
17 class WC_Admin_Status {
18
19 /**
20 * Handles output of the reports page in admin.
21 */
22 public static function output() {
23 include_once __DIR__ . '/views/html-admin-page-status.php';
24 }
25
26 /**
27 * Handles output of report.
28 */
29 public static function status_report() {
30 include_once __DIR__ . '/views/html-admin-page-status-report.php';
31 }
32
33 /**
34 * Handles output of tools.
35 */
36 public static function status_tools() {
37 if ( ! class_exists( 'WC_REST_System_Status_Tools_Controller' ) ) {
38 wp_die( 'Cannot load the REST API to access WC_REST_System_Status_Tools_Controller.' );
39 }
40
41 $tools = self::get_tools();
42 $tool_requires_refresh = false;
43
44 if ( ! empty( $_GET['action'] ) && ! empty( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( wp_unslash( $_REQUEST['_wpnonce'] ), 'debug_action' ) ) { // WPCS: input var ok, sanitization ok.
45 $tools_controller = new WC_REST_System_Status_Tools_Controller();
46 $action = wc_clean( wp_unslash( $_GET['action'] ) ); // WPCS: input var ok.
47
48 if ( array_key_exists( $action, $tools ) ) {
49 $response = $tools_controller->execute_tool( $action );
50
51 $tool = $tools[ $action ];
52 $tool_requires_refresh = ArrayUtil::get_value_or_default( $tool, 'requires_refresh', false );
53 $tool = array(
54 'id' => $action,
55 'name' => $tool['name'],
56 'action' => $tool['button'],
57 'description' => $tool['desc'],
58 'disabled' => ArrayUtil::get_value_or_default( $tool, 'disabled', false ),
59 );
60 $tool = array_merge( $tool, $response );
61
62 /**
63 * Fires after a WooCommerce system status tool has been executed.
64 *
65 * @param array $tool Details about the tool that has been executed.
66 */
67 do_action( 'woocommerce_system_status_tool_executed', $tool );
68 } else {
69 $response = array(
70 'success' => false,
71 'message' => __( 'Tool does not exist.', 'woocommerce' ),
72 );
73 }
74
75 if ( $response['success'] ) {
76 echo '<div class="updated inline"><p>' . esc_html( $response['message'] ) . '</p></div>';
77 } else {
78 echo '<div class="error inline"><p>' . esc_html( $response['message'] ) . '</p></div>';
79 }
80 }
81
82 // Display message if settings settings have been saved.
83 if ( isset( $_REQUEST['settings-updated'] ) ) { // WPCS: input var ok.
84 echo '<div class="updated inline"><p>' . esc_html__( 'Your changes have been saved.', 'woocommerce' ) . '</p></div>';
85 }
86
87 if ( $tool_requires_refresh ) {
88 $tools = self::get_tools();
89 }
90
91 include_once __DIR__ . '/views/html-admin-page-status-tools.php';
92 }
93
94 /**
95 * Get tools.
96 *
97 * @return array of tools
98 */
99 public static function get_tools() {
100 $tools_controller = new WC_REST_System_Status_Tools_Controller();
101 return $tools_controller->get_tools();
102 }
103
104 /**
105 * Show the logs page.
106 */
107 public static function status_logs() {
108 $log_handler = Constants::get_constant( 'WC_LOG_HANDLER' );
109
110 if ( 'WC_Log_Handler_DB' === $log_handler ) {
111 self::status_logs_db();
112 } else {
113 self::status_logs_file();
114 }
115 }
116
117 /**
118 * Show the log page contents for file log handler.
119 */
120 public static function status_logs_file() {
121 $logs = self::scan_log_files();
122
123 if ( ! empty( $_REQUEST['log_file'] ) && isset( $logs[ sanitize_title( wp_unslash( $_REQUEST['log_file'] ) ) ] ) ) { // WPCS: input var ok, CSRF ok.
124 $viewed_log = $logs[ sanitize_title( wp_unslash( $_REQUEST['log_file'] ) ) ]; // WPCS: input var ok, CSRF ok.
125 } elseif ( ! empty( $logs ) ) {
126 $viewed_log = current( $logs );
127 }
128
129 $handle = ! empty( $viewed_log ) ? self::get_log_file_handle( $viewed_log ) : '';
130
131 if ( ! empty( $_REQUEST['handle'] ) ) { // WPCS: input var ok, CSRF ok.
132 self::remove_log();
133 }
134
135 include_once __DIR__ . '/views/html-admin-page-status-logs.php';
136 }
137
138 /**
139 * Show the log page contents for db log handler.
140 */
141 public static function status_logs_db() {
142 if ( ! empty( $_REQUEST['flush-logs'] ) ) { // WPCS: input var ok, CSRF ok.
143 self::flush_db_logs();
144 }
145
146 if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['log'] ) ) { // WPCS: input var ok, CSRF ok.
147 self::log_table_bulk_actions();
148 }
149
150 $log_table_list = new WC_Admin_Log_Table_List();
151 $log_table_list->prepare_items();
152
153 include_once __DIR__ . '/views/html-admin-page-status-logs-db.php';
154 }
155
156 /**
157 * Retrieve metadata from a file. Based on WP Core's get_file_data function.
158 *
159 * @since 2.1.1
160 * @param string $file Path to the file.
161 * @return string
162 */
163 public static function get_file_version( $file ) {
164
165 // Avoid notices if file does not exist.
166 if ( ! file_exists( $file ) ) {
167 return '';
168 }
169
170 // We don't need to write to the file, so just open for reading.
171 $fp = fopen( $file, 'r' ); // @codingStandardsIgnoreLine.
172
173 // Pull only the first 8kiB of the file in.
174 $file_data = fread( $fp, 8192 ); // @codingStandardsIgnoreLine.
175
176 // PHP will close file handle, but we are good citizens.
177 fclose( $fp ); // @codingStandardsIgnoreLine.
178
179 // Make sure we catch CR-only line endings.
180 $file_data = str_replace( "\r", "\n", $file_data );
181 $version = '';
182
183 if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( '@version', '/' ) . '(.*)$/mi', $file_data, $match ) && $match[1] ) {
184 $version = _cleanup_header_comment( $match[1] );
185 }
186
187 return $version;
188 }
189
190 /**
191 * Return the log file handle.
192 *
193 * @param string $filename Filename to get the handle for.
194 * @return string
195 */
196 public static function get_log_file_handle( $filename ) {
197 return substr( $filename, 0, strlen( $filename ) > 48 ? strlen( $filename ) - 48 : strlen( $filename ) - 4 );
198 }
199
200 /**
201 * Scan the template files.
202 *
203 * @param string $template_path Path to the template directory.
204 * @return array
205 */
206 public static function scan_template_files( $template_path ) {
207 $files = @scandir( $template_path ); // @codingStandardsIgnoreLine.
208 $result = array();
209
210 if ( ! empty( $files ) ) {
211
212 foreach ( $files as $key => $value ) {
213
214 if ( ! in_array( $value, array( '.', '..' ), true ) ) {
215
216 if ( is_dir( $template_path . DIRECTORY_SEPARATOR . $value ) ) {
217 $sub_files = self::scan_template_files( $template_path . DIRECTORY_SEPARATOR . $value );
218 foreach ( $sub_files as $sub_file ) {
219 $result[] = $value . DIRECTORY_SEPARATOR . $sub_file;
220 }
221 } else {
222 $result[] = $value;
223 }
224 }
225 }
226 }
227 return $result;
228 }
229
230 /**
231 * Scan the log files.
232 *
233 * @return array
234 */
235 public static function scan_log_files() {
236 return WC_Log_Handler_File::get_log_files();
237 }
238
239 /**
240 * Get latest version of a theme by slug.
241 *
242 * @param object $theme WP_Theme object.
243 * @return string Version number if found.
244 */
245 public static function get_latest_theme_version( $theme ) {
246 include_once ABSPATH . 'wp-admin/includes/theme.php';
247
248 $api = themes_api(
249 'theme_information',
250 array(
251 'slug' => $theme->get_stylesheet(),
252 'fields' => array(
253 'sections' => false,
254 'tags' => false,
255 ),
256 )
257 );
258
259 $update_theme_version = 0;
260
261 // Check .org for updates.
262 if ( is_object( $api ) && ! is_wp_error( $api ) && isset( $api->version ) ) {
263 $update_theme_version = $api->version;
264 } elseif ( strstr( $theme->{'Author URI'}, 'woothemes' ) ) { // Check WooThemes Theme Version.
265 $theme_dir = substr( strtolower( str_replace( ' ', '', $theme->Name ) ), 0, 45 ); // @codingStandardsIgnoreLine.
266 $theme_version_data = get_transient( $theme_dir . '_version_data' );
267
268 if ( false === $theme_version_data ) {
269 $theme_changelog = wp_safe_remote_get( 'http://dzv365zjfbd8v.cloudfront.net/changelogs/' . $theme_dir . '/changelog.txt' );
270 $cl_lines = explode( "\n", wp_remote_retrieve_body( $theme_changelog ) );
271 if ( ! empty( $cl_lines ) ) {
272 foreach ( $cl_lines as $line_num => $cl_line ) {
273 if ( preg_match( '/^[0-9]/', $cl_line ) ) {
274 $theme_date = str_replace( '.', '-', trim( substr( $cl_line, 0, strpos( $cl_line, '-' ) ) ) );
275 $theme_version = preg_replace( '~[^0-9,.]~', '', stristr( $cl_line, 'version' ) );
276 $theme_update = trim( str_replace( '*', '', $cl_lines[ $line_num + 1 ] ) );
277 $theme_version_data = array(
278 'date' => $theme_date,
279 'version' => $theme_version,
280 'update' => $theme_update,
281 'changelog' => $theme_changelog,
282 );
283 set_transient( $theme_dir . '_version_data', $theme_version_data, DAY_IN_SECONDS );
284 break;
285 }
286 }
287 }
288 }
289
290 if ( ! empty( $theme_version_data['version'] ) ) {
291 $update_theme_version = $theme_version_data['version'];
292 }
293 }
294
295 return $update_theme_version;
296 }
297
298 /**
299 * Remove/delete the chosen file.
300 */
301 public static function remove_log() {
302 if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( wp_unslash( $_REQUEST['_wpnonce'] ), 'remove_log' ) ) { // WPCS: input var ok, sanitization ok.
303 wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'woocommerce' ) );
304 }
305
306 if ( ! empty( $_REQUEST['handle'] ) ) { // WPCS: input var ok.
307 $log_handler = new WC_Log_Handler_File();
308 $log_handler->remove( wp_unslash( $_REQUEST['handle'] ) ); // WPCS: input var ok, sanitization ok.
309 }
310
311 wp_safe_redirect( esc_url_raw( admin_url( 'admin.php?page=wc-status&tab=logs' ) ) );
312 exit();
313 }
314
315 /**
316 * Clear DB log table.
317 *
318 * @since 3.0.0
319 */
320 private static function flush_db_logs() {
321 if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'woocommerce-status-logs' ) ) { // WPCS: input var ok, sanitization ok.
322 wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'woocommerce' ) );
323 }
324
325 WC_Log_Handler_DB::flush();
326
327 wp_safe_redirect( esc_url_raw( admin_url( 'admin.php?page=wc-status&tab=logs' ) ) );
328 exit();
329 }
330
331 /**
332 * Bulk DB log table actions.
333 *
334 * @since 3.0.0
335 */
336 private static function log_table_bulk_actions() {
337 if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'woocommerce-status-logs' ) ) { // WPCS: input var ok, sanitization ok.
338 wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'woocommerce' ) );
339 }
340
341 $log_ids = array_map( 'absint', (array) isset( $_REQUEST['log'] ) ? wp_unslash( $_REQUEST['log'] ) : array() ); // WPCS: input var ok, sanitization ok.
342
343 if ( ( isset( $_REQUEST['action'] ) && 'delete' === $_REQUEST['action'] ) || ( isset( $_REQUEST['action2'] ) && 'delete' === $_REQUEST['action2'] ) ) { // WPCS: input var ok, sanitization ok.
344 WC_Log_Handler_DB::delete( $log_ids );
345 wp_safe_redirect( esc_url_raw( admin_url( 'admin.php?page=wc-status&tab=logs' ) ) );
346 exit();
347 }
348 }
349
350 /**
351 * Prints table info if a base table is not present.
352 */
353 private static function output_tables_info() {
354 $missing_tables = WC_Install::verify_base_tables( false );
355 if ( 0 === count( $missing_tables ) ) {
356 return;
357 }
358 ?>
359
360 <br>
361 <strong style="color:#a00;">
362 <span class="dashicons dashicons-warning"></span>
363 <?php
364 echo esc_html(
365 sprintf(
366 // translators: Comma seperated list of missing tables.
367 __( 'Missing base tables: %s. Some WooCommerce functionality may not work as expected.', 'woocommerce' ),
368 implode( ', ', $missing_tables )
369 )
370 );
371 ?>
372 </strong>
373
374 <?php
375 }
376
377 /**
378 * Prints the information about plugins for the system status report.
379 * Used for both active and inactive plugins sections.
380 *
381 * @param array $plugins List of plugins to display.
382 * @param array $untested_plugins List of plugins that haven't been tested with the current WooCommerce version.
383 * @return void
384 */
385 private static function output_plugins_info( $plugins, $untested_plugins ) {
386 $wc_version = Constants::get_constant( 'WC_VERSION' );
387
388 if ( 'major' === Constants::get_constant( 'WC_SSR_PLUGIN_UPDATE_RELEASE_VERSION_TYPE' ) ) {
389 // Since we're only testing against major, we don't need to show minor and patch version.
390 $wc_version = $wc_version[0] . '.0';
391 }
392
393 foreach ( $plugins as $plugin ) {
394 if ( ! empty( $plugin['name'] ) ) {
395 // Link the plugin name to the plugin url if available.
396 $plugin_name = esc_html( $plugin['name'] );
397 if ( ! empty( $plugin['url'] ) ) {
398 $plugin_name = '<a href="' . esc_url( $plugin['url'] ) . '" aria-label="' . esc_attr__( 'Visit plugin homepage', 'woocommerce' ) . '" target="_blank">' . $plugin_name . '</a>';
399 }
400
401 $has_newer_version = false;
402 $version_string = $plugin['version'];
403 $network_string = '';
404 if ( strstr( $plugin['url'], 'woothemes.com' ) || strstr( $plugin['url'], 'woocommerce.com' ) ) {
405 if ( ! empty( $plugin['version_latest'] ) && version_compare( $plugin['version_latest'], $plugin['version'], '>' ) ) {
406 /* translators: 1: current version. 2: latest version */
407 $version_string = sprintf( __( '%1$s (update to version %2$s is available)', 'woocommerce' ), $plugin['version'], $plugin['version_latest'] );
408 }
409
410 if ( false !== $plugin['network_activated'] ) {
411 $network_string = ' &ndash; <strong style="color: black;">' . esc_html__( 'Network enabled', 'woocommerce' ) . '</strong>';
412 }
413 }
414 $untested_string = '';
415 if ( array_key_exists( $plugin['plugin'], $untested_plugins ) ) {
416 $untested_string = ' &ndash; <strong style="color: #a00;">';
417
418 /* translators: %s: version */
419 $untested_string .= esc_html( sprintf( __( 'Installed version not tested with active version of WooCommerce %s', 'woocommerce' ), $wc_version ) );
420
421 $untested_string .= '</strong>';
422 }
423 ?>
424 <tr>
425 <td><?php echo wp_kses_post( $plugin_name ); ?></td>
426 <td class="help">&nbsp;</td>
427 <td>
428 <?php
429 /* translators: %s: plugin author */
430 printf( esc_html__( 'by %s', 'woocommerce' ), esc_html( $plugin['author_name'] ) );
431 echo ' &ndash; ' . esc_html( $version_string ) . $untested_string . $network_string; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
432 ?>
433 </td>
434 </tr>
435 <?php
436 }
437 }
438 }
439 }
440