oont-contents/plugins/xc-woo-google-cloud-print/includes/views/html-admin-page-status-report.php
2025-02-08 15:10:23 +01:00

390 lines
20 KiB
PHP

<?php
/**
* Admin View: Page - Status Report.
*
* @package WooCommerce
*/
defined( 'ABSPATH' ) || exit;
global $wpdb;
$woocommerce = WC();
if (version_compare($woocommerce->version, '3.6', '>=')) {
// This screen requires classes from the REST API.
if ( ! did_action( 'rest_api_init' ) ) {
WC()->api->rest_api_includes();
}
}else{
if ( ! class_exists( 'WC_REST_System_Status_Controller', false ) ) {
wp_die( 'Cannot load the REST API to access WC_REST_System_Status_Controller.' );
}
}
$system_status = new WC_REST_System_Status_Controller();
$environment = $system_status->get_environment_info();
$post_type_counts = $system_status->get_post_type_counts();
$active_plugins = $system_status->get_active_plugins();
$theme = $system_status->get_theme_info();
$security = $system_status->get_security_info();
$settings = $system_status->get_settings();
$pages = $system_status->get_pages();
$plugin_updates = new WC_Plugin_Updates();
$untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor' );
?>
<div class="updated woocommerce-message inline">
<p>
<?php esc_html_e( 'Please copy and paste this information in your ticket when contacting support:', XC_WOO_CLOUD ); ?>
</p>
<p class="submit">
<a href="#" class="button-primary debug-report"><?php esc_html_e( 'Get system report', XC_WOO_CLOUD ); ?></a>
</p>
<div id="debug-report">
<textarea readonly></textarea>
<p class="submit">
<button id="copy-for-support" class="button-primary" href="#" data-tip="<?php esc_attr_e( 'Copied!', XC_WOO_CLOUD ); ?>">
<?php esc_html_e( 'Copy for support', XC_WOO_CLOUD ); ?>
</button>
</p>
<p class="copy-error hidden">
<?php esc_html_e( 'Copying to clipboard failed. Please press Ctrl/Cmd+C to copy.', XC_WOO_CLOUD ); ?>
</p>
</div>
</div>
<table class="wc_status_table widefat" cellspacing="0" id="status">
<thead>
<tr>
<th colspan="3" data-export-label="WordPress Environment"><h2><?php esc_html_e( 'WordPress environment', XC_WOO_CLOUD ); ?></h2></th>
</tr>
</thead>
<tbody>
<tr>
<td data-export-label="Home URL"><?php esc_html_e( 'Home URL', XC_WOO_CLOUD ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The homepage URL of your site.', XC_WOO_CLOUD ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $environment['home_url'] ); ?></td>
</tr>
<tr>
<td data-export-label="Site URL"><?php esc_html_e( 'Site URL', XC_WOO_CLOUD ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The root URL of your site.', XC_WOO_CLOUD ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $environment['site_url'] ); ?></td>
</tr>
<tr>
<td data-export-label="WC Version"><?php esc_html_e( 'WooCommerce version', XC_WOO_CLOUD ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The version of WooCommerce installed on your site.', XC_WOO_CLOUD ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $environment['version'] ); ?></td>
</tr>
<tr>
<td data-export-label="Log Directory Writable"><?php esc_html_e( 'Log directory writable', XC_WOO_CLOUD ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'Several WooCommerce extensions can write logs which makes debugging problems easier. The directory must be writable for this to happen.', XC_WOO_CLOUD ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php
if ( $environment['log_directory_writable'] ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span> <code class="private">' . esc_html( $environment['log_directory'] ) . '</code></mark> ';
} else {
/* Translators: %1$s: Log directory, %2$s: Log directory constant */
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( 'To allow logging, make %1$s writable or define a custom %2$s.', XC_WOO_CLOUD ), '<code>' . esc_html( $environment['log_directory'] ) . '</code>', '<code>WC_LOG_DIR</code>' ) . '</mark>';
}
?>
</td>
</tr>
<tr>
<td data-export-label="WP Version"><?php esc_html_e( 'WordPress version', XC_WOO_CLOUD ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The version of WordPress installed on your site.', XC_WOO_CLOUD ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php
$latest_version = get_transient( 'woocommerce_system_status_wp_version_check' );
if ( false === $latest_version ) {
$version_check = wp_remote_get( 'https://api.wordpress.org/core/version-check/1.7/' );
$api_response = json_decode( wp_remote_retrieve_body( $version_check ), true );
if ( $api_response && isset( $api_response['offers'], $api_response['offers'][0], $api_response['offers'][0]['version'] ) ) {
$latest_version = $api_response['offers'][0]['version'];
} else {
$latest_version = $environment['wp_version'];
}
set_transient( 'woocommerce_system_status_wp_version_check', $latest_version, DAY_IN_SECONDS );
}
if ( version_compare( $environment['wp_version'], $latest_version, '<' ) ) {
/* Translators: %1$s: Current version, %2$s: New version */
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '%1$s - There is a newer version of WordPress available (%2$s)', XC_WOO_CLOUD ), esc_html( $environment['wp_version'] ), esc_html( $latest_version ) ) . '</mark>';
} else {
echo '<mark class="yes">' . esc_html( $environment['wp_version'] ) . '</mark>';
}
?>
</td>
</tr>
<tr>
<td data-export-label="WP Multisite"><?php esc_html_e( 'WordPress multisite', XC_WOO_CLOUD ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'Whether or not you have WordPress Multisite enabled.', XC_WOO_CLOUD ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo ( $environment['wp_multisite'] ) ? '<span class="dashicons dashicons-yes"></span>' : '&ndash;'; ?></td>
</tr>
<tr>
<td data-export-label="WP Memory Limit"><?php esc_html_e( 'WordPress memory limit', XC_WOO_CLOUD ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The maximum amount of memory (RAM) that your site can use at one time.', XC_WOO_CLOUD ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php
if ( $environment['wp_memory_limit'] < 67108864 ) {
/* Translators: %1$s: Memory limit, %2$s: Docs link. */
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '%1$s - We recommend setting memory to at least 64MB. See: %2$s', XC_WOO_CLOUD ), esc_html( size_format( $environment['wp_memory_limit'] ) ), '<a href="https://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP" target="_blank">' . esc_html__( 'Increasing memory allocated to PHP', XC_WOO_CLOUD ) . '</a>' ) . '</mark>';
} else {
echo '<mark class="yes">' . esc_html( size_format( $environment['wp_memory_limit'] ) ) . '</mark>';
}
?>
</td>
</tr>
<tr>
<td data-export-label="WP Debug Mode"><?php esc_html_e( 'WordPress debug mode', XC_WOO_CLOUD ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'Displays whether or not WordPress is in Debug Mode.', XC_WOO_CLOUD ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php if ( $environment['wp_debug_mode'] ) : ?>
<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>
<?php else : ?>
<mark class="no">&ndash;</mark>
<?php endif; ?>
</td>
</tr>
<tr>
<td data-export-label="WP Cron"><?php esc_html_e( 'WordPress cron', XC_WOO_CLOUD ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'Displays whether or not WP Cron Jobs are enabled.', XC_WOO_CLOUD ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php if ( $environment['wp_cron'] ) : ?>
<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>
<?php else : ?>
<mark class="no">&ndash;</mark>
<?php endif; ?>
</td>
</tr>
<tr>
<td data-export-label="Language"><?php esc_html_e( 'Language', XC_WOO_CLOUD ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The current language used by WordPress. Default = English', XC_WOO_CLOUD ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $environment['language'] ); ?></td>
</tr>
<tr>
<td data-export-label="External object cache"><?php esc_html_e( 'External object cache', XC_WOO_CLOUD ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'Displays whether or not WordPress is using an external object cache.', XC_WOO_CLOUD ) ); ?></td>
<td>
<?php if ( $environment['external_object_cache'] ) : ?>
<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>
<?php else : ?>
<mark class="no">&ndash;</mark>
<?php endif; ?>
</td>
</tr>
</tbody>
</table>
<table class="wc_status_table widefat" cellspacing="0">
<thead>
<tr>
<th colspan="3" data-export-label="Server Environment"><h2><?php esc_html_e( 'Server environment', XC_WOO_CLOUD ); ?></h2></th>
</tr>
</thead>
<tbody>
<tr>
<td data-export-label="Server Info"><?php esc_html_e( 'Server info', XC_WOO_CLOUD ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'Information about the web server that is currently hosting your site.', XC_WOO_CLOUD ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $environment['server_info'] ); ?></td>
</tr>
<tr>
<td data-export-label="PHP Version"><?php esc_html_e( 'PHP version', XC_WOO_CLOUD ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The version of PHP installed on your hosting server.', XC_WOO_CLOUD ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php
if ( version_compare( $environment['php_version'], '5.5', '>=' ) ) {
echo '<mark class="yes">' . esc_html( $environment['php_version'] ) . '</mark>';
} else {
$update_link = ' <a href="https://docs.woocommerce.com/document/how-to-update-your-php-version/" target="_blank">' . esc_html__( 'How to update your PHP version', XC_WOO_CLOUD ) . '</a>';
$class = 'error';
if ( version_compare( $environment['php_version'], '5.5', '<' ) ) {
$notice = '<span class="dashicons dashicons-warning"></span> ' . __( 'We recommend using PHP version 5.6 or above for greater performance.', XC_WOO_CLOUD ) . $update_link;
}
echo '<mark class="' . esc_attr( $class ) . '">' . esc_html( $environment['php_version'] ) . ' - ' . wp_kses_post( $notice ) . '</mark>';
}
?>
</td>
</tr>
<tr>
<td data-export-label="DOM extension"><?php esc_html_e( 'DOM extension', XC_WOO_CLOUD ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'Google cloud print will not work without DOM extension', XC_WOO_CLOUD ) ); ?></td>
<td>
<?php
if ( extension_loaded('dom') ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
} else {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( 'Your server does not have the DOM extension enabled - Google cloud print will not work without DOM extension.', XC_WOO_CLOUD )) . '</mark>';
}
?>
</td>
</tr>
<tr>
<td data-export-label="GD extension"><?php esc_html_e( 'GD extension', XC_WOO_CLOUD ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'Google cloud print will not work without GD extension', XC_WOO_CLOUD ) ); ?></td>
<td>
<?php
if ( extension_loaded('gd') ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
} else {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( 'Your server does not have the GD extension enabled - Google cloud print will not work without GD extension.', XC_WOO_CLOUD )) . '</mark>';
}
?>
</td>
</tr>
<tr>
<td data-export-label="Multibyte String"><?php esc_html_e( 'Multibyte string', XC_WOO_CLOUD ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'Multibyte String (mbstring) is used to convert character encoding', XC_WOO_CLOUD ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php
if ( $environment['mbstring_enabled'] ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
} else {
/* Translators: %s: classname and link. */
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( 'Your server does not support the %s functions - this is required for better character encoding. Some fallbacks will be used instead for it.', XC_WOO_CLOUD ), '<a href="https://php.net/manual/en/mbstring.installation.php">mbstring</a>' ) . '</mark>';
}
?>
</td>
</tr>
</tbody>
</table>
<table class="wc_status_table widefat" cellspacing="0">
<thead>
<tr>
<th colspan="3" data-export-label="Active Plugins (<?php echo count( $active_plugins ); ?>)"><h2><?php esc_html_e( 'Active plugins', XC_WOO_CLOUD ); ?> (<?php echo count( $active_plugins ); ?>)</h2></th>
</tr>
</thead>
<tbody>
<?php
foreach ( $active_plugins as $plugin ) {
if ( ! empty( $plugin['name'] ) ) {
$dirname = dirname( $plugin['plugin'] );
// Link the plugin name to the plugin url if available.
$plugin_name = esc_html( $plugin['name'] );
if ( ! empty( $plugin['url'] ) ) {
$plugin_name = '<a href="' . esc_url( $plugin['url'] ) . '" aria-label="' . esc_attr__( 'Visit plugin homepage', XC_WOO_CLOUD ) . '" target="_blank">' . $plugin_name . '</a>';
}
$version_string = '';
$network_string = '';
if ( strstr( $plugin['url'], 'woothemes.com' ) || strstr( $plugin['url'], 'woocommerce.com' ) ) {
if ( ! empty( $plugin['version_latest'] ) && version_compare( $plugin['version_latest'], $plugin['version'], '>' ) ) {
/* translators: %s: plugin latest version */
$version_string = ' &ndash; <strong style="color:red;">' . sprintf( esc_html__( '%s is available', XC_WOO_CLOUD ), $plugin['version_latest'] ) . '</strong>';
}
if ( false !== $plugin['network_activated'] ) {
$network_string = ' &ndash; <strong style="color:black;">' . esc_html__( 'Network enabled', XC_WOO_CLOUD ) . '</strong>';
}
}
$untested_string = '';
if ( array_key_exists( $plugin['plugin'], $untested_plugins ) ) {
$untested_string = ' &ndash; <strong style="color:red;">' . esc_html__( 'Not tested with the active version of WooCommerce', XC_WOO_CLOUD ) . '</strong>';
}
?>
<tr>
<td><?php echo wp_kses_post( $plugin_name ); ?></td>
<td class="help">&nbsp;</td>
<td>
<?php
/* translators: %s: plugin author */
printf( esc_html__( 'by %s', XC_WOO_CLOUD ), esc_html( $plugin['author_name'] ) );
echo ' &ndash; ' . esc_html( $plugin['version'] ) . $version_string . $untested_string . $network_string; // WPCS: XSS ok.
?>
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
<table class="wc_status_table widefat" cellspacing="0">
<thead>
<tr>
<th colspan="3" data-export-label="Theme"><h2><?php esc_html_e( 'Theme', XC_WOO_CLOUD ); ?></h2></th>
</tr>
</thead>
<tbody>
<tr>
<td data-export-label="Name"><?php esc_html_e( 'Name', XC_WOO_CLOUD ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The name of the current active theme.', XC_WOO_CLOUD ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $theme['name'] ); ?></td>
</tr>
<tr>
<td data-export-label="Version"><?php esc_html_e( 'Version', XC_WOO_CLOUD ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The installed version of the current active theme.', XC_WOO_CLOUD ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php
echo esc_html( $theme['version'] );
if ( version_compare( $theme['version'], $theme['version_latest'], '<' ) ) {
/* translators: %s: theme latest version */
echo ' &ndash; <strong style="color:red;">' . sprintf( esc_html__( '%s is available', XC_WOO_CLOUD ), esc_html( $theme['version_latest'] ) ) . '</strong>';
}
?>
</td>
</tr>
<tr>
<td data-export-label="Author URL"><?php esc_html_e( 'Author URL', XC_WOO_CLOUD ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The theme developers URL.', XC_WOO_CLOUD ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $theme['author_url'] ); ?></td>
</tr>
<tr>
<td data-export-label="Child Theme"><?php esc_html_e( 'Child theme', XC_WOO_CLOUD ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'Displays whether or not the current theme is a child theme.', XC_WOO_CLOUD ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php
if ( $theme['is_child_theme'] ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
} else {
/* Translators: %s docs link. */
echo '<span class="dashicons dashicons-no-alt"></span> &ndash; ' . wp_kses_post( sprintf( __( 'If you are modifying WooCommerce on a parent theme that you did not build personally we recommend using a child theme. See: <a href="%s" target="_blank">How to create a child theme</a>', XC_WOO_CLOUD ), 'https://codex.wordpress.org/Child_Themes' ) );
}
?>
</td>
</tr>
<?php if ( $theme['is_child_theme'] ) : ?>
<tr>
<td data-export-label="Parent Theme Name"><?php esc_html_e( 'Parent theme name', XC_WOO_CLOUD ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The name of the parent theme.', XC_WOO_CLOUD ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $theme['parent_name'] ); ?></td>
</tr>
<tr>
<td data-export-label="Parent Theme Version"><?php esc_html_e( 'Parent theme version', XC_WOO_CLOUD ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The installed version of the parent theme.', XC_WOO_CLOUD ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php
echo esc_html( $theme['parent_version'] );
if ( version_compare( $theme['parent_version'], $theme['parent_version_latest'], '<' ) ) {
/* translators: %s: parent theme latest version */
echo ' &ndash; <strong style="color:red;">' . sprintf( esc_html__( '%s is available', XC_WOO_CLOUD ), esc_html( $theme['parent_version_latest'] ) ) . '</strong>';
}
?>
</td>
</tr>
<tr>
<td data-export-label="Parent Theme Author URL"><?php esc_html_e( 'Parent theme author URL', XC_WOO_CLOUD ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'The parent theme developers URL.', XC_WOO_CLOUD ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td><?php echo esc_html( $theme['parent_author_url'] ); ?></td>
</tr>
<?php endif ?>
<tr>
<td data-export-label="WooCommerce Support"><?php esc_html_e( 'WooCommerce support', XC_WOO_CLOUD ); ?>:</td>
<td class="help"><?php echo wc_help_tip( esc_html__( 'Displays whether or not the current active theme declares WooCommerce support.', XC_WOO_CLOUD ) ); /* phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped */ ?></td>
<td>
<?php
if ( ! $theme['has_woocommerce_support'] ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . esc_html__( 'Not declared', XC_WOO_CLOUD ) . '</mark>';
} else {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
}
?>
</td>
</tr>
</tbody>
</table>
<?php do_action( 'xc_woo_cloud_system_status_report' ); ?>