Automattic\WooCommerce\Internal\Admin\Onboarding
OnboardingThemes::sort_woocommerce_themes()
Sort themes returned from Woo.com
Method of the class: OnboardingThemes{}
No Hooks.
Return
Array
.
Usage
$result = OnboardingThemes::sort_woocommerce_themes( $themes );
- $themes(array) (required)
- Array of themes from Woo.com.
OnboardingThemes::sort_woocommerce_themes() OnboardingThemes::sort woocommerce themes code 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; }