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