diff --git a/classes/Tools/Storage/Driver/BunnyCDN/BunnyCDNClient.php b/classes/Tools/Storage/Driver/BunnyCDN/BunnyCDNClient.php index 288dbb15..1a02e704 100644 --- a/classes/Tools/Storage/Driver/BunnyCDN/BunnyCDNClient.php +++ b/classes/Tools/Storage/Driver/BunnyCDN/BunnyCDNClient.php @@ -24,7 +24,7 @@ public function __construct($apiKey, $storageZone, $region, $pullZone) { $this->apiKey = $apiKey; $this->storageZone = $storageZone; - $this->region = $region; + $this->region = empty($region) ? '' : "{$region}."; $this->pullZone = $pullZone; $this->client = new Client(); @@ -33,7 +33,7 @@ public function __construct($apiKey, $storageZone, $region, $pullZone) { public function upload($sourceFile, $destPath) { $res = fopen($sourceFile, 'r'); - $res = $this->client->put("https://{$this->region}.storage.bunnycdn.com/{$this->storageZone}/{$destPath}", [ + $res = $this->client->put("https://{$this->region}storage.bunnycdn.com/{$this->storageZone}/{$destPath}", [ RequestOptions::HEADERS => [ 'Content-Type' => 'application/octet-stream', 'AccessKey' => $this->apiKey @@ -50,7 +50,7 @@ public function mkdir($path) { return false; } - $ftpId = ftp_connect("{$this->region}.storage.bunnycdn.com"); + $ftpId = ftp_connect("{$this->region}storage.bunnycdn.com"); $login = ftp_login($ftpId, $this->storageZone, $this->apiKey); if (!$login) { throw new StorageException("Invalid settings"); @@ -64,7 +64,7 @@ public function mkdir($path) { } public function listFiles($path) { - $res = $this->client->get("https://{$this->region}.storage.bunnycdn.com/{$this->storageZone}/{$path}/", [ + $res = $this->client->get("https://{$this->region}storage.bunnycdn.com/{$this->storageZone}/{$path}/", [ RequestOptions::HEADERS => [ 'AccessKey' => $this->apiKey ], @@ -95,7 +95,7 @@ public function listFiles($path) { public function deleteFile($file) { - $res = $this->client->delete("https://{$this->region}.storage.bunnycdn.com/{$this->storageZone}/{$file}", [ + $res = $this->client->delete("https://{$this->region}storage.bunnycdn.com/{$this->storageZone}/{$file}", [ RequestOptions::HEADERS => [ 'AccessKey' => $this->apiKey ], @@ -110,7 +110,7 @@ public function exists($file) { return false; } - $ftpId = ftp_connect("{$this->region}.storage.bunnycdn.com"); + $ftpId = ftp_connect("{$this->region}storage.bunnycdn.com"); $login = ftp_login($ftpId, $this->storageZone, $this->apiKey); if (!$login) { throw new StorageException("Invalid settings"); diff --git a/classes/Tools/Storage/Driver/BunnyCDN/BunnyCDNStorage.php b/classes/Tools/Storage/Driver/BunnyCDN/BunnyCDNStorage.php index 47cd4167..a303cb21 100644 --- a/classes/Tools/Storage/Driver/BunnyCDN/BunnyCDNStorage.php +++ b/classes/Tools/Storage/Driver/BunnyCDN/BunnyCDNStorage.php @@ -2,9 +2,7 @@ namespace MediaCloud\Plugin\Tools\Storage\Driver\BunnyCDN; -use MediaCloud\Plugin\Tools\Storage\FileInfo; use MediaCloud\Plugin\Tools\Storage\InvalidStorageSettingsException; -use MediaCloud\Plugin\Tools\Storage\StorageException; use MediaCloud\Plugin\Tools\Storage\StorageInterface; use MediaCloud\Plugin\Tools\Storage\StorageToolSettings; use MediaCloud\Plugin\Utilities\Environment; @@ -14,7 +12,7 @@ use MediaCloud\Plugin\Wizard\ConfiguresWizard; use MediaCloud\Plugin\Wizard\StorageWizardTrait; use MediaCloud\Plugin\Wizard\WizardBuilder; -use MediaCloud\Vendor\FasterImage\FasterImage; +use function MediaCloud\Plugin\Utilities\anyEmpty; use function MediaCloud\Plugin\Utilities\anyNull; use function MediaCloud\Plugin\Utilities\arrayPath; @@ -121,7 +119,7 @@ public function signedURLExpirationForType($type = null) { * @inheritDoc */ public function enabled() { - if(!($this->settings->apiKey && $this->settings->region && $this->settings->pullZone && $this->settings->storageZone)) { + if(anyEmpty($this->settings->apiKey && $this->settings->pullZone && $this->settings->storageZone)) { if (current_user_can('manage_options')) { $adminUrl = admin_url('admin.php?page=media-cloud-settings&tab=storage'); NoticeManager::instance()->displayAdminNotice('error', "To start using Cloud Storage, you will need to supply your Bunny CDN credentials..", true, 'ilab-cloud-storage-setup-warning', 'forever'); @@ -417,136 +415,11 @@ public static function configureWizard($builder = null) { ->textField('mcloud-storage-bunnycdn-storage-zone', 'Storage Zone', '', null) ->textField('mcloud-storage-bunnycdn-pull-zone', 'Pull Zone URL', '', null) ->selectField('mcloud-storage-bunnycdn-region', 'Region', '', null, [ - 'jo' => 'AF: Amman, JO', - 'eg2' => 'AF: Cairo 2, EG', - 'eg' => 'AF: Cairo, EG', - 'ct' => 'AF: Cape Town, SA', - 'jh' => 'AF: Johannesburg, ZA', - 'ng' => 'AF: Lagos, NG', - 'ao' => 'AF: Luanda, AO', - 'ke' => 'AF: Nairobi, KE', - 'tn' => 'AF: Tunis, TN', - 'pk' => 'ASIA: Karachi, PK', - 'tw' => 'ASIA: Taipei, TW', - 'kz' => 'Asia: Almaty, KZ', - 'az' => 'Asia: Baku, AZ', - 'in' => 'Asia: Bangalore, IN', - 'th' => 'Asia: Bangkok, TH', - 'kg' => 'Asia: Bishkek, KG', - 'cen' => 'Asia: Chennai, IN', - 'bd' => 'Asia: Dhaka, BD', - 'vn' => 'Asia: Ho Chi Minh, VN', - 'hk' => 'Asia: Hong Kong, HK', - 'tr' => 'Asia: Istanbul, TR', - 'id' => 'Asia: Jakarta, ID', - 'np' => 'Asia: Kathmandu, NP', - 'ccu' => 'Asia: Kolkata, IN', - 'my' => 'Asia: Kuala Lumpur, MY', - 'ph' => 'Asia: Manila, PH', - 'mu' => 'Asia: Mumbai, IN', - 'nd' => 'Asia: New Delhi, IN', - 'cy' => 'Asia: Nicosia, CY', - 'pp' => 'Asia: Phnom Penh, KH', - 'kr' => 'Asia: Seoul, KR', - 'sg2' => 'Asia: Singapore 2, SG', - 'sg' => 'Asia: Singapore, SG', - 'geo' => 'Asia: Tbilisi, GE', - 'isr' => 'Asia: Tel Aviv, IL', - 'jp' => 'Asia: Tokyo, JP', - 'mg' => 'Asia: Ulaanbaatar, MN', - 'rgn' => 'Asia: Yangon, MM', - 'am' => 'Asia: Yerevan, AM', - 'ams' => 'EU: Amsterdam, NL', - 'gr' => 'EU: Athens, GR', - 'rs' => 'EU: Belgrade, RS', - 'sk' => 'EU: Bratislava, SK', - 'bu' => 'EU: Bucharest, RO', - 'hu' => 'EU: Budapest, HU', - 'md' => 'EU: Chisinau, MD', - 'dk' => 'EU: Copenhagen, DK', - 'ie' => 'EU: Dublin, IE', - 'dd' => 'EU: Dusseldorf, DE', - 'de2' => 'EU: Frankfurt 2, DE2', - 'de' => 'EU: Frankfurt, DE', - 'fi' => 'EU: Helsinki, FI', - 'is' => 'EU: Keflavik, IS', - 'kh' => 'EU: Khabarovsk, RU', - 'ky' => 'EU: Krasnoyarsk, RU', - 'ua' => 'EU: Kyiv, UA', - 'pt' => 'EU: Lisbon, PT', - 'lj' => 'EU: Ljubljana, SI', - 'uk' => 'EU: London, UK', - 'lu' => 'EU: Luxembourg, LU', - 'es' => 'EU: Madrid, ES', - 'ms' => 'EU: Marseille, FR', - 'it' => 'EU: Milan, IT', - 'ru' => 'EU: Moscow, RU', - 'ba' => 'EU: Novi Travnik, BA', - 'no' => 'EU: Oslo, NO', - 'fr' => 'EU: Paris, FR', - 'cz' => 'EU: Prague, CZ', - 'lv' => 'EU: Riga, LV', - 'bg' => 'EU: Sofia, BG', - 'se' => 'EU: Stockholm, SE', - 'at' => 'EU: Vienna, AT', - 'at2' => 'EU: Vienna, AT2', - 'lt' => 'EU: Vilnius, LT', - 'pl' => 'EU: Warsaw, PL', - 'hr' => 'EU: Zagreb, HR', - 'ch' => 'EU: Zurich, CH', - 'bs' => 'LATAM: Brasilia, BR', - 'fo' => 'LATAM: Fortaleza, BR', - 'gt' => 'LATAM: Guatemala, GT', - 'mx' => 'LATAM: Mexico City, MX', - 'pa' => 'LATAM: Porto Alegre, BR', - 'pr' => 'LATAM: San Juan, PR', - 'cr' => 'LATAM: San Pedro, CR', - 'bol' => 'LATAM: Sucre, BO', - 'iq2' => 'ME: Baghdad 2, IQ', - 'iq' => 'ME: Baghdad, IQ', - 'bhr' => 'ME: Bahrain, BH', - 'ae' => 'ME: Dubai, AE', - 'fu' => 'ME: Fujairah, UAE', - 'ri' => 'ME: Riyadh, SA', - 'hi' => 'NA: Honolulu, HI', - 'asb' => 'NA: Ashburn, VA', - 'ga' => 'NA: Atlanta, GA', - 'bo' => 'NA: Boston, MA', - 'clt' => 'NA: Charlotte, NC', - 'il' => 'NA: Chicago, IL', - 'tx' => 'NA: Dallas, TX', - 'den' => 'NA: Denver, CO', - 'hou' => 'NA: Houston, TX', - 'kc' => 'NA: Kansas City, MO', - 'la' => 'NA: Los Angeles, CA', - 'mi' => 'NA: Miami, FL', - 'msp' => 'NA: Minneapolis, MN', - 'mn' => 'NA: Montreal, CA', - 'ny' => 'NA: New York City, NY', - 'og' => 'NA: Ogden, UT', - 'phx' => 'NA: Phoenix, AZ', - 'pb' => 'NA: Pittsburgh, PA', - 'sil' => 'NA: San Jose, CA', - 'wa' => 'NA: Seattle, WA', - 'ca' => 'NA: Toronto, CA', - 'va' => 'NA: Vancouver, CA', - 'adl' => 'OC: Adelaide, AU', - 'auc' => 'OC: Auckland, NZ', - 'brb' => 'OC: Brisbane, AU', - 'gu' => 'OC: Hagatna: GU', - 'mel' => 'OC: Melbourne, AU', - 'per' => 'OC: Perth, AU', - 'syd' => 'OC: Sydney, SYD', - 'co' => 'SA: Bogota, SA', - 'ar' => 'SA: Buenos Aires, AR', - 'cwb' => 'SA: Curitiba, BR', - 'lap' => 'SA: La Paz, BO', - 'pe' => 'SA: Lima, PE', - 'ec' => 'SA: Quito, EC', - 'rj' => 'SA: Rio de Janeiro, BR', - 'ssa' => 'SA: Salvador, BR', - 'cl' => 'SA: Santiago, CL', - 'br' => 'SA: Sao Paulo, BR', + '' => 'Falkenstein: storage.bunnycdn.com', + 'ny' => 'New York: ny.storage.bunnycdn.com', + 'la' => 'Los Angeles: la.storage.bunnycdn.com', + 'sg' => 'Singapore: sg.storage.bunnycdn.com', + 'syd' => 'Sydney: syd.storage.bunnycdn.com', ]) ->endStep() ->testStep('wizard.cloud-storage.providers.bunnycdn.test', 'Test Settings', 'Perform tests to insure that your cloud storage provider is configured correctly.', false); @@ -584,9 +457,9 @@ public static function processWizardSettings() { $apiKey = arrayPath($_POST, $apiKeyName, null); $storageZone = arrayPath($_POST, $storageZoneName, null); $pullZone = arrayPath($_POST, $pullZoneName, null); - $region = arrayPath($_POST, $regionName, null); + $region = arrayPath($_POST, $regionName, ''); - if (anyNull($provider, $apiKey, $storageZone, $pullZone, $region)) { + if (anyNull($provider, $apiKey, $storageZone, $pullZone)) { wp_send_json(['status' => 'error', 'message' => 'Missing required fields'], 200); } diff --git a/config/storage/bunnycdn.config.php b/config/storage/bunnycdn.config.php index 81472e71..ed1394f1 100644 --- a/config/storage/bunnycdn.config.php +++ b/config/storage/bunnycdn.config.php @@ -41,136 +41,11 @@ "display-order" => 11, "type" => "select", "options" => [ - 'jo' => 'AF: Amman, JO', - 'eg2' => 'AF: Cairo 2, EG', - 'eg' => 'AF: Cairo, EG', - 'ct' => 'AF: Cape Town, SA', - 'jh' => 'AF: Johannesburg, ZA', - 'ng' => 'AF: Lagos, NG', - 'ao' => 'AF: Luanda, AO', - 'ke' => 'AF: Nairobi, KE', - 'tn' => 'AF: Tunis, TN', - 'pk' => 'ASIA: Karachi, PK', - 'tw' => 'ASIA: Taipei, TW', - 'kz' => 'Asia: Almaty, KZ', - 'az' => 'Asia: Baku, AZ', - 'in' => 'Asia: Bangalore, IN', - 'th' => 'Asia: Bangkok, TH', - 'kg' => 'Asia: Bishkek, KG', - 'cen' => 'Asia: Chennai, IN', - 'bd' => 'Asia: Dhaka, BD', - 'vn' => 'Asia: Ho Chi Minh, VN', - 'hk' => 'Asia: Hong Kong, HK', - 'tr' => 'Asia: Istanbul, TR', - 'id' => 'Asia: Jakarta, ID', - 'np' => 'Asia: Kathmandu, NP', - 'ccu' => 'Asia: Kolkata, IN', - 'my' => 'Asia: Kuala Lumpur, MY', - 'ph' => 'Asia: Manila, PH', - 'mu' => 'Asia: Mumbai, IN', - 'nd' => 'Asia: New Delhi, IN', - 'cy' => 'Asia: Nicosia, CY', - 'pp' => 'Asia: Phnom Penh, KH', - 'kr' => 'Asia: Seoul, KR', - 'sg2' => 'Asia: Singapore 2, SG', - 'sg' => 'Asia: Singapore, SG', - 'geo' => 'Asia: Tbilisi, GE', - 'isr' => 'Asia: Tel Aviv, IL', - 'jp' => 'Asia: Tokyo, JP', - 'mg' => 'Asia: Ulaanbaatar, MN', - 'rgn' => 'Asia: Yangon, MM', - 'am' => 'Asia: Yerevan, AM', - 'ams' => 'EU: Amsterdam, NL', - 'gr' => 'EU: Athens, GR', - 'rs' => 'EU: Belgrade, RS', - 'sk' => 'EU: Bratislava, SK', - 'bu' => 'EU: Bucharest, RO', - 'hu' => 'EU: Budapest, HU', - 'md' => 'EU: Chisinau, MD', - 'dk' => 'EU: Copenhagen, DK', - 'ie' => 'EU: Dublin, IE', - 'dd' => 'EU: Dusseldorf, DE', - 'de2' => 'EU: Frankfurt 2, DE2', - 'de' => 'EU: Frankfurt, DE', - 'fi' => 'EU: Helsinki, FI', - 'is' => 'EU: Keflavik, IS', - 'kh' => 'EU: Khabarovsk, RU', - 'ky' => 'EU: Krasnoyarsk, RU', - 'ua' => 'EU: Kyiv, UA', - 'pt' => 'EU: Lisbon, PT', - 'lj' => 'EU: Ljubljana, SI', - 'uk' => 'EU: London, UK', - 'lu' => 'EU: Luxembourg, LU', - 'es' => 'EU: Madrid, ES', - 'ms' => 'EU: Marseille, FR', - 'it' => 'EU: Milan, IT', - 'ru' => 'EU: Moscow, RU', - 'ba' => 'EU: Novi Travnik, BA', - 'no' => 'EU: Oslo, NO', - 'fr' => 'EU: Paris, FR', - 'cz' => 'EU: Prague, CZ', - 'lv' => 'EU: Riga, LV', - 'bg' => 'EU: Sofia, BG', - 'se' => 'EU: Stockholm, SE', - 'at' => 'EU: Vienna, AT', - 'at2' => 'EU: Vienna, AT2', - 'lt' => 'EU: Vilnius, LT', - 'pl' => 'EU: Warsaw, PL', - 'hr' => 'EU: Zagreb, HR', - 'ch' => 'EU: Zurich, CH', - 'bs' => 'LATAM: Brasilia, BR', - 'fo' => 'LATAM: Fortaleza, BR', - 'gt' => 'LATAM: Guatemala, GT', - 'mx' => 'LATAM: Mexico City, MX', - 'pa' => 'LATAM: Porto Alegre, BR', - 'pr' => 'LATAM: San Juan, PR', - 'cr' => 'LATAM: San Pedro, CR', - 'bol' => 'LATAM: Sucre, BO', - 'iq2' => 'ME: Baghdad 2, IQ', - 'iq' => 'ME: Baghdad, IQ', - 'bhr' => 'ME: Bahrain, BH', - 'ae' => 'ME: Dubai, AE', - 'fu' => 'ME: Fujairah, UAE', - 'ri' => 'ME: Riyadh, SA', - 'hi' => 'NA: Honolulu, HI', - 'asb' => 'NA: Ashburn, VA', - 'ga' => 'NA: Atlanta, GA', - 'bo' => 'NA: Boston, MA', - 'clt' => 'NA: Charlotte, NC', - 'il' => 'NA: Chicago, IL', - 'tx' => 'NA: Dallas, TX', - 'den' => 'NA: Denver, CO', - 'hou' => 'NA: Houston, TX', - 'kc' => 'NA: Kansas City, MO', - 'la' => 'NA: Los Angeles, CA', - 'mi' => 'NA: Miami, FL', - 'msp' => 'NA: Minneapolis, MN', - 'mn' => 'NA: Montreal, CA', - 'ny' => 'NA: New York City, NY', - 'og' => 'NA: Ogden, UT', - 'phx' => 'NA: Phoenix, AZ', - 'pb' => 'NA: Pittsburgh, PA', - 'sil' => 'NA: San Jose, CA', - 'wa' => 'NA: Seattle, WA', - 'ca' => 'NA: Toronto, CA', - 'va' => 'NA: Vancouver, CA', - 'adl' => 'OC: Adelaide, AU', - 'auc' => 'OC: Auckland, NZ', - 'brb' => 'OC: Brisbane, AU', - 'gu' => 'OC: Hagatna: GU', - 'mel' => 'OC: Melbourne, AU', - 'per' => 'OC: Perth, AU', - 'syd' => 'OC: Sydney, SYD', - 'co' => 'SA: Bogota, SA', - 'ar' => 'SA: Buenos Aires, AR', - 'cwb' => 'SA: Curitiba, BR', - 'lap' => 'SA: La Paz, BO', - 'pe' => 'SA: Lima, PE', - 'ec' => 'SA: Quito, EC', - 'rj' => 'SA: Rio de Janeiro, BR', - 'ssa' => 'SA: Salvador, BR', - 'cl' => 'SA: Santiago, CL', - 'br' => 'SA: Sao Paulo, BR', + '' => 'Falkenstein: storage.bunnycdn.com', + 'ny' => 'New York: ny.storage.bunnycdn.com', + 'la' => 'Los Angeles: la.storage.bunnycdn.com', + 'sg' => 'Singapore: sg.storage.bunnycdn.com', + 'syd' => 'Sydney: syd.storage.bunnycdn.com', ] ], ] diff --git a/ilab-media-tools.php b/ilab-media-tools.php index fe0c23b8..873136b5 100644 --- a/ilab-media-tools.php +++ b/ilab-media-tools.php @@ -5,7 +5,7 @@ Plugin URI: https://github.com/interfacelab/ilab-media-tools Description: Automatically upload media to Amazon S3 and integrate with Imgix, a real-time image processing CDN. Boosts site performance and simplifies workflows. Author: interfacelab -Version: 4.6.1 +Version: 4.6.2 Requires PHP: 7.4 Author URI: http://interfacelab.io */ @@ -117,7 +117,7 @@ define( 'WP_FS__ENABLE_GARBAGE_COLLECTOR', false ); } // Version Defines -define( 'MEDIA_CLOUD_VERSION', '4.6.1' ); +define( 'MEDIA_CLOUD_VERSION', '4.6.2' ); define( 'MEDIA_CLOUD_INFO_VERSION', '4.0.2' ); define( 'MCLOUD_IS_BETA', false ); // Debugging diff --git a/readme.txt b/readme.txt index 94462458..7447e90f 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Requires at least: 4.9 Tested up to: 6.5 License: GPLv3 or later License URI: http://www.gnu.org/licenses/gpl-3.0.html -Stable tag: 4.6.1 +Stable tag: 4.6.2 Requires PHP: 7.4 Automatically store media on Amazon S3, Cloudflare R2, Google Cloud Storage, DigitalOcean Spaces + others. Serve CSS/JS assets through CDNs. Integrate with Imgix. @@ -105,6 +105,10 @@ Imgix is a content delivery network with a twist. In addition to distributing y == Changelog == += 4.6.2 - 03/22/2024 = + +* Fix for Bunny CDN region list + = 4.6.1 - 03/22/2024 = * Added beta support for Bunny CDN as a storage provider.