PluginProbe
WP-Stateless – Google Cloud Storage / 2.1.4
WP-Stateless – Google Cloud Storage v2.1.4
4.4.3 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.3.0 2.3.1 2.3.2 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 All 62 releases
wp-stateless / lib / classes / compatibility / edd-download-method.php

edd-download-method.php in WP-Stateless – Google Cloud Storage 2.1.4, at lib/classes/compatibility/edd-download-method.php

54 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Easy Digital Downloads
4 * Plugin URI: https://wordpress.org/plugins/easy-digital-downloads/
5 *
6 * Compatibility Description:
7 *
8 */
9
10 namespace wpCloud\StatelessMedia {
11
12 if(!class_exists('wpCloud\StatelessMedia\EDDDownloadMethod')) {
13
14 class EDDDownloadMethod extends ICompatibility {
15 protected $id = 'edd-download-method';
16 protected $title = 'Easy Digital Downloads';
17 protected $constant = 'WP_STATELESS_COMPATIBILITY_EDD';
18 protected $description = 'Ensures compatibility with the forced download method and WP-Stateless.';
19
20 public function __construct(){
21 $this->init();
22 }
23
24 public function module_init($sm){
25 add_action('edd_process_download_headers', array( $this, 'edd_download_method_support' ), 10, 4);
26 }
27
28 /**
29 * If EDD download method is Forced (direct) and file goes from GCS then make it to be downloaded right away.
30 *
31 * @param $requested_file
32 * @param $download
33 * @param $email
34 * @param $payment
35 */
36 public function edd_download_method_support( $requested_file, $download, $email, $payment ) {
37 if (!function_exists('edd_is_local_file') || !function_exists('edd_get_file_download_method') )
38 return;
39 if (edd_get_file_download_method() != 'direct')
40 return;
41 if (!edd_is_local_file($requested_file) && strstr($requested_file, 'storage.googleapis.com')) {
42 header('Content-Type: application/octet-stream');
43 header("Content-Transfer-Encoding: Binary");
44 header("Content-disposition: attachment; filename=\"" . apply_filters('edd_requested_file_name', basename($requested_file)) . "\"");
45 readfile($requested_file);
46 exit;
47 }
48 }
49 }
50
51 }
52
53 }
54