Automattic\WooCommerce\Internal\Admin\Onboarding
OnboardingThemes::get_themes()
Get a list of themes for the onboarding wizard.
Метод класса: OnboardingThemes{}
Хуки из метода
Возвращает
Массив
.
Использование
$result = OnboardingThemes::get_themes();
Код OnboardingThemes::get_themes() OnboardingThemes::get themes WC 8.7.0
public static function get_themes() { $themes = get_transient( self::THEMES_TRANSIENT ); if ( false === $themes ) { $theme_data = wp_remote_get( 'https://woocommerce.com/wp-json/wccom-extensions/1.0/search?category=themes', array( 'user-agent' => 'WooCommerce/' . WC()->version . '; ' . get_bloginfo( 'url' ), ) ); $themes = array(); if ( ! is_wp_error( $theme_data ) ) { $theme_data = json_decode( $theme_data['body'] ); $woo_themes = property_exists( $theme_data, 'products' ) ? $theme_data->products : array(); $sorted_themes = self::sort_woocommerce_themes( $woo_themes ); foreach ( $sorted_themes as $theme ) { $slug = sanitize_title_with_dashes( $theme->slug ); $themes[ $slug ] = (array) $theme; $themes[ $slug ]['is_installed'] = false; $themes[ $slug ]['has_woocommerce_support'] = true; $themes[ $slug ]['slug'] = $slug; } } $installed_themes = wp_get_themes(); foreach ( $installed_themes as $slug => $theme ) { $theme_data = self::get_theme_data( $theme ); if ( isset( $themes[ $slug ] ) ) { $themes[ $slug ]['is_installed'] = true; $themes[ $slug ]['image'] = $theme_data['image']; } else { $themes[ $slug ] = $theme_data; } } $active_theme = get_option( 'stylesheet' ); /** * The active theme may no be set if active_theme is not compatible with current version of WordPress. * In this case, we should not add active theme to onboarding themes. */ if ( isset( $themes[ $active_theme ] ) ) { // Add the WooCommerce support tag for default themes that don't explicitly declare support. if ( function_exists( 'wc_is_wp_default_theme_active' ) && wc_is_wp_default_theme_active() ) { $themes[ $active_theme ]['has_woocommerce_support'] = true; } $themes = array( $active_theme => $themes[ $active_theme ] ) + $themes; } set_transient( self::THEMES_TRANSIENT, $themes, DAY_IN_SECONDS ); } $themes = apply_filters( 'woocommerce_admin_onboarding_themes', $themes ); return array_values( $themes ); }