Revert packages initialization timeline change (#51728)
* Revert packages initialization timeline change * Add changefile(s) from automation for the following project(s): woocommerce * Fix lint errors --------- Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
parent
9b3073999b
commit
08b8dd99cc
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: tweak
|
||||||
|
Comment: This PR reverts a change that hasn't yet been released, so no changelog is required.
|
||||||
|
|
|
@ -26,7 +26,7 @@ class WC_Brands {
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->template_url = apply_filters( 'woocommerce_template_url', 'woocommerce/' ); // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
|
$this->template_url = apply_filters( 'woocommerce_template_url', 'woocommerce/' ); // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
|
||||||
|
|
||||||
add_action( 'plugins_loaded', array( $this, 'register_hooks' ), 2 );
|
add_action( 'plugins_loaded', array( $this, 'register_hooks' ), 11 );
|
||||||
|
|
||||||
$this->register_shortcodes();
|
$this->register_shortcodes();
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,6 @@ class Brands {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the WooCommerce Brands plugin is activated via the WP CLI using the '--skip-plugins' flag, deactivate it here.
|
|
||||||
if ( function_exists( 'wc_brands_init' ) ) {
|
|
||||||
remove_action( 'plugins_loaded', 'wc_brands_init', 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
include_once WC_ABSPATH . 'includes/class-wc-brands.php';
|
include_once WC_ABSPATH . 'includes/class-wc-brands.php';
|
||||||
include_once WC_ABSPATH . 'includes/class-wc-brands-coupons.php';
|
include_once WC_ABSPATH . 'includes/class-wc-brands-coupons.php';
|
||||||
include_once WC_ABSPATH . 'includes/class-wc-brands-brand-settings-manager.php';
|
include_once WC_ABSPATH . 'includes/class-wc-brands-brand-settings-manager.php';
|
||||||
|
@ -58,4 +53,19 @@ class Brands {
|
||||||
}
|
}
|
||||||
return ( $assignment <= 6 ); // Considering 5% of the 0-120 range.
|
return ( $assignment <= 6 ); // Considering 5% of the 0-120 range.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If WooCommerce Brands gets activated forcibly, without WooCommerce active (e.g. via '--skip-plugins'),
|
||||||
|
* remove WooCommerce Brands initialization functions early on in the 'plugins_loaded' timeline.
|
||||||
|
*/
|
||||||
|
public static function prepare() {
|
||||||
|
|
||||||
|
if ( ! self::is_enabled() ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( function_exists( 'wc_brands_init' ) ) {
|
||||||
|
remove_action( 'plugins_loaded', 'wc_brands_init', 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,8 @@ class Packages {
|
||||||
* @since 3.7.0
|
* @since 3.7.0
|
||||||
*/
|
*/
|
||||||
public static function init() {
|
public static function init() {
|
||||||
add_action( 'plugins_loaded', array( __CLASS__, 'on_init' ), 0 );
|
add_action( 'plugins_loaded', array( __CLASS__, 'prepare_packages' ), -100 );
|
||||||
|
add_action( 'plugins_loaded', array( __CLASS__, 'on_init' ), 10 );
|
||||||
|
|
||||||
// Prevent plugins already merged into WooCommerce core from getting activated as standalone plugins.
|
// Prevent plugins already merged into WooCommerce core from getting activated as standalone plugins.
|
||||||
add_action( 'activate_plugin', array( __CLASS__, 'deactivate_merged_plugins' ) );
|
add_action( 'activate_plugin', array( __CLASS__, 'deactivate_merged_plugins' ) );
|
||||||
|
@ -149,6 +150,18 @@ class Packages {
|
||||||
return array_key_exists( $package, self::get_enabled_packages() );
|
return array_key_exists( $package, self::get_enabled_packages() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare merged packages for initialization.
|
||||||
|
* Especially useful when running actions early in the 'plugins_loaded' timeline.
|
||||||
|
*/
|
||||||
|
public static function prepare_packages() {
|
||||||
|
foreach ( self::get_enabled_packages() as $package_name => $package_class ) {
|
||||||
|
if ( method_exists( $package_class, 'prepare' ) ) {
|
||||||
|
call_user_func( array( $package_class, 'prepare' ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deactivates merged feature plugins.
|
* Deactivates merged feature plugins.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue