/** * The handler for the "get" request. Redirects to the file download. * * @param $product WP_Post The product object */ private function get_product($product, $product_id, $email, $license_key) { // Get the AWS data from post meta fields $meta = get_post_meta($product->ID, 'wp_license_manager_product_meta', true); $bucket = isset($meta['file_bucket']) ? $meta['file_bucket'] : ''; $file_name = isset($meta['file_name']) ? $meta['file_name'] : ''; if ($bucket == '' || $file_name == '') { // No file set, return error return $this->error_response('No download defined for product.'); } // Use the AWS API to set up the download // This API method is called directly by WordPress so we need to adhere to its // requirements and skip the JSON. WordPress expects to receive a ZIP file... $s3_url = Wp_License_Manager_S3::get_s3_url($bucket, $file_name); wp_redirect($s3_url, 302); exit; }