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