WC_Admin_Addons::get_featured()public staticWC 1.0

Устарела с версии 5.9.0. Больше не поддерживается и может быть удалена. Используйте d in In-App Marketplace.

Get featured for the addons screen

{} Это метод класса: WC_Admin_Addons{}

Хуков нет.

Возвращает

Массив. of objects

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

$result = WC_Admin_Addons::get_featured();

Список изменений

Устарела с 5.9.0 No longer used in In-App Marketplace

Код WC_Admin_Addons::get_featured() WC 6.9.4

public static function get_featured() {
	$locale   = get_user_locale();
	$featured = self::get_locale_data_from_transient( 'wc_addons_featured_2', $locale );
	if ( false === $featured ) {
		$headers = array();
		$auth    = WC_Helper_Options::get( 'auth' );

		if ( ! empty( $auth['access_token'] ) ) {
			$headers['Authorization'] = 'Bearer ' . $auth['access_token'];
		}

		$raw_featured = wp_safe_remote_get(
			'https://woocommerce.com/wp-json/wccom-extensions/1.0/featured',
			array(
				'headers' => $headers,
			)
		);

		if ( ! is_wp_error( $raw_featured ) ) {
			$featured = json_decode( wp_remote_retrieve_body( $raw_featured ) );
			if ( $featured ) {
				self::set_locale_data_in_transient( 'wc_addons_featured_2', $featured, $locale, DAY_IN_SECONDS );
			}
		}
	}

	if ( is_object( $featured ) ) {
		self::output_featured_sections( $featured->sections );
		return $featured;
	}
}