WooCommerce Code Reference

Features
in package

Features Class.

Table of Contents

$instance  : Loader
Class instance.
$retired_feature_compatibility_versions  : array<string, array{deprecated_since: string, removed_in: ?string}>
Version metadata for WC Admin feature flags kept for backward compatibility.
__construct()  : mixed
Constructor.
add_admin_body_classes()  : mixed
Adds body classes to the main wp-admin wrapper, allowing us to better target elements in specific scenarios.
add_features_section()  : array<string|int, mixed>
Adds the Features section to the advanced tab of WooCommerce Settings
add_features_settings()  : array<string|int, mixed>
Adds the Features settings.
disable()  : bool
Disable a toggleable optional feature.
enable()  : bool
Enable a toggleable optional feature.
exists()  : bool
Returns if a specific wc-admin feature exists in the current environment.
get_available_features()  : array<string|int, mixed>
Gets a build configured array of enabled WooCommerce Admin respecting optionally disabled features.
get_feature_class()  : string|null
Get the feature class as a string.
get_features()  : array<string|int, mixed>
Gets a build configured array of enabled WooCommerce Admin features/sections, but does not respect optionally disabled features.
get_instance()  : mixed
Get class instance.
get_legacy_feature_compatibility_values()  : array<string, bool>
Gets legacy feature flag compatibility values.
get_optional_feature_options()  : array<string|int, mixed>
Gets the optional feature options as an associative array that can be toggled on or off.
is_analytics_disabled_by_legacy_filters()  : bool
Checks if Analytics was disabled by legacy WooCommerce Admin filters.
is_enabled()  : bool
Check if a feature is enabled.
load_features()  : mixed
Class loader for enabled WooCommerce Admin features/sections.
load_scripts()  : mixed
Loads the required scripts on the correct pages.
get_features_with_legacy_compatibility_defaults()  : array<string|int, mixed>
Gets WooCommerce Admin features with legacy compatibility defaults before public filtering.
get_legacy_feature_compatibility_defaults()  : array<string, bool>
Gets default legacy feature flag compatibility values before public filtering.
get_legacy_feature_compatibility_deprecation_version()  : string|null
Gets the WooCommerce version where a legacy feature flag shim was deprecated.
get_legacy_feature_compatibility_removal_version()  : string|null
Gets the WooCommerce version where a legacy feature flag shim will be removed.
get_legacy_feature_compatibility_versions()  : array{deprecated_since: string, removed_in: ?string}|null
Gets version metadata for a legacy feature flag shim.
is_analytics_enabled()  : bool
Checks if analytics is enabled, without going through FeaturesController.
is_legacy_compatibility_feature()  : bool
Checks if a feature slug is supported only by the legacy compatibility shim.
register_internal_class_aliases()  : mixed
Alias internal features classes to make them backward compatible.
should_load_features()  : bool
Check if we're in an admin context where features should be loaded.
warn_legacy_feature_compatibility_usage()  : void
Emits a deprecation notice for a direct legacy feature flag shim lookup.

Properties

$retired_feature_compatibility_versions

Version metadata for WC Admin feature flags kept for backward compatibility.

private static array<string, array{deprecated_since: string, removed_in: ?string}> $retired_feature_compatibility_versions = array('activity-panels' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'analytics' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'analytics-scheduled-import' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'experimental-iapi-mini-cart' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'coupons' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'core-profiler' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'customize-store' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'customer-effort-score-tracks' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'import-products-task' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'experimental-fashion-sample-products' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'shipping-smart-defaults' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'shipping-setting-tour' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'homescreen' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'marketing' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'mobile-app-banner' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'onboarding' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'onboarding-tasks' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'pattern-toolkit-full-composability' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'payment-gateway-suggestions' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'product-custom-fields' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'printful' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'remote-inbox-notifications' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'remote-free-extensions' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'shipping-label-banner' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'subscriptions' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'transient-notices' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'wc-pay-promotion' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'wc-pay-welcome-page' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'woo-mobile-welcome' => array('deprecated_since' => '11.1.0', 'removed_in' => null), 'launch-your-store' => array('deprecated_since' => '11.1.0', 'removed_in' => null))

Keep this dictionary in sync with RETIRED_FEATURE_FLAGS in plugins/woocommerce/client/admin/client/utils/features/retired-feature-flags.ts.

Methods

add_admin_body_classes()

Adds body classes to the main wp-admin wrapper, allowing us to better target elements in specific scenarios.

public static add_admin_body_classes([string $admin_body_class = '' ]) : mixed
Parameters
$admin_body_class : string = ''

Body class to add.

Return values
mixed

add_features_section()

Adds the Features section to the advanced tab of WooCommerce Settings

public static add_features_section(array<string|int, mixed> $sections) : array<string|int, mixed>
Parameters
$sections : array<string|int, mixed>

Sections.

Tags
deprecated
7.0

The WooCommerce Admin features are now handled by the WooCommerce features engine (see the FeaturesController class).

Return values
array<string|int, mixed>

add_features_settings()

Adds the Features settings.

public static add_features_settings(array<string|int, mixed> $settings, string $current_section) : array<string|int, mixed>
Parameters
$settings : array<string|int, mixed>

Settings.

$current_section : string

Current section slug.

Tags
deprecated
7.0

The WooCommerce Admin features are now handled by the WooCommerce features engine (see the FeaturesController class).

Return values
array<string|int, mixed>

disable()

Disable a toggleable optional feature.

public static disable(string $feature) : bool
Parameters
$feature : string

Feature name.

Tags
deprecated
11.1.0

Use FeaturesUtil::feature_is_enabled() to check if a feature is enabled.

Return values
bool

enable()

Enable a toggleable optional feature.

public static enable(string $feature) : bool
Parameters
$feature : string

Feature name.

Tags
deprecated
11.1.0

Use FeaturesUtil::feature_is_enabled() to check if a feature is enabled.

Return values
bool

exists()

Returns if a specific wc-admin feature exists in the current environment.

public static exists(string $feature) : bool
Parameters
$feature : string

Feature slug.

Return values
boolReturns true if the feature exists.

get_available_features()

Gets a build configured array of enabled WooCommerce Admin respecting optionally disabled features.

public static get_available_features() : array<string|int, mixed>
Return values
array<string|int, mixed>Enabled Woocommerce Admin features/sections.

get_feature_class()

Get the feature class as a string.

public static get_feature_class(string $feature) : string|null
Parameters
$feature : string

Feature name.

Return values
string|null

get_features()

Gets a build configured array of enabled WooCommerce Admin features/sections, but does not respect optionally disabled features.

public static get_features() : array<string|int, mixed>
Return values
array<string|int, mixed>Enabled Woocommerce Admin features/sections.

get_legacy_feature_compatibility_values()

Gets legacy feature flag compatibility values.

public static get_legacy_feature_compatibility_values() : array<string, bool>

This method is intended for passive compatibility paths, such as script globals and filtering shared settings, where emitting deprecation notices would warn on every admin page load.

Tags
since
11.1.0
Return values
array<string, bool>

get_optional_feature_options()

Gets the optional feature options as an associative array that can be toggled on or off.

public static get_optional_feature_options() : array<string|int, mixed>
Tags
deprecated
11.1.0

Use FeaturesUtil::feature_is_enabled() to check if a feature is enabled.

Return values
array<string|int, mixed>

is_analytics_disabled_by_legacy_filters()

Checks if Analytics was disabled by legacy WooCommerce Admin filters.

public static is_analytics_disabled_by_legacy_filters() : bool
Return values
boolTrue if Analytics was disabled by legacy filters.

is_enabled()

Check if a feature is enabled.

public static is_enabled(string $feature) : bool
Parameters
$feature : string

Feature slug.

Return values
bool

load_features()

Class loader for enabled WooCommerce Admin features/sections.

public static load_features() : mixed
Return values
mixed

load_scripts()

Loads the required scripts on the correct pages.

public static load_scripts() : mixed
Return values
mixed

get_features_with_legacy_compatibility_defaults()

Gets WooCommerce Admin features with legacy compatibility defaults before public filtering.

private static get_features_with_legacy_compatibility_defaults() : array<string|int, mixed>
Return values
array<string|int, mixed>Enabled Woocommerce Admin features/sections.

get_legacy_feature_compatibility_defaults()

Gets default legacy feature flag compatibility values before public filtering.

private static get_legacy_feature_compatibility_defaults() : array<string, bool>
Return values
array<string, bool>

get_legacy_feature_compatibility_deprecation_version()

Gets the WooCommerce version where a legacy feature flag shim was deprecated.

private static get_legacy_feature_compatibility_deprecation_version(string $feature) : string|null
Parameters
$feature : string

Feature slug.

Return values
string|null

get_legacy_feature_compatibility_removal_version()

Gets the WooCommerce version where a legacy feature flag shim will be removed.

private static get_legacy_feature_compatibility_removal_version(string $feature) : string|null
Parameters
$feature : string

Feature slug.

Return values
string|null

get_legacy_feature_compatibility_versions()

Gets version metadata for a legacy feature flag shim.

private static get_legacy_feature_compatibility_versions(string $feature) : array{deprecated_since: string, removed_in: ?string}|null
Parameters
$feature : string

Feature slug.

Return values
array{deprecated_since: string, removed_in: ?string}|null

is_analytics_enabled()

Checks if analytics is enabled, without going through FeaturesController.

private static is_analytics_enabled() : bool
Return values
bool

is_legacy_compatibility_feature()

Checks if a feature slug is supported only by the legacy compatibility shim.

private static is_legacy_compatibility_feature(string $feature) : bool
Parameters
$feature : string

Feature slug.

Return values
bool

register_internal_class_aliases()

Alias internal features classes to make them backward compatible.

private register_internal_class_aliases() : mixed

We've moved our feature classes to src-internal as part of merging this repository with WooCommerce Core to form a monorepo. See https://wp.me/p90Yrv-2HY for details.

Return values
mixed

should_load_features()

Check if we're in an admin context where features should be loaded.

private static should_load_features() : bool
Return values
bool

warn_legacy_feature_compatibility_usage()

Emits a deprecation notice for a direct legacy feature flag shim lookup.

private static warn_legacy_feature_compatibility_usage(string $method, string $feature) : void
Parameters
$method : string

Method name.

$feature : string

Feature slug.

Return values
void