Automattic\WooCommerce\Internal\Features
FeaturesController::feature_is_enabled
Check if a given feature is currently enabled.
Note: This method does not log deprecation notices for deprecated features. Deprecation logging is handled by FeaturesUtil::feature_is_enabled() which is the public API.
Method of the class: FeaturesController{}
No Hooks.
Returns
true|false. True if the feature is enabled, false if not or if the feature doesn't exist.
Usage
$FeaturesController = new FeaturesController(); $FeaturesController->feature_is_enabled( $feature_id ): bool;
- $feature_id(string) (required)
- Unique feature id.
FeaturesController::feature_is_enabled() FeaturesController::feature is enabled code WC 10.8.1
public function feature_is_enabled( string $feature_id ): bool {
$feature = $this->get_feature_definition( $feature_id );
if ( null === $feature ) {
return false;
}
// Handle deprecated features - return the backwards-compatible value.
if ( ! empty( $feature['deprecated_since'] ) ) {
return (bool) ( $feature['deprecated_value'] ?? false );
}
if ( $this->is_preview_email_improvements_enabled( $feature_id ) ) {
return true;
}
$default_value = $this->feature_is_enabled_by_default( $feature_id ) ? 'yes' : 'no';
$value = 'yes' === get_option( $this->feature_enable_option_name( $feature_id ), $default_value );
return $value;
}