get_locale(), 'sdk_partner' => defined('EXTENDIFY_PARTNER_ID') ? EXTENDIFY_PARTNER_ID : '', ]); $response = \wp_remote_get( sprintf('%s/api/assist/recommendations?%s', Constants::DASHBOARD_HOST, $params), [ 'headers' => [ 'Content-Type' => 'application/json', 'Accept' => 'application/json', ], ] ); if (\is_wp_error($response)) { return new \WP_REST_Response([], 500); } $body = json_decode(\wp_remote_retrieve_body($response), true); if (!isset($body['success']) || !isset($body['data'])) { return new \WP_REST_Response([], 500); } return new \WP_REST_Response($body['data'], \wp_remote_retrieve_response_code($response)); } }