Automattic\WooCommerce\Internal\Admin\RemoteFreeExtensions

EvaluateExtension::evaluate_bundles()public staticWC 1.0

Evaluates the specs and returns the bundles with visible extensions.

Метод класса: EvaluateExtension{}

Хуков нет.

Возвращает

Массив. The bundles and errors.

Использование

$result = EvaluateExtension::evaluate_bundles( $specs, $allowed_bundles );
$specs(массив) (обязательный)
extensions spec array.
$allowed_bundles(массив)
Optional array of allowed bundles to be returned.
По умолчанию: array()

Код EvaluateExtension::evaluate_bundles() WC 9.5.1

public static function evaluate_bundles( $specs, $allowed_bundles = array() ) {
	$bundles = array();

	foreach ( $specs as $spec ) {
		$spec              = (object) $spec;
		$bundle            = (array) $spec;
		$bundle['plugins'] = array();

		if ( ! empty( $allowed_bundles ) && ! in_array( $spec->key, $allowed_bundles, true ) ) {
			continue;
		}

		$errors = array();
		foreach ( $spec->plugins as $plugin ) {
			try {
				$extension = self::evaluate( (object) $plugin );
				if ( ! property_exists( $extension, 'is_visible' ) || $extension->is_visible ) {
					$bundle['plugins'][] = $extension;
				}
			} catch ( \Throwable $e ) {
				$errors[] = $e;
			}
		}

		$bundles[] = $bundle;
	}

	return array(
		'bundles' => $bundles,
		'errors'  => $errors,
	);
}