FeaturesUtil::declare_compatibility()public staticWC 1.0

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.

Метод класса: FeaturesUtil{}

Хуков нет.


true|false. True on success, false on error (feature doesn't exist or not inside the required hook).


$result = FeaturesUtil::declare_compatibility( $feature_id, $plugin_file, $positive_compatibility ): bool;
$feature_id(строка) (обязательный)
Unique feature id.
$plugin_file(строка) (обязательный)
The full plugin file path.
True if the plugin declares being compatible with the feature, false if it declares being incompatible.
По умолчанию: true

Код FeaturesUtil::declare_compatibility() WC 8.9.0

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 );