WordPress at Your Fingertips
function is not described

WC_Admin_Addons::get_featured() public WC 1.0

Deprecated from version 5.9.0. It is no longer supported and can be removed in future releases. Use d in In-App Marketplace instead.

Get featured for the addons screen

{} It's a method of the class: WC_Admin_Addons{}

No Hooks.

Return

Array. of objects

Usage

$result = WC_Admin_Addons::get_featured();

Changelog

Deprecated Since 5.9.0 No longer used in In-App Marketplace

Code of WC_Admin_Addons::get_featured() WC 5.9.0

public static function get_featured() {
	$featured = get_transient( 'wc_addons_featured' );
	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,
				'user-agent' => 'WooCommerce Addons Page',
			)
		);

		if ( ! is_wp_error( $raw_featured ) ) {
			$featured = json_decode( wp_remote_retrieve_body( $raw_featured ) );
			if ( $featured ) {
				set_transient( 'wc_addons_featured', $featured, DAY_IN_SECONDS );
			}
		}
	}

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