Automatically fix coding standard violations using phpcbf

This commit is contained in:
Rodrigo Primo 2018-01-25 12:15:48 -02:00
parent e2d553fb61
commit a15ecc1601
3 changed files with 478 additions and 414 deletions

View File

@ -13,7 +13,7 @@ if ( ! class_exists( 'WC_REST_System_Status_Controller', false ) ) {
wp_die( 'Cannot load the REST API to access WC_REST_System_Status_Controller.' ); wp_die( 'Cannot load the REST API to access WC_REST_System_Status_Controller.' );
} }
$system_status = new WC_REST_System_Status_Controller; $system_status = new WC_REST_System_Status_Controller();
$environment = $system_status->get_environment_info(); $environment = $system_status->get_environment_info();
$database = $system_status->get_database_info(); $database = $system_status->get_database_info();
$post_type_counts = $system_status->get_post_type_counts(); $post_type_counts = $system_status->get_post_type_counts();
@ -22,7 +22,7 @@ $theme = $system_status->get_theme_info();
$security = $system_status->get_security_info(); $security = $system_status->get_security_info();
$settings = $system_status->get_settings(); $settings = $system_status->get_settings();
$pages = $system_status->get_pages(); $pages = $system_status->get_pages();
$plugin_updates = new WC_Plugin_Updates; $plugin_updates = new WC_Plugin_Updates();
$untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor' ); $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor' );
?> ?>
<div class="updated woocommerce-message inline"> <div class="updated woocommerce-message inline">
@ -45,33 +45,35 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<tr> <tr>
<td data-export-label="Home URL"><?php _e( 'Home URL', 'woocommerce' ); ?>:</td> <td data-export-label="Home URL"><?php _e( 'Home URL', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The homepage URL of your site.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'The homepage URL of your site.', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( $environment['home_url'] ) ?></td> <td><?php echo esc_html( $environment['home_url'] ); ?></td>
</tr> </tr>
<tr> <tr>
<td data-export-label="Site URL"><?php _e( 'Site URL', 'woocommerce' ); ?>:</td> <td data-export-label="Site URL"><?php _e( 'Site URL', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The root URL of your site.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'The root URL of your site.', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( $environment['site_url'] ) ?></td> <td><?php echo esc_html( $environment['site_url'] ); ?></td>
</tr> </tr>
<tr> <tr>
<td data-export-label="WC Version"><?php _e( 'WC version', 'woocommerce' ); ?>:</td> <td data-export-label="WC Version"><?php _e( 'WC version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The version of WooCommerce installed on your site.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'The version of WooCommerce installed on your site.', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( $environment['version'] ) ?></td> <td><?php echo esc_html( $environment['version'] ); ?></td>
</tr> </tr>
<tr> <tr>
<td data-export-label="Log Directory Writable"><?php _e( 'Log directory writable', 'woocommerce' ); ?>:</td> <td data-export-label="Log Directory Writable"><?php _e( 'Log directory writable', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Several WooCommerce extensions can write logs which makes debugging problems easier. The directory must be writable for this to happen.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'Several WooCommerce extensions can write logs which makes debugging problems easier. The directory must be writable for this to happen.', 'woocommerce' ) ); ?></td>
<td><?php <td>
<?php
if ( $environment['log_directory_writable'] ) { 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> '; echo '<mark class="yes"><span class="dashicons dashicons-yes"></span> <code class="private">' . esc_html( $environment['log_directory'] ) . '</code></mark> ';
} else { } else {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'To allow logging, make %1$s writable or define a custom %2$s.', 'woocommerce' ), '<code>' . $environment['log_directory'] . '</code>', '<code>WC_LOG_DIR</code>' ) . '</mark>'; echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'To allow logging, make %1$s writable or define a custom %2$s.', 'woocommerce' ), '<code>' . $environment['log_directory'] . '</code>', '<code>WC_LOG_DIR</code>' ) . '</mark>';
} }
?></td> ?>
</td>
</tr> </tr>
<tr> <tr>
<td data-export-label="WP Version"><?php _e( 'WP version', 'woocommerce' ); ?>:</td> <td data-export-label="WP Version"><?php _e( 'WP version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The version of WordPress installed on your site.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'The version of WordPress installed on your site.', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( $environment['wp_version'] ) ?></td> <td><?php echo esc_html( $environment['wp_version'] ); ?></td>
</tr> </tr>
<tr> <tr>
<td data-export-label="WP Multisite"><?php _e( 'WP multisite', 'woocommerce' ); ?>:</td> <td data-export-label="WP Multisite"><?php _e( 'WP multisite', 'woocommerce' ); ?>:</td>
@ -81,13 +83,15 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<tr> <tr>
<td data-export-label="WP Memory Limit"><?php _e( 'WP memory limit', 'woocommerce' ); ?>:</td> <td data-export-label="WP Memory Limit"><?php _e( 'WP memory limit', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The maximum amount of memory (RAM) that your site can use at one time.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'The maximum amount of memory (RAM) that your site can use at one time.', 'woocommerce' ) ); ?></td>
<td><?php <td>
<?php
if ( $environment['wp_memory_limit'] < 67108864 ) { if ( $environment['wp_memory_limit'] < 67108864 ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%1$s - We recommend setting memory to at least 64MB. See: %2$s', 'woocommerce' ), size_format( $environment['wp_memory_limit'] ), '<a href="https://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP" target="_blank">' . __( 'Increasing memory allocated to PHP', 'woocommerce' ) . '</a>' ) . '</mark>'; echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%1$s - We recommend setting memory to at least 64MB. See: %2$s', 'woocommerce' ), size_format( $environment['wp_memory_limit'] ), '<a href="https://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP" target="_blank">' . __( 'Increasing memory allocated to PHP', 'woocommerce' ) . '</a>' ) . '</mark>';
} else { } else {
echo '<mark class="yes">' . size_format( $environment['wp_memory_limit'] ) . '</mark>'; echo '<mark class="yes">' . size_format( $environment['wp_memory_limit'] ) . '</mark>';
} }
?></td> ?>
</td>
</tr> </tr>
<tr> <tr>
<td data-export-label="WP Debug Mode"><?php _e( 'WP debug mode', 'woocommerce' ); ?>:</td> <td data-export-label="WP Debug Mode"><?php _e( 'WP debug mode', 'woocommerce' ); ?>:</td>
@ -114,7 +118,7 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<tr> <tr>
<td data-export-label="Language"><?php _e( 'Language', 'woocommerce' ); ?>:</td> <td data-export-label="Language"><?php _e( 'Language', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The current language used by WordPress. Default = English', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'The current language used by WordPress. Default = English', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( $environment['language'] ) ?></td> <td><?php echo esc_html( $environment['language'] ); ?></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -133,34 +137,36 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<tr> <tr>
<td data-export-label="PHP Version"><?php _e( 'PHP version', 'woocommerce' ); ?>:</td> <td data-export-label="PHP Version"><?php _e( 'PHP version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The version of PHP installed on your hosting server.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'The version of PHP installed on your hosting server.', 'woocommerce' ) ); ?></td>
<td><?php <td>
<?php
if ( version_compare( $environment['php_version'], '5.6', '<' ) ) { if ( version_compare( $environment['php_version'], '5.6', '<' ) ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%1$s - We recommend a minimum PHP version of 5.6. See: %2$s', 'woocommerce' ), esc_html( $environment['php_version'] ), '<a href="https://docs.woocommerce.com/document/how-to-update-your-php-version/" target="_blank">' . __( 'How to update your PHP version', 'woocommerce' ) . '</a>' ) . '</mark>'; echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%1$s - We recommend a minimum PHP version of 5.6. See: %2$s', 'woocommerce' ), esc_html( $environment['php_version'] ), '<a href="https://docs.woocommerce.com/document/how-to-update-your-php-version/" target="_blank">' . __( 'How to update your PHP version', 'woocommerce' ) . '</a>' ) . '</mark>';
} else { } else {
echo '<mark class="yes">' . esc_html( $environment['php_version'] ) . '</mark>'; echo '<mark class="yes">' . esc_html( $environment['php_version'] ) . '</mark>';
} }
?></td> ?>
</td>
</tr> </tr>
<?php if ( function_exists( 'ini_get' ) ) : ?> <?php if ( function_exists( 'ini_get' ) ) : ?>
<tr> <tr>
<td data-export-label="PHP Post Max Size"><?php _e( 'PHP post max size', 'woocommerce' ); ?>:</td> <td data-export-label="PHP Post Max Size"><?php _e( 'PHP post max size', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The largest filesize that can be contained in one post.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'The largest filesize that can be contained in one post.', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( size_format( $environment['php_post_max_size'] ) ) ?></td> <td><?php echo esc_html( size_format( $environment['php_post_max_size'] ) ); ?></td>
</tr> </tr>
<tr> <tr>
<td data-export-label="PHP Time Limit"><?php _e( 'PHP time limit', 'woocommerce' ); ?>:</td> <td data-export-label="PHP Time Limit"><?php _e( 'PHP time limit', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The amount of time (in seconds) that your site will spend on a single operation before timing out (to avoid server lockups)', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'The amount of time (in seconds) that your site will spend on a single operation before timing out (to avoid server lockups)', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( $environment['php_max_execution_time'] ) ?></td> <td><?php echo esc_html( $environment['php_max_execution_time'] ); ?></td>
</tr> </tr>
<tr> <tr>
<td data-export-label="PHP Max Input Vars"><?php _e( 'PHP max input vars', 'woocommerce' ); ?>:</td> <td data-export-label="PHP Max Input Vars"><?php _e( 'PHP max input vars', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The maximum number of variables your server can use for a single function to avoid overloads.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'The maximum number of variables your server can use for a single function to avoid overloads.', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( $environment['php_max_input_vars'] ) ?></td> <td><?php echo esc_html( $environment['php_max_input_vars'] ); ?></td>
</tr> </tr>
<tr> <tr>
<td data-export-label="cURL Version"><?php _e( 'cURL version', 'woocommerce' ); ?>:</td> <td data-export-label="cURL Version"><?php _e( 'cURL version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The version of cURL installed on your server.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'The version of cURL installed on your server.', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( $environment['curl_version'] ) ?></td> <td><?php echo esc_html( $environment['curl_version'] ); ?></td>
</tr> </tr>
<tr> <tr>
<td data-export-label="SUHOSIN Installed"><?php _e( 'SUHOSIN installed', 'woocommerce' ); ?>:</td> <td data-export-label="SUHOSIN Installed"><?php _e( 'SUHOSIN installed', 'woocommerce' ); ?>:</td>
@ -191,94 +197,110 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<tr> <tr>
<td data-export-label="Max Upload Size"><?php _e( 'Max upload size', 'woocommerce' ); ?>:</td> <td data-export-label="Max Upload Size"><?php _e( 'Max upload size', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The largest filesize that can be uploaded to your WordPress installation.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'The largest filesize that can be uploaded to your WordPress installation.', 'woocommerce' ) ); ?></td>
<td><?php echo size_format( $environment['max_upload_size'] ) ?></td> <td><?php echo size_format( $environment['max_upload_size'] ); ?></td>
</tr> </tr>
<tr> <tr>
<td data-export-label="Default Timezone is UTC"><?php _e( 'Default timezone is UTC', 'woocommerce' ); ?>:</td> <td data-export-label="Default Timezone is UTC"><?php _e( 'Default timezone is UTC', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The default timezone for your server.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'The default timezone for your server.', 'woocommerce' ) ); ?></td>
<td><?php <td>
<?php
if ( 'UTC' !== $environment['default_timezone'] ) { if ( 'UTC' !== $environment['default_timezone'] ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Default timezone is %s - it should be UTC', 'woocommerce' ), $environment['default_timezone'] ) . '</mark>'; echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Default timezone is %s - it should be UTC', 'woocommerce' ), $environment['default_timezone'] ) . '</mark>';
} else { } else {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
} ?> }
?>
</td> </td>
</tr> </tr>
<tr> <tr>
<td data-export-label="fsockopen/cURL"><?php _e( 'fsockopen/cURL', 'woocommerce' ); ?>:</td> <td data-export-label="fsockopen/cURL"><?php _e( 'fsockopen/cURL', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Payment gateways can use cURL to communicate with remote servers to authorize payments, other plugins may also use it when communicating with remote services.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'Payment gateways can use cURL to communicate with remote servers to authorize payments, other plugins may also use it when communicating with remote services.', 'woocommerce' ) ); ?></td>
<td><?php <td>
<?php
if ( $environment['fsockopen_or_curl_enabled'] ) { if ( $environment['fsockopen_or_curl_enabled'] ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
} else { } else {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'woocommerce' ) . '</mark>'; echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'woocommerce' ) . '</mark>';
} ?> }
?>
</td> </td>
</tr> </tr>
<tr> <tr>
<td data-export-label="SoapClient"><?php _e( 'SoapClient', 'woocommerce' ); ?>:</td> <td data-export-label="SoapClient"><?php _e( 'SoapClient', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Some webservices like shipping use SOAP to get information from remote servers, for example, live shipping quotes from FedEx require SOAP to be installed.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'Some webservices like shipping use SOAP to get information from remote servers, for example, live shipping quotes from FedEx require SOAP to be installed.', 'woocommerce' ) ); ?></td>
<td><?php <td>
<?php
if ( $environment['soapclient_enabled'] ) { if ( $environment['soapclient_enabled'] ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
} else { } else {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Your server does not have the %s class enabled - some gateway plugins which use SOAP may not work as expected.', 'woocommerce' ), '<a href="https://php.net/manual/en/class.soapclient.php">SoapClient</a>' ) . '</mark>'; echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Your server does not have the %s class enabled - some gateway plugins which use SOAP may not work as expected.', 'woocommerce' ), '<a href="https://php.net/manual/en/class.soapclient.php">SoapClient</a>' ) . '</mark>';
} ?> }
?>
</td> </td>
</tr> </tr>
<tr> <tr>
<td data-export-label="DOMDocument"><?php _e( 'DOMDocument', 'woocommerce' ); ?>:</td> <td data-export-label="DOMDocument"><?php _e( 'DOMDocument', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'HTML/Multipart emails use DOMDocument to generate inline CSS in templates.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'HTML/Multipart emails use DOMDocument to generate inline CSS in templates.', 'woocommerce' ) ); ?></td>
<td><?php <td>
<?php
if ( $environment['domdocument_enabled'] ) { if ( $environment['domdocument_enabled'] ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
} else { } else {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Your server does not have the %s class enabled - HTML/Multipart emails, and also some extensions, will not work without DOMDocument.', 'woocommerce' ), '<a href="https://php.net/manual/en/class.domdocument.php">DOMDocument</a>' ) . '</mark>'; echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Your server does not have the %s class enabled - HTML/Multipart emails, and also some extensions, will not work without DOMDocument.', 'woocommerce' ), '<a href="https://php.net/manual/en/class.domdocument.php">DOMDocument</a>' ) . '</mark>';
} ?> }
?>
</td> </td>
</tr> </tr>
<tr> <tr>
<td data-export-label="GZip"><?php _e( 'GZip', 'woocommerce' ); ?>:</td> <td data-export-label="GZip"><?php _e( 'GZip', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'GZip (gzopen) is used to open the GEOIP database from MaxMind.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'GZip (gzopen) is used to open the GEOIP database from MaxMind.', 'woocommerce' ) ); ?></td>
<td><?php <td>
<?php
if ( $environment['gzip_enabled'] ) { if ( $environment['gzip_enabled'] ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
} else { } else {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Your server does not support the %s function - this is required to use the GeoIP database from MaxMind.', 'woocommerce' ), '<a href="https://php.net/manual/en/zlib.installation.php">gzopen</a>' ) . '</mark>'; echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Your server does not support the %s function - this is required to use the GeoIP database from MaxMind.', 'woocommerce' ), '<a href="https://php.net/manual/en/zlib.installation.php">gzopen</a>' ) . '</mark>';
} ?> }
?>
</td> </td>
</tr> </tr>
<tr> <tr>
<td data-export-label="Multibyte String"><?php _e( 'Multibyte string', 'woocommerce' ); ?>:</td> <td data-export-label="Multibyte String"><?php _e( 'Multibyte string', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Multibyte String (mbstring) is used to convert character encoding, like for emails or converting characters to lowercase.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'Multibyte String (mbstring) is used to convert character encoding, like for emails or converting characters to lowercase.', 'woocommerce' ) ); ?></td>
<td><?php <td>
<?php
if ( $environment['mbstring_enabled'] ) { if ( $environment['mbstring_enabled'] ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
} else { } else {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Your server does not support the %s functions - this is required for better character encoding. Some fallbacks will be used instead for it.', 'woocommerce' ), '<a href="https://php.net/manual/en/mbstring.installation.php">mbstring</a>' ) . '</mark>'; echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Your server does not support the %s functions - this is required for better character encoding. Some fallbacks will be used instead for it.', 'woocommerce' ), '<a href="https://php.net/manual/en/mbstring.installation.php">mbstring</a>' ) . '</mark>';
} ?> }
?>
</td> </td>
</tr> </tr>
<tr> <tr>
<td data-export-label="Remote Post"><?php _e( 'Remote post', 'woocommerce' ); ?>:</td> <td data-export-label="Remote Post"><?php _e( 'Remote post', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'PayPal uses this method of communicating when sending back transaction information.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'PayPal uses this method of communicating when sending back transaction information.', 'woocommerce' ) ); ?></td>
<td><?php <td>
<?php
if ( $environment['remote_post_successful'] ) { if ( $environment['remote_post_successful'] ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
} else { } else {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%s failed. Contact your hosting provider.', 'woocommerce' ), 'wp_remote_post()' ) . ' ' . esc_html( $environment['remote_post_response'] ) . '</mark>'; echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%s failed. Contact your hosting provider.', 'woocommerce' ), 'wp_remote_post()' ) . ' ' . esc_html( $environment['remote_post_response'] ) . '</mark>';
} ?> }
?>
</td> </td>
</tr> </tr>
<tr> <tr>
<td data-export-label="Remote Get"><?php _e( 'Remote get', 'woocommerce' ); ?>:</td> <td data-export-label="Remote Get"><?php _e( 'Remote get', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'WooCommerce plugins may use this method of communication when checking for plugin updates.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'WooCommerce plugins may use this method of communication when checking for plugin updates.', 'woocommerce' ) ); ?></td>
<td><?php <td>
<?php
if ( $environment['remote_get_successful'] ) { if ( $environment['remote_get_successful'] ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
} else { } else {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%s failed. Contact your hosting provider.', 'woocommerce' ), 'wp_remote_get()' ) . ' ' . esc_html( $environment['remote_get_response'] ) . '</mark>'; echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%s failed. Contact your hosting provider.', 'woocommerce' ), 'wp_remote_get()' ) . ' ' . esc_html( $environment['remote_get_response'] ) . '</mark>';
} ?> }
?>
</td> </td>
</tr> </tr>
<?php <?php
@ -286,10 +308,10 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
foreach ( $rows as $row ) { foreach ( $rows as $row ) {
if ( ! empty( $row['success'] ) ) { if ( ! empty( $row['success'] ) ) {
$css_class = 'yes'; $css_class = 'yes';
$icon = '<span class="dashicons dashicons-yes"></span>'; $icon = '<span class="dashicons dashicons-yes"></span>';
} else { } else {
$css_class = 'error'; $css_class = 'error';
$icon = '<span class="dashicons dashicons-no-alt"></span>'; $icon = '<span class="dashicons dashicons-no-alt"></span>';
} }
?> ?>
<tr> <tr>
@ -300,111 +322,118 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<?php echo $icon; ?> <?php echo ! empty( $row['note'] ) ? wp_kses_data( $row['note'] ) : ''; ?> <?php echo $icon; ?> <?php echo ! empty( $row['note'] ) ? wp_kses_data( $row['note'] ) : ''; ?>
</mark> </mark>
</td> </td>
</tr><?php </tr>
} ?> <?php
}
?>
</tbody> </tbody>
</table> </table>
<table class="wc_status_table widefat" cellspacing="0"> <table class="wc_status_table widefat" cellspacing="0">
<thead> <thead>
<tr> <tr>
<th colspan="3" data-export-label="Database"><h2><?php _e( 'Database', 'woocommerce' ); ?></h2></th> <th colspan="3" data-export-label="Database"><h2><?php _e( 'Database', 'woocommerce' ); ?></h2></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td data-export-label="WC Database Version"><?php _e( 'WC database version', 'woocommerce' ); ?>:</td> <td data-export-label="WC Database Version"><?php _e( 'WC database version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The version of WooCommerce that the database is formatted for. This should be the same as your WooCommerce version.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'The version of WooCommerce that the database is formatted for. This should be the same as your WooCommerce version.', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( $database['wc_database_version'] ); ?></td> <td><?php echo esc_html( $database['wc_database_version'] ); ?></td>
</tr> </tr>
<tr> <tr>
<td data-export-label="WC Database Prefix"><?php _e( 'Database prefix', 'woocommerce' ); ?></td> <td data-export-label="WC Database Prefix"><?php _e( 'Database prefix', 'woocommerce' ); ?></td>
<td class="help">&nbsp;</td> <td class="help">&nbsp;</td>
<td><?php <td>
if ( strlen( $database['database_prefix'] ) > 20 ) { <?php
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%1$s - We recommend using a prefix with less than 20 characters. See: %2$s', 'woocommerce' ), esc_html( $database['database_prefix'] ), '<a href="https://docs.woocommerce.com/document/completed-order-email-doesnt-contain-download-links/#section-2" target="_blank">' . __( 'How to update your database table prefix', 'woocommerce' ) . '</a>' ) . '</mark>'; if ( strlen( $database['database_prefix'] ) > 20 ) {
} else { echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%1$s - We recommend using a prefix with less than 20 characters. See: %2$s', 'woocommerce' ), esc_html( $database['database_prefix'] ), '<a href="https://docs.woocommerce.com/document/completed-order-email-doesnt-contain-download-links/#section-2" target="_blank">' . __( 'How to update your database table prefix', 'woocommerce' ) . '</a>' ) . '</mark>';
echo '<mark class="yes">' . esc_html( $database['database_prefix'] ) . '</mark>'; } else {
} echo '<mark class="yes">' . esc_html( $database['database_prefix'] ) . '</mark>';
?> }
</td> ?>
</tr> </td>
</tr>
<?php if ( $settings['geolocation_enabled'] ) { ?> <?php if ( $settings['geolocation_enabled'] ) { ?>
<tr> <tr>
<td data-export-label="MaxMind GeoIP Database"><?php _e( 'MaxMind GeoIP database', 'woocommerce' ); ?>:</td> <td data-export-label="MaxMind GeoIP Database"><?php _e( 'MaxMind GeoIP database', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The GeoIP database from MaxMind is used to geolocate customers.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'The GeoIP database from MaxMind is used to geolocate customers.', 'woocommerce' ) ); ?></td>
<td><?php <td>
if ( file_exists( $database['maxmind_geoip_database'] ) ) { <?php
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span> <code class="private">' . esc_html( $database['maxmind_geoip_database'] ) . '</code></mark> '; if ( file_exists( $database['maxmind_geoip_database'] ) ) {
} else { echo '<mark class="yes"><span class="dashicons dashicons-yes"></span> <code class="private">' . esc_html( $database['maxmind_geoip_database'] ) . '</code></mark> ';
printf( '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'The MaxMind GeoIP Database does not exist - Geolocation will not function. You can download and install it manually from %1$s to the path: %2$s. Scroll down to "Downloads" and download the "Binary / gzip" file next to "GeoLite Country". Please remember to uncompress GeoIP.dat.gz and upload the GeoIP.dat file only.', 'woocommerce' ), make_clickable( 'http://dev.maxmind.com/geoip/legacy/geolite/' ), '<code class="private">' . $database['maxmind_geoip_database'] . '</code>' ) . '</mark>', WC_LOG_DIR ); } else {
} printf( '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'The MaxMind GeoIP Database does not exist - Geolocation will not function. You can download and install it manually from %1$s to the path: %2$s. Scroll down to "Downloads" and download the "Binary / gzip" file next to "GeoLite Country". Please remember to uncompress GeoIP.dat.gz and upload the GeoIP.dat file only.', 'woocommerce' ), make_clickable( 'http://dev.maxmind.com/geoip/legacy/geolite/' ), '<code class="private">' . $database['maxmind_geoip_database'] . '</code>' ) . '</mark>', WC_LOG_DIR );
?></td> }
</tr> ?>
<?php } ?> </td>
</tr>
<?php } ?>
<tr> <tr>
<td><?php _e( 'Total Database Size', 'woocommerce' ); ?></td> <td><?php _e( 'Total Database Size', 'woocommerce' ); ?></td>
<td class="help">&nbsp;</td> <td class="help">&nbsp;</td>
<td><?php printf( '%.2fMB', $database['database_size']['data'] + $database['database_size']['index'] ); ?></td> <td><?php printf( '%.2fMB', $database['database_size']['data'] + $database['database_size']['index'] ); ?></td>
</tr> </tr>
<tr> <tr>
<td><?php _e( 'Database Data Size', 'woocommerce' ); ?></td> <td><?php _e( 'Database Data Size', 'woocommerce' ); ?></td>
<td class="help">&nbsp;</td> <td class="help">&nbsp;</td>
<td><?php printf( '%.2fMB', $database['database_size']['data'] ); ?></td> <td><?php printf( '%.2fMB', $database['database_size']['data'] ); ?></td>
</tr> </tr>
<tr> <tr>
<td><?php _e( 'Database Index Size', 'woocommerce' ); ?></td> <td><?php _e( 'Database Index Size', 'woocommerce' ); ?></td>
<td class="help">&nbsp;</td> <td class="help">&nbsp;</td>
<td><?php printf( '%.2fMB', $database['database_size']['index'] ); ?></td> <td><?php printf( '%.2fMB', $database['database_size']['index'] ); ?></td>
</tr> </tr>
<?php foreach ( $database['database_tables']['woocommerce'] as $table => $table_data ) { ?> <?php foreach ( $database['database_tables']['woocommerce'] as $table => $table_data ) { ?>
<tr> <tr>
<td><?php echo esc_html( $table ); ?></td> <td><?php echo esc_html( $table ); ?></td>
<td class="help">&nbsp;</td> <td class="help">&nbsp;</td>
<td> <td>
<?php if( ! $table_data ) { <?php
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'Table does not exist', 'woocommerce' ) . '</mark>'; if ( ! $table_data ) {
} else { echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'Table does not exist', 'woocommerce' ) . '</mark>';
printf( __( 'Data: %.2fMB + Index: %.2fMB', 'woocommerce' ), wc_format_decimal( $table_data['data'], 2 ), wc_format_decimal( $table_data['index'], 2 ) ); } else {
} ?> printf( __( 'Data: %1$.2fMB + Index: %2$.2fMB', 'woocommerce' ), wc_format_decimal( $table_data['data'], 2 ), wc_format_decimal( $table_data['index'], 2 ) );
</td> }
</tr> ?>
<?php } ?> </td>
</tr>
<?php } ?>
<?php foreach ( $database['database_tables']['other'] as $table => $table_data ) { ?> <?php foreach ( $database['database_tables']['other'] as $table => $table_data ) { ?>
<tr> <tr>
<td><?php echo esc_html( $table ); ?></td> <td><?php echo esc_html( $table ); ?></td>
<td class="help">&nbsp;</td> <td class="help">&nbsp;</td>
<td> <td>
<?php printf( __( 'Data: %.2fMB + Index: %.2fMB', 'woocommerce' ), wc_format_decimal( $table_data['data'], 2 ), wc_format_decimal( $table_data['index'], 2 ) ); ?> <?php printf( __( 'Data: %1$.2fMB + Index: %2$.2fMB', 'woocommerce' ), wc_format_decimal( $table_data['data'], 2 ), wc_format_decimal( $table_data['index'], 2 ) ); ?>
</td> </td>
</tr> </tr>
<?php } ?> <?php } ?>
</tbody> </tbody>
</table> </table>
<table class="wc_status_table widefat" cellspacing="0"> <table class="wc_status_table widefat" cellspacing="0">
<thead> <thead>
<tr> <tr>
<th colspan="3" data-export-label="Post Type Counts"><h2><?php _e( 'Post Type Counts', 'woocommerce' ); ?></h2></th> <th colspan="3" data-export-label="Post Type Counts"><h2><?php _e( 'Post Type Counts', 'woocommerce' ); ?></h2></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php
foreach ( $post_type_counts as $post_type ) {
?>
<tr>
<td><?php echo esc_html( $post_type->type ); ?></td>
<td class="help">&nbsp;</td>
<td><?php echo absint( $post_type->count ); ?></td>
</tr>
<?php <?php
} foreach ( $post_type_counts as $post_type ) {
?> ?>
</tbody> <tr>
<td><?php echo esc_html( $post_type->type ); ?></td>
<td class="help">&nbsp;</td>
<td><?php echo absint( $post_type->count ); ?></td>
</tr>
<?php
}
?>
</tbody>
</table> </table>
<table class="wc_status_table widefat" cellspacing="0"> <table class="wc_status_table widefat" cellspacing="0">
<thead> <thead>
@ -440,7 +469,7 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<table class="wc_status_table widefat" cellspacing="0"> <table class="wc_status_table widefat" cellspacing="0">
<thead> <thead>
<tr> <tr>
<th colspan="3" data-export-label="Active Plugins (<?php echo count( $active_plugins ) ?>)"><h2><?php _e( 'Active plugins', 'woocommerce' ); ?> (<?php echo count( $active_plugins ) ?>)</h2></th> <th colspan="3" data-export-label="Active Plugins (<?php echo count( $active_plugins ); ?>)"><h2><?php _e( 'Active plugins', 'woocommerce' ); ?> (<?php echo count( $active_plugins ); ?>)</h2></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -452,7 +481,7 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
// Link the plugin name to the plugin url if available. // Link the plugin name to the plugin url if available.
$plugin_name = esc_html( $plugin['name'] ); $plugin_name = esc_html( $plugin['name'] );
if ( ! empty( $plugin['url'] ) ) { if ( ! empty( $plugin['url'] ) ) {
$plugin_name = '<a href="' . esc_url( $plugin['url'] ) . '" aria-label="' . esc_attr__( 'Visit plugin homepage' , 'woocommerce' ) . '" target="_blank">' . $plugin_name . '</a>'; $plugin_name = '<a href="' . esc_url( $plugin['url'] ) . '" aria-label="' . esc_attr__( 'Visit plugin homepage', 'woocommerce' ) . '" target="_blank">' . $plugin_name . '</a>';
} }
$version_string = ''; $version_string = '';
@ -475,11 +504,13 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<tr> <tr>
<td><?php echo $plugin_name; ?></td> <td><?php echo $plugin_name; ?></td>
<td class="help">&nbsp;</td> <td class="help">&nbsp;</td>
<td><?php <td>
<?php
/* translators: %s: plugin author */ /* translators: %s: plugin author */
printf( __( 'by %s', 'woocommerce' ), $plugin['author_name'] ); printf( __( 'by %s', 'woocommerce' ), $plugin['author_name'] );
echo ' &ndash; ' . esc_html( $plugin['version'] ) . $version_string . $untested_string . $network_string; echo ' &ndash; ' . esc_html( $plugin['version'] ) . $version_string . $untested_string . $network_string;
?></td> ?>
</td>
</tr> </tr>
<?php <?php
} }
@ -505,51 +536,55 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<td><?php echo $settings['force_ssl'] ? '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>' : '<mark class="no">&ndash;</mark>'; ?></td> <td><?php echo $settings['force_ssl'] ? '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>' : '<mark class="no">&ndash;</mark>'; ?></td>
</tr> </tr>
<tr> <tr>
<td data-export-label="Currency"><?php _e( 'Currency', 'woocommerce' ) ?></td> <td data-export-label="Currency"><?php _e( 'Currency', 'woocommerce' ); ?></td>
<td class="help"><?php echo wc_help_tip( __( 'What currency prices are listed at in the catalog and which currency gateways will take payments in.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'What currency prices are listed at in the catalog and which currency gateways will take payments in.', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( $settings['currency'] ) ?> (<?php echo esc_html( $settings['currency_symbol'] ) ?>)</td> <td><?php echo esc_html( $settings['currency'] ); ?> (<?php echo esc_html( $settings['currency_symbol'] ); ?>)</td>
</tr> </tr>
<tr> <tr>
<td data-export-label="Currency Position"><?php _e( 'Currency position', 'woocommerce' ) ?></td> <td data-export-label="Currency Position"><?php _e( 'Currency position', 'woocommerce' ); ?></td>
<td class="help"><?php echo wc_help_tip( __( 'The position of the currency symbol.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'The position of the currency symbol.', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( $settings['currency_position'] ) ?></td> <td><?php echo esc_html( $settings['currency_position'] ); ?></td>
</tr> </tr>
<tr> <tr>
<td data-export-label="Thousand Separator"><?php _e( 'Thousand separator', 'woocommerce' ) ?></td> <td data-export-label="Thousand Separator"><?php _e( 'Thousand separator', 'woocommerce' ); ?></td>
<td class="help"><?php echo wc_help_tip( __( 'The thousand separator of displayed prices.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'The thousand separator of displayed prices.', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( $settings['thousand_separator'] ) ?></td> <td><?php echo esc_html( $settings['thousand_separator'] ); ?></td>
</tr> </tr>
<tr> <tr>
<td data-export-label="Decimal Separator"><?php _e( 'Decimal separator', 'woocommerce' ) ?></td> <td data-export-label="Decimal Separator"><?php _e( 'Decimal separator', 'woocommerce' ); ?></td>
<td class="help"><?php echo wc_help_tip( __( 'The decimal separator of displayed prices.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'The decimal separator of displayed prices.', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( $settings['decimal_separator'] ) ?></td> <td><?php echo esc_html( $settings['decimal_separator'] ); ?></td>
</tr> </tr>
<tr> <tr>
<td data-export-label="Number of Decimals"><?php _e( 'Number of decimals', 'woocommerce' ) ?></td> <td data-export-label="Number of Decimals"><?php _e( 'Number of decimals', 'woocommerce' ); ?></td>
<td class="help"><?php echo wc_help_tip( __( 'The number of decimal points shown in displayed prices.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'The number of decimal points shown in displayed prices.', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( $settings['number_of_decimals'] ) ?></td> <td><?php echo esc_html( $settings['number_of_decimals'] ); ?></td>
</tr> </tr>
<tr> <tr>
<td data-export-label="Taxonomies: Product Types"><?php _e( 'Taxonomies: Product types', 'woocommerce' ); ?></th> <td data-export-label="Taxonomies: Product Types"><?php _e( 'Taxonomies: Product types', 'woocommerce' ); ?></th>
<td class="help"><?php echo wc_help_tip( __( 'A list of taxonomy terms that can be used in regard to order/product statuses.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'A list of taxonomy terms that can be used in regard to order/product statuses.', 'woocommerce' ) ); ?></td>
<td><?php <td>
<?php
$display_terms = array(); $display_terms = array();
foreach ( $settings['taxonomies'] as $slug => $name ) { foreach ( $settings['taxonomies'] as $slug => $name ) {
$display_terms[] = strtolower( $name ) . ' (' . $slug . ')'; $display_terms[] = strtolower( $name ) . ' (' . $slug . ')';
} }
echo implode( ', ', array_map( 'esc_html', $display_terms ) ); echo implode( ', ', array_map( 'esc_html', $display_terms ) );
?></td> ?>
</td>
</tr> </tr>
<tr> <tr>
<td data-export-label="Taxonomies: Product Visibility"><?php _e( 'Taxonomies: Product visibility', 'woocommerce' ); ?></th> <td data-export-label="Taxonomies: Product Visibility"><?php _e( 'Taxonomies: Product visibility', 'woocommerce' ); ?></th>
<td class="help"><?php echo wc_help_tip( __( 'A list of taxonomy terms used for product visibility.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'A list of taxonomy terms used for product visibility.', 'woocommerce' ) ); ?></td>
<td><?php <td>
<?php
$display_terms = array(); $display_terms = array();
foreach ( $settings['product_visibility_terms'] as $slug => $name ) { foreach ( $settings['product_visibility_terms'] as $slug => $name ) {
$display_terms[] = strtolower( $name ) . ' (' . $slug . ')'; $display_terms[] = strtolower( $name ) . ' (' . $slug . ')';
} }
echo implode( ', ', array_map( 'esc_html', $display_terms ) ); echo implode( ', ', array_map( 'esc_html', $display_terms ) );
?></td> ?>
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -561,45 +596,45 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
</thead> </thead>
<tbody> <tbody>
<?php <?php
$alt = 1; $alt = 1;
foreach ( $pages as $page ) { foreach ( $pages as $page ) {
$error = false; $error = false;
if ( $page['page_id'] ) { if ( $page['page_id'] ) {
$page_name = '<a href="' . get_edit_post_link( $page['page_id'] ) . '" aria-label="' . sprintf( __( 'Edit %s page', 'woocommerce' ), esc_html( $page['page_name'] ) ) . '">' . esc_html( $page['page_name'] ) . '</a>'; $page_name = '<a href="' . get_edit_post_link( $page['page_id'] ) . '" aria-label="' . sprintf( __( 'Edit %s page', 'woocommerce' ), esc_html( $page['page_name'] ) ) . '">' . esc_html( $page['page_name'] ) . '</a>';
} else { } else {
$page_name = esc_html( $page['page_name'] ); $page_name = esc_html( $page['page_name'] );
} }
echo '<tr><td data-export-label="' . esc_attr( $page_name ) . '">' . $page_name . ':</td>'; echo '<tr><td data-export-label="' . esc_attr( $page_name ) . '">' . $page_name . ':</td>';
echo '<td class="help">' . wc_help_tip( sprintf( __( 'The URL of your %s page (along with the Page ID).', 'woocommerce' ), $page_name ) ) . '</td><td>'; echo '<td class="help">' . wc_help_tip( sprintf( __( 'The URL of your %s page (along with the Page ID).', 'woocommerce' ), $page_name ) ) . '</td><td>';
// Page ID check. // Page ID check.
if ( ! $page['page_set'] ) { if ( ! $page['page_set'] ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'Page not set', 'woocommerce' ) . '</mark>'; echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'Page not set', 'woocommerce' ) . '</mark>';
$error = true; $error = true;
} elseif ( ! $page['page_exists'] ) { } elseif ( ! $page['page_exists'] ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'Page ID is set, but the page does not exist', 'woocommerce' ) . '</mark>'; echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'Page ID is set, but the page does not exist', 'woocommerce' ) . '</mark>';
$error = true; $error = true;
} elseif ( ! $page['page_visible'] ) { } elseif ( ! $page['page_visible'] ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Page visibility should be <a href="%s" target="_blank">public</a>', 'woocommerce' ), 'https://codex.wordpress.org/Content_Visibility' ) . '</mark>'; echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Page visibility should be <a href="%s" target="_blank">public</a>', 'woocommerce' ), 'https://codex.wordpress.org/Content_Visibility' ) . '</mark>';
$error = true; $error = true;
} else { } else {
// Shortcode check // Shortcode check
if ( $page['shortcode_required'] ) { if ( $page['shortcode_required'] ) {
if ( ! $page['shortcode_present'] ) { if ( ! $page['shortcode_present'] ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Page does not contain the shortcode.', 'woocommerce' ), $page['shortcode'] ) . '</mark>'; echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Page does not contain the shortcode.', 'woocommerce' ), $page['shortcode'] ) . '</mark>';
$error = true; $error = true;
}
} }
} }
if ( ! $error ) {
echo '<mark class="yes">#' . absint( $page['page_id'] ) . ' - ' . str_replace( home_url(), '', get_permalink( $page['page_id'] ) ) . '</mark>';
}
echo '</td></tr>';
} }
if ( ! $error ) {
echo '<mark class="yes">#' . absint( $page['page_id'] ) . ' - ' . str_replace( home_url(), '', get_permalink( $page['page_id'] ) ) . '</mark>';
}
echo '</td></tr>';
}
?> ?>
</tbody> </tbody>
</table> </table>
@ -613,65 +648,69 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<tr> <tr>
<td data-export-label="Name"><?php _e( 'Name', 'woocommerce' ); ?>:</td> <td data-export-label="Name"><?php _e( 'Name', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The name of the current active theme.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'The name of the current active theme.', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( $theme['name'] ) ?></td> <td><?php echo esc_html( $theme['name'] ); ?></td>
</tr> </tr>
<tr> <tr>
<td data-export-label="Version"><?php _e( 'Version', 'woocommerce' ); ?>:</td> <td data-export-label="Version"><?php _e( 'Version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The installed version of the current active theme.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'The installed version of the current active theme.', 'woocommerce' ) ); ?></td>
<td><?php <td>
<?php
echo esc_html( $theme['version'] ); echo esc_html( $theme['version'] );
if ( version_compare( $theme['version'], $theme['version_latest'], '<' ) ) { if ( version_compare( $theme['version'], $theme['version_latest'], '<' ) ) {
/* translators: %s: theme latest version */ /* translators: %s: theme latest version */
echo ' &ndash; <strong style="color:red;">' . sprintf( __( '%s is available', 'woocommerce' ), esc_html( $theme['version_latest'] ) ) . '</strong>'; echo ' &ndash; <strong style="color:red;">' . sprintf( __( '%s is available', 'woocommerce' ), esc_html( $theme['version_latest'] ) ) . '</strong>';
} }
?></td> ?>
</td>
</tr> </tr>
<tr> <tr>
<td data-export-label="Author URL"><?php _e( 'Author URL', 'woocommerce' ); ?>:</td> <td data-export-label="Author URL"><?php _e( 'Author URL', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The theme developers URL.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'The theme developers URL.', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( $theme['author_url'] ) ?></td> <td><?php echo esc_html( $theme['author_url'] ); ?></td>
</tr> </tr>
<tr> <tr>
<td data-export-label="Child Theme"><?php _e( 'Child theme', 'woocommerce' ); ?>:</td> <td data-export-label="Child Theme"><?php _e( 'Child theme', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Displays whether or not the current theme is a child theme.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'Displays whether or not the current theme is a child theme.', 'woocommerce' ) ); ?></td>
<td><?php <td>
echo $theme['is_child_theme'] ? '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>' : '<span class="dashicons dashicons-no-alt"></span> &ndash; ' . 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>', 'woocommerce' ), 'https://codex.wordpress.org/Child_Themes' ); <?php echo $theme['is_child_theme'] ? '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>' : '<span class="dashicons dashicons-no-alt"></span> &ndash; ' . 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>', 'woocommerce' ), 'https://codex.wordpress.org/Child_Themes' ); ?>
?></td> </td>
</tr>
<?php
if ( $theme['is_child_theme'] ) :
?>
<tr>
<td data-export-label="Parent Theme Name"><?php _e( 'Parent theme name', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The name of the parent theme.', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( $theme['parent_name'] ); ?></td>
</tr>
<tr>
<td data-export-label="Parent Theme Version"><?php _e( 'Parent theme version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The installed version of the parent theme.', 'woocommerce' ) ); ?></td>
<td><?php
echo esc_html( $theme['parent_version'] );
if ( version_compare( $theme['parent_version'], $theme['parent_version_latest'], '<' ) ) {
/* translators: %s: parant theme latest version */
echo ' &ndash; <strong style="color:red;">' . sprintf( __( '%s is available', 'woocommerce' ), esc_html( $theme['parent_version_latest'] ) ) . '</strong>';
}
?></td>
</tr>
<tr>
<td data-export-label="Parent Theme Author URL"><?php _e( 'Parent theme author URL', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The parent theme developers URL.', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( $theme['parent_author_url'] ) ?></td>
</tr> </tr>
<?php if ( $theme['is_child_theme'] ) : ?>
<tr>
<td data-export-label="Parent Theme Name"><?php _e( 'Parent theme name', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The name of the parent theme.', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( $theme['parent_name'] ); ?></td>
</tr>
<tr>
<td data-export-label="Parent Theme Version"><?php _e( 'Parent theme version', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The installed version of the parent theme.', 'woocommerce' ) ); ?></td>
<td>
<?php
echo esc_html( $theme['parent_version'] );
if ( version_compare( $theme['parent_version'], $theme['parent_version_latest'], '<' ) ) {
/* translators: %s: parant theme latest version */
echo ' &ndash; <strong style="color:red;">' . sprintf( __( '%s is available', 'woocommerce' ), esc_html( $theme['parent_version_latest'] ) ) . '</strong>';
}
?>
</td>
</tr>
<tr>
<td data-export-label="Parent Theme Author URL"><?php _e( 'Parent theme author URL', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'The parent theme developers URL.', 'woocommerce' ) ); ?></td>
<td><?php echo esc_html( $theme['parent_author_url'] ); ?></td>
</tr>
<?php endif ?> <?php endif ?>
<tr> <tr>
<td data-export-label="WooCommerce Support"><?php _e( 'WooCommerce support', 'woocommerce' ); ?>:</td> <td data-export-label="WooCommerce Support"><?php _e( 'WooCommerce support', 'woocommerce' ); ?>:</td>
<td class="help"><?php echo wc_help_tip( __( 'Displays whether or not the current active theme declares WooCommerce support.', 'woocommerce' ) ); ?></td> <td class="help"><?php echo wc_help_tip( __( 'Displays whether or not the current active theme declares WooCommerce support.', 'woocommerce' ) ); ?></td>
<td> <td>
<?php if ( ! $theme['has_woocommerce_support'] ) { <?php
if ( ! $theme['has_woocommerce_support'] ) {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'Not declared', 'woocommerce' ) . '</mark>'; echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'Not declared', 'woocommerce' ) . '</mark>';
} else { } else {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>';
} ?> }
?>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@ -690,55 +729,53 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'minor
<td><?php _e( 'Your theme has a woocommerce.php file, you will not be able to override the woocommerce/archive-product.php custom template since woocommerce.php has priority over archive-product.php. This is intended to prevent display issues.', 'woocommerce' ); ?></td> <td><?php _e( 'Your theme has a woocommerce.php file, you will not be able to override the woocommerce/archive-product.php custom template since woocommerce.php has priority over archive-product.php. This is intended to prevent display issues.', 'woocommerce' ); ?></td>
</tr> </tr>
<?php endif ?> <?php endif ?>
<?php <?php if ( ! empty( $theme['overrides'] ) ) { ?>
if ( ! empty( $theme['overrides'] ) ) { ?> <tr>
<tr> <td data-export-label="Overrides"><?php _e( 'Overrides', 'woocommerce' ); ?></td>
<td data-export-label="Overrides"><?php _e( 'Overrides', 'woocommerce' ); ?></td> <td class="help">&nbsp;</td>
<td class="help">&nbsp;</td> <td>
<td>
<?php
$total_overrides = count( $theme['overrides'] );
for ( $i = 0; $i < $total_overrides; $i++ ) {
$override = $theme['overrides'][ $i ];
if ( $override['core_version'] && ( empty( $override['version'] ) || version_compare( $override['version'], $override['core_version'], '<' ) ) ) {
$current_version = $override['version'] ? $override['version'] : '-';
printf(
__( '%1$s version %2$s is out of date. The core version is %3$s', 'woocommerce' ),
'<code>' . $override['file'] . '</code>',
'<strong style="color:red">' . $current_version . '</strong>',
$override['core_version']
);
} else {
echo esc_html( $override['file'] );
}
if ( ( count( $theme['overrides'] ) - 1 ) !== $i ) {
echo ', ';
}
echo '<br />';
}
?>
</td>
</tr>
<?php <?php
} else { $total_overrides = count( $theme['overrides'] );
?> for ( $i = 0; $i < $total_overrides; $i++ ) {
<tr> $override = $theme['overrides'][ $i ];
<td data-export-label="Overrides"><?php _e( 'Overrides', 'woocommerce' ); ?>:</td> if ( $override['core_version'] && ( empty( $override['version'] ) || version_compare( $override['version'], $override['core_version'], '<' ) ) ) {
<td class="help">&nbsp;</td> $current_version = $override['version'] ? $override['version'] : '-';
<td>&ndash;</td> printf(
</tr> __( '%1$s version %2$s is out of date. The core version is %3$s', 'woocommerce' ),
<?php '<code>' . $override['file'] . '</code>',
} '<strong style="color:red">' . $current_version . '</strong>',
$override['core_version']
);
} else {
echo esc_html( $override['file'] );
}
if ( ( count( $theme['overrides'] ) - 1 ) !== $i ) {
echo ', ';
}
echo '<br />';
}
?>
</td>
</tr>
<?php
} else { ?>
<tr>
<td data-export-label="Overrides"><?php _e( 'Overrides', 'woocommerce' ); ?>:</td>
<td class="help">&nbsp;</td>
<td>&ndash;</td>
</tr>
<?php
}
if ( true === $theme['has_outdated_templates'] ) { if ( true === $theme['has_outdated_templates'] ) {
?> ?>
<tr> <tr>
<td data-export-label="Outdated Templates"><?php _e( 'Outdated templates', 'woocommerce' ); ?>:</td> <td data-export-label="Outdated Templates"><?php _e( 'Outdated templates', 'woocommerce' ); ?>:</td>
<td class="help">&nbsp;</td> <td class="help">&nbsp;</td>
<td><mark class="error"><span class="dashicons dashicons-warning"></span></mark><a href="https://docs.woocommerce.com/document/fix-outdated-templates-woocommerce/" target="_blank"><?php _e( 'Learn how to update', 'woocommerce' ) ?></a></td> <td><mark class="error"><span class="dashicons dashicons-warning"></span></mark><a href="https://docs.woocommerce.com/document/fix-outdated-templates-woocommerce/" target="_blank"><?php _e( 'Learn how to update', 'woocommerce' ); ?></a></td>
</tr> </tr>
<?php <?php
} }
?> ?>
</tbody> </tbody>
</table> </table>

View File

@ -38,15 +38,18 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
* Register the route for /system_status * Register the route for /system_status
*/ */
public function register_routes() { public function register_routes() {
register_rest_route( $this->namespace, '/' . $this->rest_base, array( register_rest_route(
$this->namespace, '/' . $this->rest_base,
array( array(
'methods' => WP_REST_Server::READABLE, array(
'callback' => array( $this, 'get_items' ), 'methods' => WP_REST_Server::READABLE,
'permission_callback' => array( $this, 'get_items_permissions_check' ), 'callback' => array( $this, 'get_items' ),
'args' => $this->get_collection_params(), 'permission_callback' => array( $this, 'get_items_permissions_check' ),
), 'args' => $this->get_collection_params(),
'schema' => array( $this, 'get_public_item_schema' ), ),
) ); 'schema' => array( $this, 'get_public_item_schema' ),
)
);
} }
/** /**
@ -69,9 +72,9 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
* @return WP_Error|WP_REST_Response * @return WP_Error|WP_REST_Response
*/ */
public function get_items( $request ) { public function get_items( $request ) {
$schema = $this->get_item_schema(); $schema = $this->get_item_schema();
$mappings = $this->get_item_mappings(); $mappings = $this->get_item_mappings();
$response = array(); $response = array();
foreach ( $mappings as $section => $values ) { foreach ( $mappings as $section => $values ) {
foreach ( $values as $key => $value ) { foreach ( $values as $key => $value ) {
@ -99,135 +102,135 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
'title' => 'system_status', 'title' => 'system_status',
'type' => 'object', 'type' => 'object',
'properties' => array( 'properties' => array(
'environment' => array( 'environment' => array(
'description' => __( 'Environment.', 'woocommerce' ), 'description' => __( 'Environment.', 'woocommerce' ),
'type' => 'object', 'type' => 'object',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
'properties' => array( 'properties' => array(
'home_url' => array( 'home_url' => array(
'description' => __( 'Home URL.', 'woocommerce' ), 'description' => __( 'Home URL.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'format' => 'uri', 'format' => 'uri',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'site_url' => array( 'site_url' => array(
'description' => __( 'Site URL.', 'woocommerce' ), 'description' => __( 'Site URL.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'format' => 'uri', 'format' => 'uri',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'wc_version' => array( 'wc_version' => array(
'description' => __( 'WooCommerce version.', 'woocommerce' ), 'description' => __( 'WooCommerce version.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'log_directory' => array( 'log_directory' => array(
'description' => __( 'Log directory.', 'woocommerce' ), 'description' => __( 'Log directory.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'log_directory_writable' => array( 'log_directory_writable' => array(
'description' => __( 'Is log directory writable?', 'woocommerce' ), 'description' => __( 'Is log directory writable?', 'woocommerce' ),
'type' => 'boolean', 'type' => 'boolean',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'wp_version' => array( 'wp_version' => array(
'description' => __( 'WordPress version.', 'woocommerce' ), 'description' => __( 'WordPress version.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'wp_multisite' => array( 'wp_multisite' => array(
'description' => __( 'Is WordPress multisite?', 'woocommerce' ), 'description' => __( 'Is WordPress multisite?', 'woocommerce' ),
'type' => 'boolean', 'type' => 'boolean',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'wp_memory_limit' => array( 'wp_memory_limit' => array(
'description' => __( 'WordPress memory limit.', 'woocommerce' ), 'description' => __( 'WordPress memory limit.', 'woocommerce' ),
'type' => 'integer', 'type' => 'integer',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'wp_debug_mode' => array( 'wp_debug_mode' => array(
'description' => __( 'Is WordPress debug mode active?', 'woocommerce' ), 'description' => __( 'Is WordPress debug mode active?', 'woocommerce' ),
'type' => 'boolean', 'type' => 'boolean',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'wp_cron' => array( 'wp_cron' => array(
'description' => __( 'Are WordPress cron jobs enabled?', 'woocommerce' ), 'description' => __( 'Are WordPress cron jobs enabled?', 'woocommerce' ),
'type' => 'boolean', 'type' => 'boolean',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'language' => array( 'language' => array(
'description' => __( 'WordPress language.', 'woocommerce' ), 'description' => __( 'WordPress language.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'server_info' => array( 'server_info' => array(
'description' => __( 'Server info.', 'woocommerce' ), 'description' => __( 'Server info.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'php_version' => array( 'php_version' => array(
'description' => __( 'PHP version.', 'woocommerce' ), 'description' => __( 'PHP version.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'php_post_max_size' => array( 'php_post_max_size' => array(
'description' => __( 'PHP post max size.', 'woocommerce' ), 'description' => __( 'PHP post max size.', 'woocommerce' ),
'type' => 'integer', 'type' => 'integer',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'php_max_execution_time' => array( 'php_max_execution_time' => array(
'description' => __( 'PHP max execution time.', 'woocommerce' ), 'description' => __( 'PHP max execution time.', 'woocommerce' ),
'type' => 'integer', 'type' => 'integer',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'php_max_input_vars' => array( 'php_max_input_vars' => array(
'description' => __( 'PHP max input vars.', 'woocommerce' ), 'description' => __( 'PHP max input vars.', 'woocommerce' ),
'type' => 'integer', 'type' => 'integer',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'curl_version' => array( 'curl_version' => array(
'description' => __( 'cURL version.', 'woocommerce' ), 'description' => __( 'cURL version.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'suhosin_installed' => array( 'suhosin_installed' => array(
'description' => __( 'Is SUHOSIN installed?', 'woocommerce' ), 'description' => __( 'Is SUHOSIN installed?', 'woocommerce' ),
'type' => 'boolean', 'type' => 'boolean',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'max_upload_size' => array( 'max_upload_size' => array(
'description' => __( 'Max upload size.', 'woocommerce' ), 'description' => __( 'Max upload size.', 'woocommerce' ),
'type' => 'integer', 'type' => 'integer',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'mysql_version' => array( 'mysql_version' => array(
'description' => __( 'MySQL version.', 'woocommerce' ), 'description' => __( 'MySQL version.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'default_timezone' => array( 'default_timezone' => array(
'description' => __( 'Default timezone.', 'woocommerce' ), 'description' => __( 'Default timezone.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view' ), 'context' => array( 'view' ),
@ -239,49 +242,49 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'soapclient_enabled' => array( 'soapclient_enabled' => array(
'description' => __( 'Is SoapClient class enabled?', 'woocommerce' ), 'description' => __( 'Is SoapClient class enabled?', 'woocommerce' ),
'type' => 'boolean', 'type' => 'boolean',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'domdocument_enabled' => array( 'domdocument_enabled' => array(
'description' => __( 'Is DomDocument class enabled?', 'woocommerce' ), 'description' => __( 'Is DomDocument class enabled?', 'woocommerce' ),
'type' => 'boolean', 'type' => 'boolean',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'gzip_enabled' => array( 'gzip_enabled' => array(
'description' => __( 'Is GZip enabled?', 'woocommerce' ), 'description' => __( 'Is GZip enabled?', 'woocommerce' ),
'type' => 'boolean', 'type' => 'boolean',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'mbstring_enabled' => array( 'mbstring_enabled' => array(
'description' => __( 'Is mbstring enabled?', 'woocommerce' ), 'description' => __( 'Is mbstring enabled?', 'woocommerce' ),
'type' => 'boolean', 'type' => 'boolean',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'remote_post_successful' => array( 'remote_post_successful' => array(
'description' => __( 'Remote POST successful?', 'woocommerce' ), 'description' => __( 'Remote POST successful?', 'woocommerce' ),
'type' => 'boolean', 'type' => 'boolean',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'remote_post_response' => array( 'remote_post_response' => array(
'description' => __( 'Remote POST response.', 'woocommerce' ), 'description' => __( 'Remote POST response.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'remote_get_successful' => array( 'remote_get_successful' => array(
'description' => __( 'Remote GET successful?', 'woocommerce' ), 'description' => __( 'Remote GET successful?', 'woocommerce' ),
'type' => 'boolean', 'type' => 'boolean',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'remote_get_response' => array( 'remote_get_response' => array(
'description' => __( 'Remote GET response.', 'woocommerce' ), 'description' => __( 'Remote GET response.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view' ), 'context' => array( 'view' ),
@ -289,19 +292,19 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
), ),
), ),
), ),
'database' => array( 'database' => array(
'description' => __( 'Database.', 'woocommerce' ), 'description' => __( 'Database.', 'woocommerce' ),
'type' => 'object', 'type' => 'object',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
'properties' => array( 'properties' => array(
'wc_database_version' => array( 'wc_database_version' => array(
'description' => __( 'WC database version.', 'woocommerce' ), 'description' => __( 'WC database version.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'database_prefix' => array( 'database_prefix' => array(
'description' => __( 'Database prefix.', 'woocommerce' ), 'description' => __( 'Database prefix.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view' ), 'context' => array( 'view' ),
@ -313,13 +316,13 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'database_tables' => array( 'database_tables' => array(
'description' => __( 'Database tables.', 'woocommerce' ), 'description' => __( 'Database tables.', 'woocommerce' ),
'type' => 'array', 'type' => 'array',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
'items' => array( 'items' => array(
'type' => 'string', 'type' => 'string',
), ),
), ),
), ),
@ -330,41 +333,41 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
'items' => array( 'items' => array(
'type' => 'string', 'type' => 'string',
), ),
), ),
'theme' => array( 'theme' => array(
'description' => __( 'Theme.', 'woocommerce' ), 'description' => __( 'Theme.', 'woocommerce' ),
'type' => 'object', 'type' => 'object',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
'properties' => array( 'properties' => array(
'name' => array( 'name' => array(
'description' => __( 'Theme name.', 'woocommerce' ), 'description' => __( 'Theme name.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'version' => array( 'version' => array(
'description' => __( 'Theme version.', 'woocommerce' ), 'description' => __( 'Theme version.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'version_latest' => array( 'version_latest' => array(
'description' => __( 'Latest version of theme.', 'woocommerce' ), 'description' => __( 'Latest version of theme.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'author_url' => array( 'author_url' => array(
'description' => __( 'Theme author URL.', 'woocommerce' ), 'description' => __( 'Theme author URL.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'format' => 'uri', 'format' => 'uri',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'is_child_theme' => array( 'is_child_theme' => array(
'description' => __( 'Is this theme a child theme?', 'woocommerce' ), 'description' => __( 'Is this theme a child theme?', 'woocommerce' ),
'type' => 'boolean', 'type' => 'boolean',
'context' => array( 'view' ), 'context' => array( 'view' ),
@ -376,40 +379,40 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'has_woocommerce_file' => array( 'has_woocommerce_file' => array(
'description' => __( 'Does the theme have a woocommerce.php file?', 'woocommerce' ), 'description' => __( 'Does the theme have a woocommerce.php file?', 'woocommerce' ),
'type' => 'boolean', 'type' => 'boolean',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'has_outdated_templates' => array( 'has_outdated_templates' => array(
'description' => __( 'Does this theme have outdated templates?', 'woocommerce' ), 'description' => __( 'Does this theme have outdated templates?', 'woocommerce' ),
'type' => 'boolean', 'type' => 'boolean',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'overrides' => array( 'overrides' => array(
'description' => __( 'Template overrides.', 'woocommerce' ), 'description' => __( 'Template overrides.', 'woocommerce' ),
'type' => 'array', 'type' => 'array',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
'items' => array( 'items' => array(
'type' => 'string', 'type' => 'string',
), ),
), ),
'parent_name' => array( 'parent_name' => array(
'description' => __( 'Parent theme name.', 'woocommerce' ), 'description' => __( 'Parent theme name.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'parent_version' => array( 'parent_version' => array(
'description' => __( 'Parent theme version.', 'woocommerce' ), 'description' => __( 'Parent theme version.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'parent_author_url' => array( 'parent_author_url' => array(
'description' => __( 'Parent theme author URL.', 'woocommerce' ), 'description' => __( 'Parent theme author URL.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'format' => 'uri', 'format' => 'uri',
@ -418,73 +421,73 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
), ),
), ),
), ),
'settings' => array( 'settings' => array(
'description' => __( 'Settings.', 'woocommerce' ), 'description' => __( 'Settings.', 'woocommerce' ),
'type' => 'object', 'type' => 'object',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
'properties' => array( 'properties' => array(
'api_enabled' => array( 'api_enabled' => array(
'description' => __( 'REST API enabled?', 'woocommerce' ), 'description' => __( 'REST API enabled?', 'woocommerce' ),
'type' => 'boolean', 'type' => 'boolean',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'force_ssl' => array( 'force_ssl' => array(
'description' => __( 'SSL forced?', 'woocommerce' ), 'description' => __( 'SSL forced?', 'woocommerce' ),
'type' => 'boolean', 'type' => 'boolean',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'currency' => array( 'currency' => array(
'description' => __( 'Currency.', 'woocommerce' ), 'description' => __( 'Currency.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'currency_symbol' => array( 'currency_symbol' => array(
'description' => __( 'Currency symbol.', 'woocommerce' ), 'description' => __( 'Currency symbol.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'currency_position' => array( 'currency_position' => array(
'description' => __( 'Currency position.', 'woocommerce' ), 'description' => __( 'Currency position.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'thousand_separator' => array( 'thousand_separator' => array(
'description' => __( 'Thousand separator.', 'woocommerce' ), 'description' => __( 'Thousand separator.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'decimal_separator' => array( 'decimal_separator' => array(
'description' => __( 'Decimal separator.', 'woocommerce' ), 'description' => __( 'Decimal separator.', 'woocommerce' ),
'type' => 'string', 'type' => 'string',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'number_of_decimals' => array( 'number_of_decimals' => array(
'description' => __( 'Number of decimals.', 'woocommerce' ), 'description' => __( 'Number of decimals.', 'woocommerce' ),
'type' => 'integer', 'type' => 'integer',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'geolocation_enabled' => array( 'geolocation_enabled' => array(
'description' => __( 'Geolocation enabled?', 'woocommerce' ), 'description' => __( 'Geolocation enabled?', 'woocommerce' ),
'type' => 'boolean', 'type' => 'boolean',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'taxonomies' => array( 'taxonomies' => array(
'description' => __( 'Taxonomy terms for product/order statuses.', 'woocommerce' ), 'description' => __( 'Taxonomy terms for product/order statuses.', 'woocommerce' ),
'type' => 'array', 'type' => 'array',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
'items' => array( 'items' => array(
'type' => 'string', 'type' => 'string',
), ),
), ),
'product_visibility_terms' => array( 'product_visibility_terms' => array(
@ -493,12 +496,12 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
'items' => array( 'items' => array(
'type' => 'string', 'type' => 'string',
), ),
), ),
), ),
), ),
'security' => array( 'security' => array(
'description' => __( 'Security.', 'woocommerce' ), 'description' => __( 'Security.', 'woocommerce' ),
'type' => 'object', 'type' => 'object',
'context' => array( 'view' ), 'context' => array( 'view' ),
@ -510,7 +513,7 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
), ),
'hide_errors' => array( 'hide_errors' => array(
'description' => __( 'Hide errors from visitors?', 'woocommerce' ), 'description' => __( 'Hide errors from visitors?', 'woocommerce' ),
'type' => 'boolean', 'type' => 'boolean',
'context' => array( 'view' ), 'context' => array( 'view' ),
@ -518,13 +521,13 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
), ),
), ),
), ),
'pages' => array( 'pages' => array(
'description' => __( 'WooCommerce pages.', 'woocommerce' ), 'description' => __( 'WooCommerce pages.', 'woocommerce' ),
'type' => 'array', 'type' => 'array',
'context' => array( 'view' ), 'context' => array( 'view' ),
'readonly' => true, 'readonly' => true,
'items' => array( 'items' => array(
'type' => 'string', 'type' => 'string',
), ),
), ),
), ),
@ -573,21 +576,24 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
} }
// Test POST requests // Test POST requests
$post_response = wp_safe_remote_post( 'https://www.paypal.com/cgi-bin/webscr', array( $post_response = wp_safe_remote_post(
'timeout' => 10, 'https://www.paypal.com/cgi-bin/webscr',
'user-agent' => 'WooCommerce/' . WC()->version, array(
'httpversion' => '1.1', 'timeout' => 10,
'body' => array( 'user-agent' => 'WooCommerce/' . WC()->version,
'cmd' => '_notify-validate', 'httpversion' => '1.1',
), 'body' => array(
) ); 'cmd' => '_notify-validate',
),
)
);
$post_response_successful = false; $post_response_successful = false;
if ( ! is_wp_error( $post_response ) && $post_response['response']['code'] >= 200 && $post_response['response']['code'] < 300 ) { if ( ! is_wp_error( $post_response ) && $post_response['response']['code'] >= 200 && $post_response['response']['code'] < 300 ) {
$post_response_successful = true; $post_response_successful = true;
} }
// Test GET requests // Test GET requests
$get_response = wp_safe_remote_get( 'https://woocommerce.com/wc-api/product-key-api?request=ping&network=' . ( is_multisite() ? '1' : '0' ) ); $get_response = wp_safe_remote_get( 'https://woocommerce.com/wc-api/product-key-api?request=ping&network=' . ( is_multisite() ? '1' : '0' ) );
$get_response_successful = false; $get_response_successful = false;
if ( ! is_wp_error( $post_response ) && $post_response['response']['code'] >= 200 && $post_response['response']['code'] < 300 ) { if ( ! is_wp_error( $post_response ) && $post_response['response']['code'] >= 200 && $post_response['response']['code'] < 300 ) {
$get_response_successful = true; $get_response_successful = true;
@ -597,7 +603,7 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
return array( return array(
'home_url' => get_option( 'home' ), 'home_url' => get_option( 'home' ),
'site_url' => get_option( 'siteurl' ), 'site_url' => get_option( 'siteurl' ),
'version' => WC()->version, 'version' => WC()->version,
'log_directory' => WC_LOG_DIR, 'log_directory' => WC_LOG_DIR,
'log_directory_writable' => ( @fopen( WC_LOG_DIR . 'test-log.log', 'a' ) ? true : false ), 'log_directory_writable' => ( @fopen( WC_LOG_DIR . 'test-log.log', 'a' ) ? true : false ),
'wp_version' => get_bloginfo( 'version' ), 'wp_version' => get_bloginfo( 'version' ),
@ -647,33 +653,39 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
public function get_database_info() { public function get_database_info() {
global $wpdb; global $wpdb;
$database_table_sizes = $wpdb->get_results( $wpdb->prepare( " $database_table_sizes = $wpdb->get_results(
SELECT $wpdb->prepare(
table_name AS 'name', "SELECT
round( ( data_length / 1024 / 1024 ), 2 ) 'data', table_name AS 'name',
round( ( index_length / 1024 / 1024 ), 2 ) 'index' round( ( data_length / 1024 / 1024 ), 2 ) 'data',
FROM information_schema.TABLES round( ( index_length / 1024 / 1024 ), 2 ) 'index'
WHERE table_schema = %s FROM information_schema.TABLES
ORDER BY name ASC; WHERE table_schema = %s
", DB_NAME ) ); ORDER BY name ASC;",
DB_NAME
)
);
// WC Core tables to check existence of // WC Core tables to check existence of
$core_tables = apply_filters( 'woocommerce_database_tables', array( $core_tables = apply_filters(
'woocommerce_sessions', 'woocommerce_database_tables',
'woocommerce_api_keys', array(
'woocommerce_attribute_taxonomies', 'woocommerce_sessions',
'woocommerce_downloadable_product_permissions', 'woocommerce_api_keys',
'woocommerce_order_items', 'woocommerce_attribute_taxonomies',
'woocommerce_order_itemmeta', 'woocommerce_downloadable_product_permissions',
'woocommerce_tax_rates', 'woocommerce_order_items',
'woocommerce_tax_rate_locations', 'woocommerce_order_itemmeta',
'woocommerce_shipping_zones', 'woocommerce_tax_rates',
'woocommerce_shipping_zone_locations', 'woocommerce_tax_rate_locations',
'woocommerce_shipping_zone_methods', 'woocommerce_shipping_zones',
'woocommerce_payment_tokens', 'woocommerce_shipping_zone_locations',
'woocommerce_payment_tokenmeta', 'woocommerce_shipping_zone_methods',
'woocommerce_log', 'woocommerce_payment_tokens',
) ); 'woocommerce_payment_tokenmeta',
'woocommerce_log',
)
);
if ( get_option( 'db_version' ) < 34370 ) { if ( get_option( 'db_version' ) < 34370 ) {
$core_tables[] = 'woocommerce_termmeta'; $core_tables[] = 'woocommerce_termmeta';
@ -693,12 +705,12 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
*/ */
$tables = array( $tables = array(
'woocommerce' => array_fill_keys( $core_tables, false ), 'woocommerce' => array_fill_keys( $core_tables, false ),
'other' => array() 'other' => array(),
); );
$database_size = array( $database_size = array(
'data' => 0, 'data' => 0,
'index' => 0 'index' => 0,
); );
foreach ( $database_table_sizes as $table ) { foreach ( $database_table_sizes as $table ) {
@ -706,11 +718,11 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
$tables[ $table_type ][ $table->name ] = array( $tables[ $table_type ][ $table->name ] = array(
'data' => $table->data, 'data' => $table->data,
'index' => $table->index 'index' => $table->index,
); );
$database_size[ 'data' ] += $table->data; $database_size['data'] += $table->data;
$database_size[ 'index' ] += $table->index; $database_size['index'] += $table->index;
} }
// Return all database info. Described by JSON Schema. // Return all database info. Described by JSON Schema.
@ -742,8 +754,8 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
* @return array * @return array
*/ */
public function get_active_plugins() { public function get_active_plugins() {
require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); require_once ABSPATH . 'wp-admin/includes/plugin.php';
require_once( ABSPATH . 'wp-admin/includes/update.php' ); require_once ABSPATH . 'wp-admin/includes/update.php';
if ( ! function_exists( 'get_plugin_updates' ) ) { if ( ! function_exists( 'get_plugin_updates' ) ) {
return array(); return array();
@ -774,10 +786,15 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
if ( ! empty( $cl_lines ) ) { if ( ! empty( $cl_lines ) ) {
foreach ( $cl_lines as $line_num => $cl_line ) { foreach ( $cl_lines as $line_num => $cl_line ) {
if ( preg_match( '/^[0-9]/', $cl_line ) ) { if ( preg_match( '/^[0-9]/', $cl_line ) ) {
$date = str_replace( '.' , '-' , trim( substr( $cl_line , 0 , strpos( $cl_line , '-' ) ) ) ); $date = str_replace( '.', '-', trim( substr( $cl_line, 0, strpos( $cl_line, '-' ) ) ) );
$version = preg_replace( '~[^0-9,.]~' , '' ,stristr( $cl_line , "version" ) ); $version = preg_replace( '~[^0-9,.]~', '', stristr( $cl_line, 'version' ) );
$update = trim( str_replace( "*" , "" , $cl_lines[ $line_num + 1 ] ) ); $update = trim( str_replace( '*', '', $cl_lines[ $line_num + 1 ] ) );
$version_data = array( 'date' => $date , 'version' => $version , 'update' => $update , 'changelog' => $changelog ); $version_data = array(
'date' => $date,
'version' => $version,
'update' => $update,
'changelog' => $changelog,
);
set_transient( md5( $plugin ) . '_version_data', $version_data, DAY_IN_SECONDS ); set_transient( md5( $plugin ) . '_version_data', $version_data, DAY_IN_SECONDS );
break; break;
} }
@ -825,7 +842,12 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
'parent_author_url' => $parent_theme->{'Author URI'}, 'parent_author_url' => $parent_theme->{'Author URI'},
); );
} else { } else {
$parent_theme_info = array( 'parent_name' => '', 'parent_version' => '', 'parent_version_latest' => '', 'parent_author_url' => '' ); $parent_theme_info = array(
'parent_name' => '',
'parent_version' => '',
'parent_version_latest' => '',
'parent_author_url' => '',
);
} }
/** /**
@ -966,8 +988,8 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
$pages_output = array(); $pages_output = array();
foreach ( $check_pages as $page_name => $values ) { foreach ( $check_pages as $page_name => $values ) {
$page_id = get_option( $values['option'] ); $page_id = get_option( $values['option'] );
$page_set = $page_exists = $page_visible = false; $page_set = $page_exists = $page_visible = false;
$shortcode_present = $shortcode_required = false; $shortcode_present = $shortcode_required = false;
// Page checks // Page checks
@ -982,9 +1004,9 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
} }
// Shortcode checks // Shortcode checks
if ( $values['shortcode'] && get_post( $page_id ) ) { if ( $values['shortcode'] && get_post( $page_id ) ) {
$shortcode_required = true; $shortcode_required = true;
$page = get_post( $page_id ); $page = get_post( $page_id );
if ( strstr( $page->post_content, $values['shortcode'] ) ) { if ( strstr( $page->post_content, $values['shortcode'] ) ) {
$shortcode_present = true; $shortcode_present = true;
} }
@ -1020,7 +1042,7 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller {
/** /**
* Prepare the system status response * Prepare the system status response
* *
* @param array $system_status * @param array $system_status
* @param WP_REST_Request $request Request object. * @param WP_REST_Request $request Request object.
* @return WP_REST_Response $response Response data. * @return WP_REST_Response $response Response data.
*/ */

View File

@ -12,9 +12,11 @@ class WC_Tests_REST_System_Status extends WC_REST_Unit_Test_Case {
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$this->endpoint = new WC_REST_System_Status_Controller(); $this->endpoint = new WC_REST_System_Status_Controller();
$this->user = $this->factory->user->create( array( $this->user = $this->factory->user->create(
'role' => 'administrator', array(
) ); 'role' => 'administrator',
)
);
} }
/** /**
@ -47,7 +49,7 @@ class WC_Tests_REST_System_Status extends WC_REST_Unit_Test_Case {
public function test_get_system_status_info_returns_root_properties() { public function test_get_system_status_info_returns_root_properties() {
wp_set_current_user( $this->user ); wp_set_current_user( $this->user );
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/system_status' ) ); $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/system_status' ) );
$data = $response->get_data(); $data = $response->get_data();
$this->assertArrayHasKey( 'environment', $data ); $this->assertArrayHasKey( 'environment', $data );
$this->assertArrayHasKey( 'database', $data ); $this->assertArrayHasKey( 'database', $data );
@ -194,9 +196,9 @@ class WC_Tests_REST_System_Status extends WC_REST_Unit_Test_Case {
* @since 3.0.0 * @since 3.0.0
*/ */
public function test_system_status_schema() { public function test_system_status_schema() {
$request = new WP_REST_Request( 'OPTIONS', '/wc/v2/system_status' ); $request = new WP_REST_Request( 'OPTIONS', '/wc/v2/system_status' );
$response = $this->server->dispatch( $request ); $response = $this->server->dispatch( $request );
$data = $response->get_data(); $data = $response->get_data();
$properties = $data['schema']['properties']; $properties = $data['schema']['properties'];
$this->assertEquals( 7, count( $properties ) ); $this->assertEquals( 7, count( $properties ) );
$this->assertArrayHasKey( 'environment', $properties ); $this->assertArrayHasKey( 'environment', $properties );
@ -216,7 +218,7 @@ class WC_Tests_REST_System_Status extends WC_REST_Unit_Test_Case {
public function test_get_system_tools() { public function test_get_system_tools() {
wp_set_current_user( $this->user ); wp_set_current_user( $this->user );
$tools_controller = new WC_REST_System_Status_Tools_Controller; $tools_controller = new WC_REST_System_Status_Tools_Controller();
$raw_tools = $tools_controller->get_tools(); $raw_tools = $tools_controller->get_tools();
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/system_status/tools' ) ); $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/system_status/tools' ) );
@ -224,20 +226,23 @@ class WC_Tests_REST_System_Status extends WC_REST_Unit_Test_Case {
$this->assertEquals( 200, $response->get_status() ); $this->assertEquals( 200, $response->get_status() );
$this->assertEquals( count( $raw_tools ), count( $data ) ); $this->assertEquals( count( $raw_tools ), count( $data ) );
$this->assertContains( array( $this->assertContains(
'id' => 'reset_tracking', array(
'name' => 'Reset usage tracking', 'id' => 'reset_tracking',
'action' => 'Reset', 'name' => 'Reset usage tracking',
'description' => 'This will reset your usage tracking settings, causing it to show the opt-in banner again and not sending any data.', 'action' => 'Reset',
'_links' => array( 'description' => 'This will reset your usage tracking settings, causing it to show the opt-in banner again and not sending any data.',
'item' => array( '_links' => array(
array( 'item' => array(
'href' => rest_url( '/wc/v2/system_status/tools/reset_tracking' ), array(
'embeddable' => true, 'href' => rest_url( '/wc/v2/system_status/tools/reset_tracking' ),
'embeddable' => true,
),
), ),
), ),
), ),
), $data ); $data
);
} }
/** /**
@ -259,7 +264,7 @@ class WC_Tests_REST_System_Status extends WC_REST_Unit_Test_Case {
public function test_get_system_tool() { public function test_get_system_tool() {
wp_set_current_user( $this->user ); wp_set_current_user( $this->user );
$tools_controller = new WC_REST_System_Status_Tools_Controller; $tools_controller = new WC_REST_System_Status_Tools_Controller();
$raw_tools = $tools_controller->get_tools(); $raw_tools = $tools_controller->get_tools();
$raw_tool = $raw_tools['recount_terms']; $raw_tool = $raw_tools['recount_terms'];
@ -293,7 +298,7 @@ class WC_Tests_REST_System_Status extends WC_REST_Unit_Test_Case {
public function test_execute_system_tool() { public function test_execute_system_tool() {
wp_set_current_user( $this->user ); wp_set_current_user( $this->user );
$tools_controller = new WC_REST_System_Status_Tools_Controller; $tools_controller = new WC_REST_System_Status_Tools_Controller();
$raw_tools = $tools_controller->get_tools(); $raw_tools = $tools_controller->get_tools();
$raw_tool = $raw_tools['recount_terms']; $raw_tool = $raw_tools['recount_terms'];
@ -327,9 +332,9 @@ class WC_Tests_REST_System_Status extends WC_REST_Unit_Test_Case {
* @since 3.0.0 * @since 3.0.0
*/ */
public function test_system_status_tool_schema() { public function test_system_status_tool_schema() {
$request = new WP_REST_Request( 'OPTIONS', '/wc/v2/system_status/tools' ); $request = new WP_REST_Request( 'OPTIONS', '/wc/v2/system_status/tools' );
$response = $this->server->dispatch( $request ); $response = $this->server->dispatch( $request );
$data = $response->get_data(); $data = $response->get_data();
$properties = $data['schema']['properties']; $properties = $data['schema']['properties'];
$this->assertEquals( 6, count( $properties ) ); $this->assertEquals( 6, count( $properties ) );
$this->assertArrayHasKey( 'id', $properties ); $this->assertArrayHasKey( 'id', $properties );