Merge pull request #25830 from woocommerce/fix/wc-admin-system-status-logic

Update system status info about WC Admin.
This commit is contained in:
Rodrigo Primo 2020-03-05 15:31:20 -03:00 committed by GitHub
commit 5ef13786e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 9 deletions

View File

@ -127,26 +127,40 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, 'min
<td class="help"><?php echo wc_help_tip( esc_html__( 'The WooCommerce Admin package running on your site.', 'woocommerce' ) ); ?></td>
<td>
<?php
if ( class_exists( '\Automattic\WooCommerce\Admin\Composer\Package' ) ) {
$version = \Automattic\WooCommerce\Admin\Composer\Package::get_active_version();
$package_active = \Automattic\WooCommerce\Admin\Composer\Package::is_package_active();
$path = \Automattic\WooCommerce\Admin\Composer\Package::get_path(); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
} elseif ( defined( 'WC_ADMIN_VERSION_NUMBER' ) ) {
$wc_admin_path = null;
if ( defined( 'WC_ADMIN_VERSION_NUMBER' ) ) {
// Plugin version of WC Admin.
$version = WC_ADMIN_VERSION_NUMBER;
$package_active = false;
} elseif ( class_exists( '\Automattic\WooCommerce\Admin\Composer\Package' ) ) {
if ( WC()->is_wc_admin_active() ) {
// Fully active package version of WC Admin.
$version = \Automattic\WooCommerce\Admin\Composer\Package::get_active_version();
$package_active = \Automattic\WooCommerce\Admin\Composer\Package::is_package_active();
} else {
// with WP version < 5.3, package is present, but inactive.
$version = __( 'Inactive ', 'woocommerce' );
$version .= \Automattic\WooCommerce\Admin\Composer\Package::VERSION;
$package_active = false;
}
$wc_admin_path = \Automattic\WooCommerce\Admin\Composer\Package::get_path();
} else {
$version = null;
}
if ( ! is_null( $version ) ) {
if ( ! isset( $path ) || ! $package_active ) {
if ( ! isset( $wc_admin_path ) ) {
if ( defined( 'WC_ADMIN_PLUGIN_FILE' ) ) {
$path = dirname( WC_ADMIN_PLUGIN_FILE ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
$wc_admin_path = dirname( WC_ADMIN_PLUGIN_FILE );
} else {
$path = __( 'Active Plugin', 'woocommerce' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
$wc_admin_path = __( 'Active Plugin', 'woocommerce' );
}
}
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span> ' . esc_html( $version ) . ' <code class="private">' . esc_html( $path ) . '</code></mark> ';
if ( WC()->is_wc_admin_active() ) {
echo '<mark class="yes"><span class="dashicons dashicons-yes"></span> ' . esc_html( $version ) . ' <code class="private">' . esc_html( $wc_admin_path ) . '</code></mark> ';
} else {
echo '<span class="dashicons dashicons-no-alt"></span> ' . esc_html( $version ) . ' <code class="private">' . esc_html( $wc_admin_path ) . '</code> ';
}
} else {
echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . esc_html__( 'Unable to detect the WC Admin package.', 'woocommerce' ) . '</mark>';
}