Cherry pick 52557 into release/9.4 (#52562)
* Do not listen to changes made through the Options API before init. (#52557) * Do not listen to changes made through the Options API before init. This specifically relates to the Features Controller, which currently loads a list of feature definitions (and that involves translating strings, which is not recommended before init). Since we do not expect features to be enabled/disabled this early, this should be a reasonable adjustment. * Update plugins/woocommerce/src/Internal/Features/FeaturesController.php Co-authored-by: Corey McKrill <916023+coreymckrill@users.noreply.github.com> --------- Co-authored-by: Corey McKrill <916023+coreymckrill@users.noreply.github.com> * Prep for cherry pick 52557 --------- Co-authored-by: Barry Hughes <3594411+barryhughes@users.noreply.github.com> Co-authored-by: Corey McKrill <916023+coreymckrill@users.noreply.github.com> Co-authored-by: WooCommerce Bot <no-reply@woocommerce.com>
This commit is contained in:
parent
8d43215daa
commit
592c05a10e
|
@ -316,6 +316,7 @@ WooCommerce comes with some sample data you can use to see how products look; im
|
|||
* Dev - Update docs [#51144](https://github.com/woocommerce/woocommerce/pull/51144)
|
||||
* Dev - Updated webpack build script for wc admin so that the wp-admin-scripts are dynamically fetched from the fs instead of a hard list [#51133](https://github.com/woocommerce/woocommerce/pull/51133)
|
||||
* Dev - [Enhancement] Abstract rating block #50810 [#50810](https://github.com/woocommerce/woocommerce/pull/50810)
|
||||
* Tweak - Limit the amount of Feature Controller logic that will run before init, to improve compatibility with translation-related changes in WP 6.7. [#52557](https://github.com/woocommerce/woocommerce/pull/52557)
|
||||
* Tweak - Add default Facebook for WooCommerce plugin recommendation. [#52405](https://github.com/woocommerce/woocommerce/pull/52405)
|
||||
* Tweak - Fix PHPCS warnings in OrdersTableQuery.php and ProductQuery.php [#51281](https://github.com/woocommerce/woocommerce/pull/51281)
|
||||
* Tweak - Fix typo in inline doc in woocommerce client, includes, and lib folders. [#50739](https://github.com/woocommerce/woocommerce/pull/50739)
|
||||
|
|
|
@ -18,6 +18,8 @@ defined( 'ABSPATH' ) || exit;
|
|||
* Class to define the WooCommerce features that can be enabled and disabled by admin users,
|
||||
* provides also a mechanism for WooCommerce plugins to declare that they are compatible
|
||||
* (or incompatible) with a given feature.
|
||||
*
|
||||
* Features should not be enabled, or disabled, before init.
|
||||
*/
|
||||
class FeaturesController {
|
||||
|
||||
|
@ -89,8 +91,7 @@ class FeaturesController {
|
|||
* Creates a new instance of the class.
|
||||
*/
|
||||
public function __construct() {
|
||||
self::add_filter( 'updated_option', array( $this, 'process_updated_option' ), 999, 3 );
|
||||
self::add_filter( 'added_option', array( $this, 'process_added_option' ), 999, 3 );
|
||||
self::add_filter( 'init', array( $this, 'start_listening_for_option_changes' ), 10, 0 );
|
||||
self::add_filter( 'woocommerce_get_sections_advanced', array( $this, 'add_features_section' ), 10, 1 );
|
||||
self::add_filter( 'woocommerce_get_settings_advanced', array( $this, 'add_feature_settings' ), 10, 2 );
|
||||
self::add_filter( 'deactivated_plugin', array( $this, 'handle_plugin_deactivation' ), 10, 1 );
|
||||
|
@ -608,6 +609,19 @@ class FeaturesController {
|
|||
$this->force_allow_enabling_plugins = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds our callbacks for the `updated_option` and `added_option` filter hooks.
|
||||
*
|
||||
* We delay adding these hooks until `init`, because both callbacks need to load our list of feature definitions,
|
||||
* and building that list requires translating various strings (which should not be done earlier than `init`).
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function start_listening_for_option_changes(): void {
|
||||
self::add_filter( 'updated_option', array( $this, 'process_updated_option' ), 999, 3 );
|
||||
self::add_filter( 'added_option', array( $this, 'process_added_option' ), 999, 3 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for the 'added_option' hook.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue