Automattic\WooCommerce\Internal\Features

FeaturesController::get_compatible_features_for_plugin()publicWC 1.0

Get the ids of the features that a certain plugin has declared compatibility for.

This method can't be called before the woocommerce_init is fired.

Method of the class: FeaturesController{}

No Hooks.

Return

Array. An array having a 'compatible' and an 'incompatible' key, each holding an array of feature ids.

Usage

$FeaturesController = new FeaturesController();
$FeaturesController->get_compatible_features_for_plugin( $plugin_name, $enabled_features_only ) : array;
$plugin_name(string) (required)
Plugin name, in the form 'directory/file.php'.
$enabled_features_only(true|false)
True to return only names of enabled plugins.
Default: false

FeaturesController::get_compatible_features_for_plugin() code WC 8.6.1

public function get_compatible_features_for_plugin( string $plugin_name, bool $enabled_features_only = false ) : array {
	$this->verify_did_woocommerce_init( __FUNCTION__ );

	$features = $this->get_feature_definitions();
	if ( $enabled_features_only ) {
		$features = array_filter(
			$features,
			array( $this, 'feature_is_enabled' ),
			ARRAY_FILTER_USE_KEY
		);
	}

	if ( ! isset( $this->compatibility_info_by_plugin[ $plugin_name ] ) ) {
		return array(
			'compatible'   => array(),
			'incompatible' => array(),
			'uncertain'    => array_keys( $features ),
		);
	}

	$info                 = $this->compatibility_info_by_plugin[ $plugin_name ];
	$info['compatible']   = array_values( array_intersect( array_keys( $features ), $info['compatible'] ) );
	$info['incompatible'] = array_values( array_intersect( array_keys( $features ), $info['incompatible'] ) );
	$info['uncertain']    = array_values( array_diff( array_keys( $features ), $info['compatible'], $info['incompatible'] ) );

	return $info;
}