Automattic\WooCommerce\Internal\Features
FeaturesController::get_default_plugin_compatibility
Get the default plugin compatibility for a given feature.
Method of the class: FeaturesController{}
Hooks from the method
Returns
String. Either 'compatible' or 'incompatible'.
Usage
$FeaturesController = new FeaturesController(); $FeaturesController->get_default_plugin_compatibility( $feature_id ): string;
- $feature_id(string) (required)
- Feature id to check.
FeaturesController::get_default_plugin_compatibility() FeaturesController::get default plugin compatibility code WC 10.3.3
public function get_default_plugin_compatibility( string $feature_id ): string {
$feature_definition = $this->get_feature_definitions()[ $feature_id ] ?? null;
if ( is_null( $feature_definition ) ) {
throw new \InvalidArgumentException( esc_html( "The WooCommerce feature '$feature_id' doesn't exist" ) );
}
$default_plugin_compatibility = $feature_definition['default_plugin_compatibility'] ?? FeaturePluginCompatibility::COMPATIBLE;
// Filter below is only fired for backwards compatibility with (now removed) get_plugins_are_incompatible_by_default().
/**
* Filter to determine if plugins that don't declare compatibility nor incompatibility with a given feature
* are to be considered incompatible with that feature.
*
* @param bool $incompatible_by_default Default value, true if plugins are to be considered incompatible by default with the feature.
* @param string $feature_id The feature to check.
*
* @since 9.2.0
*/
$incompatible_by_default = (bool) apply_filters( 'woocommerce_plugins_are_incompatible_with_feature_by_default', FeaturePluginCompatibility::INCOMPATIBLE === $default_plugin_compatibility, $feature_id );
return $incompatible_by_default ? FeaturePluginCompatibility::INCOMPATIBLE : FeaturePluginCompatibility::COMPATIBLE;
}