Automattic\WooCommerce\Internal\Admin\Onboarding

OnboardingThemes::sort_woocommerce_themes()public staticWC 1.0

Sort themes returned from Woo.com

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

Хуков нет.

Возвращает

Массив.

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

$result = OnboardingThemes::sort_woocommerce_themes( $themes );
$themes(массив) (обязательный)
Array of themes from Woo.com.

Код OnboardingThemes::sort_woocommerce_themes() WC 8.7.0

public static function sort_woocommerce_themes( $themes ) {
	usort(
		$themes,
		function ( $product_1, $product_2 ) {
			if ( ! property_exists( $product_1, 'id' ) || ! property_exists( $product_1, 'slug' ) ) {
				return 1;
			}
			if ( ! property_exists( $product_2, 'id' ) || ! property_exists( $product_2, 'slug' ) ) {
				return 1;
			}
			if ( in_array( 'Storefront', array( $product_1->slug, $product_2->slug ), true ) ) {
				return 'Storefront' === $product_1->slug ? -1 : 1;
			}
			return $product_1->id < $product_2->id ? 1 : -1;
		}
	);
	return $themes;
}