diff --git a/includes/admin/class-wc-admin-addons.php b/includes/admin/class-wc-admin-addons.php index fbb8724db55..6747fbabe92 100644 --- a/includes/admin/class-wc-admin-addons.php +++ b/includes/admin/class-wc-admin-addons.php @@ -21,6 +21,45 @@ class WC_Admin_Addons { /** * Get featured for the addons screen * + * @deprecated 5.9.0 No longer used in In-App Marketplace + * + * @return array of objects + */ + 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; + } + } + + /** + * Render featured products and banners using WCCOM's the Featured 2.0 Endpoint + * * @return void */ public static function render_featured() {