Automattic\WooCommerce\Internal\Features
FeaturesController::init_feature_definitions() │ private │ WC 1.0
Initialize the hardcoded feature definitions array. This doesn't include:
- Features that get initialized via the (deprecated) woocommerce_register_feature_definitions.
- Features whose definition comes from another class. These are initialized directly in get_feature_definitions to avoid circular calls in the dependency injection container.
Метод класса: FeaturesController{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->init_feature_definitions(): void;
Код FeaturesController::init_feature_definitions() FeaturesController::init feature definitions WC 9.8.2
private function init_feature_definitions(): void { $alpha_feature_testing_is_enabled = Constants::is_true( 'WOOCOMMERCE_ENABLE_ALPHA_FEATURE_TESTING' ); $tracking_enabled = WC_Site_Tracking::is_tracking_enabled(); $legacy_features = array( 'analytics' => array( 'name' => __( 'Analytics', 'woocommerce' ), 'description' => __( 'Enable WooCommerce Analytics', 'woocommerce' ), 'option_key' => Analytics::TOGGLE_OPTION_NAME, 'is_experimental' => false, 'enabled_by_default' => true, 'disable_ui' => false, 'is_legacy' => true, ), 'product_block_editor' => array( 'name' => __( 'New product editor', 'woocommerce' ), 'description' => __( 'Try the new product editor (Beta)', 'woocommerce' ), 'is_experimental' => true, 'disable_ui' => false, 'is_legacy' => true, 'disabled' => function () { return version_compare( get_bloginfo( 'version' ), '6.2', '<' ); }, 'desc_tip' => function () { $string = ''; if ( version_compare( get_bloginfo( 'version' ), '6.2', '<' ) ) { $string = __( '⚠ This feature is compatible with WordPress version 6.2 or higher.', 'woocommerce' ); } return $string; }, ), 'cart_checkout_blocks' => array( 'name' => __( 'Cart & Checkout Blocks', 'woocommerce' ), 'description' => __( 'Optimize for faster checkout', 'woocommerce' ), 'is_experimental' => false, 'disable_ui' => true, ), 'rate_limit_checkout' => array( 'name' => __( 'Rate limit Checkout', 'woocommerce' ), 'description' => sprintf( // translators: %s is the URL to the rate limiting documentation. __( 'Enables rate limiting for Checkout place order and Store API /checkout endpoint. To further control this, refer to <a href="%s" target="_blank">rate limiting documentation</a>.', 'woocommerce' ), 'https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/src/StoreApi/docs/rate-limiting.md' ), 'is_experimental' => false, 'disable_ui' => false, 'enabled_by_default' => false, 'is_legacy' => true, ), 'marketplace' => array( 'name' => __( 'Marketplace', 'woocommerce' ), 'description' => __( 'New, faster way to find extensions and themes for your WooCommerce store', 'woocommerce' ), 'is_experimental' => false, 'enabled_by_default' => true, 'disable_ui' => true, 'is_legacy' => true, ), // Marked as a legacy feature to avoid compatibility checks, which aren't really relevant to this feature. // https://github.com/woocommerce/woocommerce/pull/39701#discussion_r1376976959. 'order_attribution' => array( 'name' => __( 'Order Attribution', 'woocommerce' ), 'description' => __( 'Enable this feature to track and credit channels and campaigns that contribute to orders on your site', 'woocommerce' ), 'enabled_by_default' => true, 'disable_ui' => false, 'is_legacy' => true, 'is_experimental' => false, ), 'site_visibility_badge' => array( 'name' => __( 'Site visibility badge', 'woocommerce' ), 'description' => __( 'Enable the site visibility badge in the WordPress admin bar', 'woocommerce' ), 'enabled_by_default' => true, 'disable_ui' => false, 'is_legacy' => true, 'is_experimental' => false, 'disabled' => false, ), 'hpos_fts_indexes' => array( 'name' => __( 'HPOS Full text search indexes', 'woocommerce' ), 'description' => __( 'Create and use full text search indexes for orders. This feature only works with high-performance order storage.', 'woocommerce' ), 'is_experimental' => true, 'enabled_by_default' => false, 'is_legacy' => true, 'option_key' => CustomOrdersTableController::HPOS_FTS_INDEX_OPTION, ), 'hpos_datastore_caching' => array( 'name' => __( 'HPOS Data Caching', 'woocommerce' ), 'description' => __( 'Enable order data caching in the datastore. This feature only works with high-performance order storage.', 'woocommerce' ), 'is_experimental' => true, 'enabled_by_default' => false, 'is_legacy' => true, 'disable_ui' => ! $alpha_feature_testing_is_enabled, 'setting' => array( 'disabled' => ! ( $alpha_feature_testing_is_enabled && wp_using_ext_object_cache() ), 'desc_tip' => function () { $string = ''; if ( ! wp_using_ext_object_cache() ) { $string = __( '⚠ This feature is currently only suggested with the use of external object caching.', 'woocommerce' ); } return $string; }, ), 'option_key' => CustomOrdersTableController::HPOS_DATASTORE_CACHING_ENABLED_OPTION, ), 'remote_logging' => array( 'name' => __( 'Remote Logging', 'woocommerce' ), 'description' => sprintf( /* translators: %1$s: opening link tag, %2$s: closing link tag */ __( 'Allow WooCommerce to send error logs and non-sensitive diagnostic data to help improve WooCommerce. This feature requires %1$susage tracking%2$s to be enabled.', 'woocommerce' ), '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=advanced§ion=woocommerce_com' ) . '">', '</a>' ), 'enabled_by_default' => true, 'disable_ui' => false, /* * This is not truly a legacy feature (it is not a feature that pre-dates the FeaturesController), * but we wish to handle compatibility checking in a similar fashion to legacy features. The * rational for setting legacy to true is therefore similar to that of the 'order_attribution' * feature. * * @see https://github.com/woocommerce/woocommerce/pull/39701#discussion_r1376976959 */ 'is_legacy' => true, 'is_experimental' => false, 'setting' => array( 'disabled' => function () use ( $tracking_enabled ) { return ! $tracking_enabled; }, 'desc_tip' => function () use ( $tracking_enabled ) { if ( ! $tracking_enabled ) { return __( '⚠ Usage tracking must be enabled to use remote logging.', 'woocommerce' ); } return ''; }, ), ), 'email_improvements' => array( 'name' => __( 'Email improvements', 'woocommerce' ), 'description' => __( 'Enable modern email design for transactional emails', 'woocommerce' ), /* * This is not truly a legacy feature (it is not a feature that pre-dates the FeaturesController), * but as this feature doesn't affect all extensions, and the rollout is fairly short, * we'll skip the compatibility check by marking this as legacy. This is a workaround until * we can implement a more sophisticated compatibility checking system. * * @see https://github.com/woocommerce/woocommerce/issues/39147 * @see https://github.com/woocommerce/woocommerce/issues/55540 */ 'is_legacy' => true, 'is_experimental' => false, ), 'blueprint' => array( 'name' => __( 'Blueprint (beta)', 'woocommerce' ), 'description' => __( 'Enable blueprint to import and export settings in bulk', 'woocommerce' ), 'enabled_by_default' => false, 'disable_ui' => true, /* * This is not truly a legacy feature (it is not a feature that pre-dates the FeaturesController), * but we wish to handle compatibility checking in a similar fashion to legacy features. The * rational for setting legacy to true is therefore similar to that of the 'order_attribution' * feature. * * @see https://github.com/woocommerce/woocommerce/pull/39701#discussion_r1376976959 */ 'is_legacy' => true, 'is_experimental' => false, ), 'reactify-classic-payments-settings' => array( 'name' => __( 'Payments Settings (beta)', 'woocommerce' ), 'description' => __( 'Enable the new payments settings experience', 'woocommerce' ), 'enabled_by_default' => false, 'disable_ui' => false, /* * This is not truly a legacy feature (it is not a feature that pre-dates the FeaturesController), * but we wish to handle compatibility checking in a similar fashion to legacy features. The * rational for setting legacy to true is therefore similar to that of the 'order_attribution' * feature. * * @see https://github.com/woocommerce/woocommerce/pull/39701#discussion_r1376976959 */ 'is_legacy' => true, 'is_experimental' => false, ), 'block_email_editor' => array( 'name' => __( 'Block Email Editor (alpha)', 'woocommerce' ), 'description' => __( 'Enable the block-based email editor for transactional emails', 'woocommerce' ), 'enabled_by_default' => false, 'disable_ui' => true, ), ); if ( ! $tracking_enabled ) { // Uncheck the remote logging feature when usage tracking is disabled. $legacy_features['remote_logging']['setting']['value'] = 'no'; } foreach ( $legacy_features as $slug => $definition ) { $this->add_feature_definition( $slug, $definition['name'], $definition ); } $this->init_compatibility_info_by_feature(); }