Merge pull request #32814 from woocommerce/fix/32797-wca-fatal
Fix WCA fatal with bail conditions for WCA execution paths
This commit is contained in:
commit
959ba869c1
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: minor
|
||||||
|
Type: fix
|
||||||
|
|
||||||
|
Fix fatal errors when activated alongside WooCommerce Admin plugin
|
|
@ -4,6 +4,7 @@ namespace Automattic\WooCommerce\Admin;
|
||||||
|
|
||||||
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
|
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
|
||||||
use Automattic\WooCommerce\Admin\Features\Features;
|
use Automattic\WooCommerce\Admin\Features\Features;
|
||||||
|
use Automattic\WooCommerce\Internal\Admin\WCAdminAssets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loader Class.
|
* Loader Class.
|
||||||
|
@ -12,6 +13,20 @@ use Automattic\WooCommerce\Admin\Features\Features;
|
||||||
*/
|
*/
|
||||||
class Loader extends DeprecatedClassFacade {
|
class Loader extends DeprecatedClassFacade {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the non-deprecated class that this facade covers.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected static $facade_over_classname = 'Automattic\WooCommerce\Internal\Admin\Loader';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The version that this class was deprecated in.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected static $deprecated_in_version = '6.3.0';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if a specific wc-admin feature is enabled.
|
* Returns if a specific wc-admin feature is enabled.
|
||||||
*
|
*
|
||||||
|
@ -55,4 +70,20 @@ class Loader extends DeprecatedClassFacade {
|
||||||
wc_deprecated_function( 'is_embed_page', '6.3', '\Automattic\WooCommerce\Admin\PageController::is_embed_page()' );
|
wc_deprecated_function( 'is_embed_page', '6.3', '\Automattic\WooCommerce\Admin\PageController::is_embed_page()' );
|
||||||
return PageController::is_embed_page();
|
return PageController::is_embed_page();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if a minified JS file should be served.
|
||||||
|
*
|
||||||
|
* @param boolean $script_debug Only serve unminified files if script debug is on.
|
||||||
|
* @return boolean If js asset should use minified version.
|
||||||
|
*
|
||||||
|
* @deprecated since 6.3.0, use WCAdminAssets::should_use_minified_js_file( $script_debug )
|
||||||
|
*/
|
||||||
|
public static function should_use_minified_js_file( $script_debug ) {
|
||||||
|
// Bail if WC isn't initialized (This can be called from WCAdmin's entrypoint).
|
||||||
|
if ( ! defined( 'WC_ABSPATH' ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return WCAdminAssets::should_use_minified_js_file( $script_debug );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,11 @@ class FeaturePlugin {
|
||||||
* Init the feature plugin, only if we can detect both Gutenberg and WooCommerce.
|
* Init the feature plugin, only if we can detect both Gutenberg and WooCommerce.
|
||||||
*/
|
*/
|
||||||
public function init() {
|
public function init() {
|
||||||
|
// Bail if WC isn't initialized (This can be called from WCAdmin's entrypoint).
|
||||||
|
if ( ! defined( 'WC_ABSPATH' ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Load the page controller functions file first to prevent fatal errors when disabling WooCommerce Admin.
|
// Load the page controller functions file first to prevent fatal errors when disabling WooCommerce Admin.
|
||||||
$this->define_constants();
|
$this->define_constants();
|
||||||
require_once WC_ADMIN_ABSPATH . '/includes/react-admin/page-controller-functions.php';
|
require_once WC_ADMIN_ABSPATH . '/includes/react-admin/page-controller-functions.php';
|
||||||
|
@ -114,7 +119,15 @@ class FeaturePlugin {
|
||||||
* @deprecated 3.3.0
|
* @deprecated 3.3.0
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
define( 'WC_ADMIN_VERSION_NUMBER', '3.3.0' );
|
if ( ! defined( 'WC_ADMIN_VERSION_NUMBER' ) ) {
|
||||||
|
/**
|
||||||
|
* Define the current WC Admin version.
|
||||||
|
*
|
||||||
|
* @deprecated 3.3.0
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
define( 'WC_ADMIN_VERSION_NUMBER', '3.3.0' );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -84,30 +84,29 @@ class Loader {
|
||||||
*/
|
*/
|
||||||
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
|
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
|
||||||
|
|
||||||
add_action( 'admin_init', array( __CLASS__, 'is_using_installed_wc_admin_plugin' ) );
|
add_action( 'admin_init', array( __CLASS__, 'deactivate_wc_admin_plugin' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies which plugin version is being used. If WooCommerce Admin is installed and activated but not in use
|
* If WooCommerce Admin is installed and activated, it will attempt to deactivate and show a notice.
|
||||||
* it will show a warning.
|
|
||||||
*/
|
*/
|
||||||
public static function is_using_installed_wc_admin_plugin() {
|
public static function deactivate_wc_admin_plugin() {
|
||||||
if ( PluginsHelper::is_plugin_active( 'woocommerce-admin' ) ) {
|
if ( PluginsHelper::is_plugin_active( 'woocommerce-admin' ) ) {
|
||||||
$path = PluginsHelper::get_plugin_data( 'woocommerce-admin' );
|
$path = PluginsHelper::get_plugin_path_from_slug( 'woocommerce-admin' );
|
||||||
if ( WC_ADMIN_VERSION_NUMBER !== $path['Version'] ) {
|
deactivate_plugins( $path );
|
||||||
add_action(
|
add_action(
|
||||||
'admin_notices',
|
'admin_notices',
|
||||||
function() {
|
function() {
|
||||||
echo '<div class="error"><p>';
|
echo '<div class="error"><p>';
|
||||||
printf(
|
printf(
|
||||||
/* translators: %s: is referring to the plugin's name. */
|
/* translators: %s: is referring to the plugin's name. */
|
||||||
esc_html__( 'You have the %s plugin activated but it is not being used.', 'woocommerce' ),
|
esc_html__( '%1$s plugin has been deactivated to avoid conflicts with %2$s plugin.', 'woocommerce' ),
|
||||||
'<code>WooCommerce Admin</code>'
|
'<code>WooCommerce Admin</code>',
|
||||||
);
|
'<code>WooCommerce</code>'
|
||||||
echo '</p></div>';
|
);
|
||||||
}
|
echo '</p></div>';
|
||||||
);
|
}
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue