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