Automattic\WooCommerce\Utilities
FeaturesUtil::declare_compatibility()
Declare (in)compatibility with a given feature for a given plugin.
This method MUST be executed from inside a handler for the before_woocommerce_init and SHOULD be executed from the main plugin file passing __FILE__ or 'my-plugin/my-plugin.php' for the $plugin_file argument.
Method of the class: FeaturesUtil{}
No Hooks.
Return
true|false
. True on success, false on error (feature doesn't exist or not inside the required hook).
Usage
$result = FeaturesUtil::declare_compatibility( $feature_id, $plugin_file, $positive_compatibility ): bool;
- $feature_id(string) (required)
- Unique feature id.
- $plugin_file(string) (required)
- The full plugin file path.
- $positive_compatibility(true|false)
- True if the plugin declares being compatible with the feature, false if it declares being incompatible.
Default: true
FeaturesUtil::declare_compatibility() FeaturesUtil::declare compatibility code WC 9.4.2
public static function declare_compatibility( string $feature_id, string $plugin_file, bool $positive_compatibility = true ): bool { $plugin_id = wc_get_container()->get( PluginUtil::class )->get_wp_plugin_id( $plugin_file ); if ( ! $plugin_id ) { $logger = wc_get_logger(); $logger->error( "FeaturesUtil::declare_compatibility: {$plugin_file} is not a known WordPress plugin." ); return false; } return wc_get_container()->get( FeaturesController::class )->declare_compatibility( $feature_id, $plugin_id, $positive_compatibility ); }