Automattic\WooCommerce\Admin\Features\MarketingRecommendations

Init::get_recommended_plugins()public staticWC 1.0

Load recommended plugins from WooCommerce.com

Method of the class: Init{}

No Hooks.

Return

Array.

Usage

$result = Init::get_recommended_plugins(): array;

Init::get_recommended_plugins() code WC 9.1.2

public static function get_recommended_plugins(): array {
	$specs   = self::get_specs();
	$results = self::evaluate_specs( $specs );

	$specs_to_return = $results['suggestions'];
	$specs_to_save   = null;

	if ( empty( $specs_to_return ) ) {
		// When suggestions is empty, replace it with defaults and save for 3 hours.
		$specs_to_save   = DefaultMarketingRecommendations::get_all();
		$specs_to_return = self::evaluate_specs( $specs_to_save )['suggestions'];
	} elseif ( count( $results['errors'] ) > 0 ) {
		// When suggestions is not empty but has errors, save it for 3 hours.
		$specs_to_save = $specs;
	}

	if ( $specs_to_save ) {
		MarketingRecommendationsDataSourcePoller::get_instance()->set_specs_transient( $specs_to_save, 3 * HOUR_IN_SECONDS );
	}
	$errors = $results['errors'];
	if ( ! empty( $errors ) ) {
		self::log_errors( $errors );
	}

	return $specs_to_return;
}