Automattic\WooCommerce\Admin\Features

Features::get_available_features()public staticWC 1.0

Gets a build configured array of enabled WooCommerce Admin respecting optionally disabled features.

Method of the class: Features{}

Hooks from the method

Return

Array. Enabled Woocommerce Admin features/sections.

Usage

$result = Features::get_available_features();

Features::get_available_features() code WC 8.6.1

public static function get_available_features() {
	$features                      = self::get_features();
	$optional_feature_keys         = array_keys( self::$optional_features );
	$optional_features_unavailable = [];

	/**
	 * Filter allowing WooCommerce Admin optional features to be disabled.
	 *
	 * @param bool $disabled False.
	 */
	if ( apply_filters( 'woocommerce_admin_disabled', false ) ) {
		return array_values( array_diff( $features, $optional_feature_keys ) );
	}

	foreach ( $optional_feature_keys as $optional_feature_key ) {
		$feature_class = self::get_feature_class( $optional_feature_key );

		if ( $feature_class ) {
			$default = isset( self::$optional_features[ $optional_feature_key ]['default'] ) ?
				self::$optional_features[ $optional_feature_key ]['default'] :
				'no';

			// Check if the feature is currently being enabled, if it is continue.
			/* phpcs:disable WordPress.Security.NonceVerification */
			$feature_option = $feature_class::TOGGLE_OPTION_NAME;
			if ( isset( $_POST[ $feature_option ] ) && '1' === $_POST[ $feature_option ] ) {
				continue;
			}

			if ( 'yes' !== get_option( $feature_class::TOGGLE_OPTION_NAME, $default ) ) {
				$optional_features_unavailable[] = $optional_feature_key;
			}
		}
	}

	return array_values( array_diff( $features, $optional_features_unavailable ) );
}