'WooCommerce Marketplace Suggestions' ) ); // Parse the data to check for any errors. // If it's valid, store structure in transient. if ( ! is_wp_error( $raw_suggestions ) ) { $suggestions = json_decode( wp_remote_retrieve_body( $raw_suggestions ) ); if ( $suggestions && is_array( $suggestions ) ) { set_transient( 'wc_marketplace_suggestions', $suggestions, WEEK_IN_SECONDS ); return $suggestions; } } // Cache empty suggestions data to reduce requests if there are any issues with API. set_transient( 'wc_marketplace_suggestions', array(), DAY_IN_SECONDS ); return array(); } } WC_Marketplace_Suggestions::init();