Automattic\WooCommerce\Internal\Features
FeaturesController::add_feature_definition()
Register a feature.
This should be called during the woocommerce_register_feature_definitions hook.
Метод класса: FeaturesController{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$FeaturesController = new FeaturesController(); $FeaturesController->add_feature_definition( $slug, $name, $args );
- $slug(строка) (обязательный)
- The ID slug of the feature.
- $name(строка) (обязательный)
- The name of the feature that will appear on the Features screen and elsewhere.
- $args(массив)
Properties that make up the feature definition. Each of these properties can also be set as a callback function, as long as that function returns the specified type.
По умолчанию: array()
-
additional_settings(array[])
An array of definitions for additional settings controls related to the feature that will display on the Features screen. See the Settings API for the schema of these props. -
description(строка)
A brief description of the feature, used as an input label if the feature setting is a checkbox. -
disabled(true|false)
True to disable the setting field for this feature on the Features screen, so it can't be changed. -
disable_ui(true|false)
Set to true to hide the setting field for this feature on the Features screen.
По умолчанию: false -
enabled_by_default(true|false)
Set to true to have this feature by opt-out instead of opt-in.
По умолчанию: false -
is_experimental(true|false)
Set to true to display this feature under the "Experimental" heading on the Features screen. Features set to experimental are also omitted from the features list in some cases.
По умолчанию: true -
is_legacy(true|false)
Set to true if this feature existed before the FeaturesController class was introduced. Features set to legacy also do not produce warnings about incompatible plugins.
По умолчанию: false -
option_key(строка)
The key name for the option that enables/disables the feature. -
order(int)
The order that the feature will appear in the list on the Features screen. Higher number = higher in the list.
По умолчанию: 10 - setting(массив)
The properties used by the Settings API to render the setting control on the Features screen. See the Settings API for the schema of these props.
-
Код FeaturesController::add_feature_definition() FeaturesController::add feature definition WC 9.4.2
public function add_feature_definition( $slug, $name, array $args = array() ) { $defaults = array( 'disable_ui' => false, 'enabled_by_default' => false, 'is_experimental' => true, 'is_legacy' => false, 'plugins_are_incompatible_by_default' => false, 'name' => $name, 'order' => 10, ); $args = wp_parse_args( $args, $defaults ); $this->features[ $slug ] = $args; }