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:
155
classes/pro/as3cf-pro-installer.php
Normal file
155
classes/pro/as3cf-pro-installer.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
class AS3CF_Pro_Installer extends AS3CF_Compatibility_Check {
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $required_plugins;
|
||||
|
||||
/**
|
||||
* @var AS3CF_Pro_Plugin_Installer
|
||||
*/
|
||||
protected $plugin_installer;
|
||||
|
||||
/**
|
||||
* AS3CF_Pro_Installer constructor.
|
||||
*
|
||||
* @param string $plugin_file_path
|
||||
*/
|
||||
public function __construct( $plugin_file_path ) {
|
||||
parent::__construct(
|
||||
'WP Offload Media',
|
||||
'amazon-s3-and-cloudfront-pro',
|
||||
$plugin_file_path
|
||||
);
|
||||
|
||||
// Fire up the plugin installer
|
||||
if ( is_admin() ) {
|
||||
$this->plugin_installer = new AS3CF_Pro_Plugin_Installer( 'installer', $this->plugin_slug, $this->plugin_file_path );
|
||||
$this->plugin_installer->set_plugins_to_install( $this->required_plugins_not_installed() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Are all the required plugins installed?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_setup() {
|
||||
$plugins_not_installed = $this->required_plugins_not_installed();
|
||||
|
||||
return empty( $plugins_not_installed );
|
||||
}
|
||||
|
||||
/**
|
||||
* Are all the required plugins activated?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function are_required_plugins_activated() {
|
||||
$plugins_not_activated = $this->required_plugins_not_activated();
|
||||
|
||||
return empty( $plugins_not_activated );
|
||||
}
|
||||
|
||||
/**
|
||||
* If the plugin is setup use the default compatible check
|
||||
*
|
||||
* @param bool $installed Check to see if the plugins are installed
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function is_compatible( $installed = true ) {
|
||||
if ( $this->is_setup() || false === $installed ) {
|
||||
return parent::is_compatible();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The required plugins for this plugin
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_required_plugins() {
|
||||
if ( is_null( $this->required_plugins ) ) {
|
||||
$this->required_plugins = array();
|
||||
}
|
||||
|
||||
return $this->required_plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if any of the required plugins are installed
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function required_plugins_not_installed() {
|
||||
$plugins = array();
|
||||
$required_plugins = $this->get_required_plugins();
|
||||
|
||||
foreach ( $required_plugins as $slug => $plugin ) {
|
||||
$filename = ( isset( $plugin['file'] ) ) ? $plugin['file'] : $slug;
|
||||
if ( ! class_exists( $plugin['class'] ) && ! file_exists( WP_PLUGIN_DIR . '/' . $slug . '/' . $filename . '.php' ) ) {
|
||||
$plugins[ $slug ] = $plugin['name'];
|
||||
}
|
||||
}
|
||||
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if any of the required plugins are activated
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function required_plugins_not_activated() {
|
||||
$plugins = array();
|
||||
$required_plugins = $this->get_required_plugins();
|
||||
|
||||
foreach ( $required_plugins as $slug => $plugin ) {
|
||||
if ( ! class_exists( $plugin['class'] ) ) {
|
||||
$plugins[ $slug ] = $plugin['name'];
|
||||
}
|
||||
}
|
||||
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the plugin info URL for thickbox
|
||||
*
|
||||
* @param string $slug
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_plugin_info_url( $slug ) {
|
||||
return self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $slug . '&TB_iframe=true&width=600&height=800' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a custom install notice if the plugin is not setup
|
||||
*/
|
||||
function get_admin_notice() {
|
||||
$plugins_not_installed = $this->required_plugins_not_installed();
|
||||
if ( empty( $plugins_not_installed ) ) {
|
||||
parent::get_admin_notice();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->plugin_installer->load_installer_assets();
|
||||
|
||||
if ( $notices = get_site_transient( 'as3cfpro_installer_notices' ) ) {
|
||||
if ( isset( $notices['filesystem_error'] ) ) {
|
||||
// Don't show the installer notice if we have filesystem credential issues
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$install_notice = untrailingslashit( plugin_dir_path( $this->plugin_file_path ) ) . '/view/pro/install-notice.php';
|
||||
include $install_notice;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user