WooCommerce Code Reference

Features
in package

Features Class.

Table of Contents

$beta_features  : array<string|int, mixed>
Beta features
$instance  : Loader
Class instance.
$optional_features  : array<string|int, mixed>
Optional features
__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_optional_feature_options()  : array<string|int, mixed>
Gets the optional feature options as an associative array that can be toggled on or off.
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.
maybe_disable_features()  : mixed
Disable features when opting out of tracking.
maybe_load_beta_features_modal()  : mixed
Conditionally loads the beta features tracking modal.
register_internal_class_aliases()  : mixed
Alias internal features classes to make them backward compatible.

Properties

$beta_features

Beta features

protected static array<string|int, mixed> $beta_features = array('navigation', 'settings')

$optional_features

Optional features

protected static array<string|int, mixed> $optional_features = array('navigation' => array('default' => 'no'), 'settings' => array('default' => 'no'), 'analytics' => array('default' => 'yes'), 'remote-inbox-notifications' => array('default' => 'yes'))

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.

Return values
bool

enable()

Enable a toggleable optional feature.

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

Feature name.

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_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>
Return values
array<string|int, mixed>

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

maybe_disable_features()

Disable features when opting out of tracking.

public static maybe_disable_features(string $old_value, string $value) : mixed
Parameters
$old_value : string

Old value.

$value : string

New value.

Return values
mixed

maybe_load_beta_features_modal()

Conditionally loads the beta features tracking modal.

public static maybe_load_beta_features_modal(string $hook) : mixed
Parameters
$hook : string

Page hook.

Return values
mixed

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