Automattic\WooCommerce\Internal\Features
FeaturesController::get_features
Get all the existing WooCommerce features.
Returns an associative array where keys are unique feature ids and values are arrays with these keys:
- name (string)
- description (string)
- is_experimental (bool)
- is_enabled (bool) (only if $include_enabled_info is passed as true)
Метод класса: FeaturesController{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$FeaturesController = new FeaturesController(); $FeaturesController->get_features( $include_experimental, $include_enabled_info ): array;
- $include_experimental(true|false)
- Include also experimental/work in progress features in the list.
По умолчанию: false - $include_enabled_info(true|false)
- True to include the 'is_enabled' field in the returned features info.
По умолчанию: false
Код FeaturesController::get_features() FeaturesController::get features WC 10.3.4
public function get_features( bool $include_experimental = false, bool $include_enabled_info = false ): array {
$features = $this->get_feature_definitions();
if ( ! $include_experimental ) {
$features = array_filter(
$features,
function ( $feature ) {
return ! $feature['is_experimental'];
}
);
}
if ( $include_enabled_info ) {
foreach ( array_keys( $features ) as $feature_id ) {
$is_enabled = $this->feature_is_enabled( $feature_id );
$features[ $feature_id ]['is_enabled'] = $is_enabled;
}
}
// We're deprecating the product block editor feature in favor of a v3 coming out.
// We want to hide this setting in the UI for users that don't have it enabled.
// If users have it enabled, we won't hide it until they explicitly disable it.
if ( isset( $features['product_block_editor'] )
&& ! $this->feature_is_enabled( 'product_block_editor' ) ) {
$features['product_block_editor']['disable_ui'] = true;
}
return $features;
}