Automattic\WooCommerce\Internal\Features

FeaturesController::get_compatible_plugins_for_featurepublicWC 1.0

Get the names of the plugins that have been declared compatible or incompatible with a given feature.

Method of the class: FeaturesController{}

No Hooks.

Returns

Array. An array having a 'compatible', an 'incompatible' and an 'uncertain' key, each holding an array of plugin names.

Usage

$FeaturesController = new FeaturesController();
$FeaturesController->get_compatible_plugins_for_feature( $feature_id, $active_only, $resolve_uncertain ): array;
$feature_id(string) (required)
Feature id.
$active_only(true|false)
True to return only active plugins.
Default: false
$resolve_uncertain(true|false)
True to resolve the uncertain plugins to compatible or incompatible.
Default: false

FeaturesController::get_compatible_plugins_for_feature() code WC 10.3.3

public function get_compatible_plugins_for_feature( string $feature_id, bool $active_only = false, bool $resolve_uncertain = false ): array {
	$this->process_pending_declarations();
	$this->verify_did_woocommerce_init( __FUNCTION__ );

	$woo_aware_plugins = $this->plugin_util->get_woocommerce_aware_plugins( $active_only );
	if ( ! $this->feature_exists( $feature_id ) ) {
		return array(
			FeaturePluginCompatibility::COMPATIBLE   => array(),
			FeaturePluginCompatibility::INCOMPATIBLE => array(),
			FeaturePluginCompatibility::UNCERTAIN    => $woo_aware_plugins,
		);
	}

	$info = $this->compatibility_info_by_feature[ $feature_id ];
	ArrayUtil::ensure_key_is_array( $info, FeaturePluginCompatibility::UNCERTAIN );

	// Resolve uncertain plugin compatibility?
	$uncertain_plugins = array_values( array_diff( $woo_aware_plugins, $info[ FeaturePluginCompatibility::COMPATIBLE ], $info[ FeaturePluginCompatibility::INCOMPATIBLE ] ) );
	$key               = $resolve_uncertain ? $this->get_default_plugin_compatibility( $feature_id ) : FeaturePluginCompatibility::UNCERTAIN;
	$info[ $key ]      = array_merge( $info[ $key ], $uncertain_plugins );

	return $info;
}