diff --git a/plugins/woocommerce/readme.txt b/plugins/woocommerce/readme.txt index 67c9b61e9e8..b9df9748df1 100644 --- a/plugins/woocommerce/readme.txt +++ b/plugins/woocommerce/readme.txt @@ -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) diff --git a/plugins/woocommerce/src/Internal/Features/FeaturesController.php b/plugins/woocommerce/src/Internal/Features/FeaturesController.php index 518c1e7027f..bb9aa688b6f 100644 --- a/plugins/woocommerce/src/Internal/Features/FeaturesController.php +++ b/plugins/woocommerce/src/Internal/Features/FeaturesController.php @@ -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. *