Automattic\WooCommerce\Internal\Features

FeaturesController::get_compatible_plugins_for_feature()publicWC 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.

Return

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 ): array;
$feature_id(string) (required)
Feature id.
$active_only(true|false)
True to return only active plugins.
Default: false

FeaturesController::get_compatible_plugins_for_feature() code WC 9.3.3

public function get_compatible_plugins_for_feature( string $feature_id, bool $active_only = false ): array {
	$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(
			'compatible'   => array(),
			'incompatible' => array(),
			'uncertain'    => $woo_aware_plugins,
		);
	}

	$info              = $this->compatibility_info_by_feature[ $feature_id ];
	$info['uncertain'] = array_values( array_diff( $woo_aware_plugins, $info['compatible'], $info['incompatible'] ) );

	return $info;
}