feat: add S3-compatible storage provider (MinIO, Ceph, R2, etc.)
Adds a new 'S3-Compatible Storage' provider that works with any
S3-API-compatible object storage service, including MinIO, Ceph,
Cloudflare R2, Backblaze B2, and others.
Changes:
- New provider class: classes/providers/storage/s3-compatible-provider.php
- Provider key: s3compatible
- Reads user-configured endpoint URL from settings
- Uses path-style URL access (required by most S3-compatible services)
- Supports credentials via AS3CF_S3COMPAT_ACCESS_KEY_ID /
AS3CF_S3COMPAT_SECRET_ACCESS_KEY wp-config.php constants
- Disables AWS-specific features (Block Public Access, Object Ownership)
- New provider SVG icons (s3compatible.svg, -link.svg, -round.svg)
- Registered provider in main plugin class with endpoint setting support
- Updated StorageProviderSubPage to show endpoint URL input for S3-compatible
- Built pro settings bundle with rollup (Svelte 4.2.19)
- Added package.json and updated rollup.config.mjs for pro-only builds
This commit is contained in:
102
classes/providers/delivery/digitalocean-spaces-cdn.php
Normal file
102
classes/providers/delivery/digitalocean-spaces-cdn.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace DeliciousBrains\WP_Offload_Media\Providers\Delivery;
|
||||
|
||||
class DigitalOcean_Spaces_CDN extends Delivery_Provider {
|
||||
|
||||
/**
|
||||
* Which storage providers does the delivery provider support, empty means all.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $supported_storage_providers = array(
|
||||
'do',
|
||||
);
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected static $provider_name = 'DigitalOcean';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected static $provider_short_name = 'DigitalOcean';
|
||||
|
||||
/**
|
||||
* Used in filters and settings.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $provider_key_name = 'do';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected static $service_name = 'Spaces CDN';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected static $service_short_name = 'Spaces CDN';
|
||||
|
||||
/**
|
||||
* Used in filters and settings.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $service_key_name = 'spaces-cdn';
|
||||
|
||||
/**
|
||||
* Optional override of "Provider Name" + "Service Name" for friendly name for service.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $provider_service_name = 'DigitalOcean Spaces CDN';
|
||||
|
||||
/**
|
||||
* The slug for the service's quick start guide doc.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $provider_service_quick_start_slug = 'digitalocean-spaces-cdn-setup';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $default_domain = 'cdn.digitaloceanspaces.com';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $console_url = 'https://cloud.digitalocean.com/spaces/';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $console_url_prefix_param = '?path=';
|
||||
|
||||
/**
|
||||
* Get the link to the provider's console.
|
||||
*
|
||||
* @param string $bucket
|
||||
* @param string $prefix
|
||||
* @param string $region
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* NOTE: DigitalOcean Spaces CDN is tied to the Space and does not have a separate means of access.
|
||||
*/
|
||||
public function get_console_url( string $bucket = '', string $prefix = '', string $region = '' ): string {
|
||||
return $this->as3cf->get_storage_provider()->get_console_url( $bucket, $prefix, $region );
|
||||
}
|
||||
|
||||
/**
|
||||
* Title to be shown for provider's console link.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_console_title(): string {
|
||||
return _x( 'Control Panel', 'Provider console link text', 'amazon-s3-and-cloudfront' );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user