| 1 |
<?php |
| 2 |
namespace Dudlewebs\WPMCS; |
| 3 |
|
| 4 |
defined('ABSPATH') || exit; |
| 5 |
|
| 6 |
class Schema { |
| 7 |
private static $constants; |
| 8 |
private static $service_labels; |
| 9 |
|
| 10 |
// Static initializer to handle dynamic operations |
| 11 |
static function init() { |
| 12 |
self::$constants = [ |
| 13 |
'S3_MULTIPART_MIN_FILE_SIZE' => 5242880, |
| 14 |
'GCLOUD_MULTIPART_MIN_FILE_SIZE' => 5242880, |
| 15 |
'DOCEAN_MULTIPART_MIN_FILE_SIZE' => 5242880, |
| 16 |
'CLOUDFLARE_R2_MULTIPART_MIN_FILE_SIZE' => 5242880, |
| 17 |
'S3COMPATIBLE_MULTIPART_MIN_FILE_SIZE' => 5242880, |
| 18 |
'CACHE_GROUP' => WPMCS_TOKEN.'_cache_group', |
| 19 |
'CACHE_EXPIRE' => 24*60*60, |
| 20 |
'META_KEY' => WPMCS_TOKEN.'_meta_data', |
| 21 |
'CONTENT_META_KEY' => WPMCS_TOKEN.'_post_meta_data', |
| 22 |
'GLOBAL_SETTINGS_KEY' => WPMCS_TOKEN.'_global_settings', |
| 23 |
'FILE_MANAGER_SETTINGS_KEY' => WPMCS_TOKEN.'_file_manager_settings', |
| 24 |
'BTB_DESTINATION_KEY' => WPMCS_TOKEN.'_btb_destination', |
| 25 |
'BG_RUNNER_SETTINGS_KEY' => WPMCS_TOKEN.'_bg_runner_settings', |
| 26 |
'STATUS_KEY' => WPMCS_TOKEN.'_status_data', |
| 27 |
'COUNTER_KEY' => WPMCS_TOKEN.'_counter_data', |
| 28 |
'UPLOADS' => WPMCS_TOKEN.'_uploads' |
| 29 |
]; |
| 30 |
|
| 31 |
self::$service_labels = [ |
| 32 |
's3' => esc_html__('AWS/S3', 'media-cloud-sync'), |
| 33 |
'gcloud' => esc_html__('Google Cloud Storage', 'media-cloud-sync'), |
| 34 |
'docean' => esc_html__('Digital Ocean Spaces', 'media-cloud-sync'), |
| 35 |
'cloudflareR2' => esc_html__('Cloudflare R2', 'media-cloud-sync'), |
| 36 |
's3compatible' => esc_html__('S3 Compatible', 'media-cloud-sync') |
| 37 |
]; |
| 38 |
} |
| 39 |
|
| 40 |
/** |
| 41 |
* Get schema constant by key. |
| 42 |
*/ |
| 43 |
public static function getConstant($key, $default = false) { |
| 44 |
return isset(self::$constants[$key]) ? self::$constants[$key] : $default; |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Get service label by key. |
| 49 |
*/ |
| 50 |
public static function getServiceLabels($key, $default = false) { |
| 51 |
return isset(self::$service_labels[$key]) ? self::$service_labels[$key] : $default; |
| 52 |
} |
| 53 |
} |
| 54 |
// Initialize on load time to handle missing constant redeclaration |
| 55 |
Schema::init(); |