| @@ -1,10 +1,13 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace FluentCart\App\Hooks\Handlers; |
| 4 | 4 | |
| 5 | +use FluentCart\App\App; | |
| 6 | +use FluentCart\App\Helpers\Helper; | |
| 5 | 7 | use FluentCart\App\Modules\StorageDrivers\Local\Local; |
| 6 | 8 | use FluentCart\App\Modules\StorageDrivers\S3\S3; |
| 9 | +use FluentCart\App\Vite; | |
| 7 | 10 | use FluentCart\Api\StorageDrivers; |
| 8 | 11 | |
| 9 | 12 | class GlobalStorageHandler |
| 10 | 13 | { |
| @@ -17,8 +20,13 @@ | ||
| 17 | 20 | { |
| 18 | 21 | add_action('init', function () { |
| 19 | 22 | (new Local())->init(); |
| 20 | 23 | (new S3())->init(); |
| 24 | + | |
| 25 | + if (!App::isProActive()) { | |
| 26 | + add_filter('fluent_cart/storage/get_global_storage_drivers', [$this, 'registerPromoR2Driver'], 20, 2); | |
| 27 | + } | |
| 28 | + | |
| 21 | 29 | //This hook will allow others to register their storage driver with ours |
| 22 | 30 | do_action('fluent_cart/register_storage_drivers'); |
| 23 | 31 | },9); |
| 24 | 32 | |
| @@ -47,6 +55,44 @@ | ||
| 47 | 55 | { |
| 48 | 56 | $storageDrivers = new StorageDrivers(); |
| 49 | 57 | return $storageDrivers->getActive(); |
| 50 | 58 | } |
| 51 | - | |
| 59 | + | |
| 60 | + public function registerPromoR2Driver($drivers, $args) | |
| 61 | + { | |
| 62 | + if (isset($drivers['r2'])) { | |
| 63 | + return $drivers; | |
| 64 | + } | |
| 65 | + | |
| 66 | + $drivers['r2'] = [ | |
| 67 | + 'title' => __('Cloudflare R2', 'fluent-cart'), | |
| 68 | + 'route' => '', | |
| 69 | + 'description' => __('Store downloadable product files in Cloudflare R2. Available in FluentCart Pro.', 'fluent-cart'), | |
| 70 | + 'logo' => $this->getPromoR2Logo(), | |
| 71 | + 'dark_logo' => $this->getPromoR2DarkLogo(), | |
| 72 | + 'status' => false, | |
| 73 | + 'brand_color' => '#f38020', | |
| 74 | + 'has_bucket' => true, | |
| 75 | + 'requires_pro' => true, | |
| 76 | + 'upgrade_url' => Helper::getUpgradeUrl('feature_lock_storage_r2'), | |
| 77 | + 'instance' => new class { | |
| 78 | + public function isEnabled() | |
| 79 | + { | |
| 80 | + return false; | |
| 81 | + } | |
| 82 | + } | |
| 83 | + ]; | |
| 84 | + | |
| 85 | + return $drivers; | |
| 86 | + } | |
| 87 | + | |
| 88 | + public function getPromoR2Logo() | |
| 89 | + { | |
| 90 | + return Vite::getAssetUrl('images/storage-drivers/r2.svg'); | |
| 91 | + } | |
| 92 | + | |
| 93 | + public function getPromoR2DarkLogo() | |
| 94 | + { | |
| 95 | + return Vite::getAssetUrl('images/storage-drivers/r2.svg'); | |
| 96 | + } | |
| 97 | + | |
| 52 | 98 | } |