set_basename( false, __FILE__ ); } else { if ( !function_exists( 'edgeupload_fs' ) ) { function edgeupload_fs() { global $edgeupload_fs; if ( !isset( $edgeupload_fs ) ) { require_once dirname( __FILE__ ) . '/vendor/freemius/start.php'; $edgeupload_fs = fs_dynamic_init( [ 'id' => '30421', 'slug' => 'edgeupload', 'premium_slug' => 'edgeupload-pro', 'type' => 'plugin', 'public_key' => 'pk_929147defb60cdb3dd8555f1401b2', 'is_premium' => false, 'premium_suffix' => 'Pro', 'has_addons' => false, 'has_paid_plans' => true, 'is_org_compliant' => true, 'trial' => [ 'days' => 7, 'is_require_payment' => true, ], 'menu' => [ 'slug' => 'edgeupload', 'first-path' => 'admin.php?page=edgeupload', 'support' => false, ], 'is_live' => true, ] ); $edgeupload_fs->add_filter( 'plugin_icon', function () { return dirname( __FILE__ ) . '/assets/images/icon-edgeupload.svg'; } ); } return $edgeupload_fs; } edgeupload_fs(); do_action( 'edgeupload_fs_loaded' ); } if ( version_compare( PHP_VERSION, '7.4.0', '<' ) ) { deactivate_plugins( plugin_basename( __FILE__ ) ); wp_die( 'EdgeUpload requires PHP 7.4 or higher. Please upgrade your PHP version.' ); } define( 'EDGEUPLOAD_PATH', plugin_dir_path( __FILE__ ) ); define( 'EDGEUPLOAD_URL', plugin_dir_url( __FILE__ ) ); define( 'EDGEUPLOAD_VERSION', '1.0.1' ); require_once EDGEUPLOAD_PATH . 'includes/Utils/Crypto.php'; require_once EDGEUPLOAD_PATH . 'includes/Utils/I18n.php'; require_once EDGEUPLOAD_PATH . 'includes/Utils/Options.php'; require_once EDGEUPLOAD_PATH . 'includes/Providers/ProviderInterface.php'; require_once EDGEUPLOAD_PATH . 'includes/Providers/AbstractProvider.php'; require_once EDGEUPLOAD_PATH . 'includes/Providers/Amazon/S3.php'; require_once EDGEUPLOAD_PATH . 'includes/Providers/ProviderFactory.php'; require_once EDGEUPLOAD_PATH . 'includes/License/LicenseManager.php'; require_once EDGEUPLOAD_PATH . 'includes/Integrations/IntegrationRegistry.php'; require_once EDGEUPLOAD_PATH . 'includes/Admin/Settings.php'; require_once EDGEUPLOAD_PATH . 'includes/API/Sign.php'; require_once EDGEUPLOAD_PATH . 'includes/Integrations/Elementor.php'; require_once EDGEUPLOAD_PATH . 'includes/Integrations/ContactForm7.php'; require_once EDGEUPLOAD_PATH . 'includes/Integrations/WPForms.php'; require_once EDGEUPLOAD_PATH . 'includes/Integrations/GravityForms.php'; require_once EDGEUPLOAD_PATH . 'includes/Integrations/NinjaForms.php'; require_once EDGEUPLOAD_PATH . 'includes/Integrations/FluentForms.php'; register_activation_hook( __FILE__, function () { $defaults = [ 'edgeupload_provider' => 's3', 'edgeupload_bucket' => '', 'edgeupload_region' => '', 'edgeupload_secret_id' => '', 'edgeupload_secret_key' => '', 'edgeupload_cdn_domain' => '', 'edgeupload_sign_expire' => 300, 'edgeupload_max_files' => \EdgeUpload\License\LicenseManager::FREE_DEFAULTS['edgeupload_max_files'], 'edgeupload_max_file_size' => \EdgeUpload\License\LicenseManager::FREE_DEFAULTS['edgeupload_max_file_size'], 'edgeupload_total_size' => \EdgeUpload\License\LicenseManager::FREE_DEFAULTS['edgeupload_total_size'], 'edgeupload_retry_count' => \EdgeUpload\License\LicenseManager::FREE_DEFAULTS['edgeupload_retry_count'], 'edgeupload_form_ids' => '', 'edgeupload_elementor_form_ids' => '', 'edgeupload_allowed_extensions' => \EdgeUpload\License\LicenseManager::FREE_DEFAULTS['edgeupload_allowed_extensions'], 'edgeupload_rate_limit_count' => 60, 'edgeupload_rate_limit_window' => 600, ]; foreach ( $defaults as $key => $value ) { if ( get_option( $key ) === false ) { add_option( $key, $value ); } } } ); add_action( 'plugins_loaded', function () { if ( get_option( 'edgeupload_form_ids' ) !== false ) { return; } add_option( 'edgeupload_form_ids', get_option( 'edgeupload_elementor_form_ids', '' ) ); }, 1 ); add_action( 'admin_init', ['EdgeUpload\\License\\LicenseManager', 'reconcile_state'] ); add_action( 'init', ['EdgeUpload\\License\\LicenseManager', 'reconcile_state'], 1 ); add_action( 'admin_menu', ['EdgeUpload_Settings', 'register_menu'] ); add_action( 'admin_init', ['EdgeUpload_Settings', 'register_settings'] ); add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), function ( $links ) { $settings_link = sprintf( '%s', esc_url( admin_url( 'admin.php?page=edgeupload' ) ), esc_html__( 'Settings' ) ); array_unshift( $links, $settings_link ); return $links; } ); add_filter( 'all_plugins', function ( $plugins ) { $basename = plugin_basename( __FILE__ ); if ( isset( $plugins[$basename]['Name'] ) && function_exists( 'edgeupload_fs' ) && edgeupload_fs()->is__premium_only() ) { $plugins[$basename]['Name'] = 'EdgeUpload Pro - Cloud Direct Upload for Forms'; $plugins[$basename]['Title'] = 'EdgeUpload Pro - Cloud Direct Upload for Forms'; } return $plugins; } ); add_action( 'plugins_loaded', ['EdgeUpload_Elementor_Integration', 'init'] ); add_action( 'plugins_loaded', ['EdgeUpload_ContactForm7_Integration', 'init'] ); add_action( 'plugins_loaded', ['EdgeUpload_WPForms_Integration', 'init'] ); add_action( 'plugins_loaded', ['EdgeUpload_GravityForms_Integration', 'init'] ); add_action( 'plugins_loaded', ['EdgeUpload_NinjaForms_Integration', 'init'] ); add_action( 'plugins_loaded', ['EdgeUpload_FluentForms_Integration', 'init'] ); add_action( 'admin_enqueue_scripts', function ( $hook ) { if ( $hook !== 'toplevel_page_edgeupload' ) { return; } wp_enqueue_style( 'dashicons' ); wp_enqueue_style( 'edgeupload-admin', EDGEUPLOAD_URL . 'assets/css/admin.css', [], EDGEUPLOAD_VERSION ); wp_enqueue_script( 'edgeupload-admin', EDGEUPLOAD_URL . 'assets/js/admin.js', ['jquery'], EDGEUPLOAD_VERSION, true ); wp_localize_script( 'edgeupload-admin', 'EdgeUploadAdmin', [ 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'edgeupload_test' ), 'i18n' => \EdgeUpload\Utils\I18n::map( [ 'Testing...' => 'Testing...', 'Connection successful !' => 'Connection successful !', 'Test failed' => 'Test failed', 'Request failed' => 'Request failed', 'CORS configuration error. Check bucket CORS: allow PUT and add Content-Type to AllowedHeaders for this site origin. ' => 'CORS configuration error. Check bucket CORS: allow PUT and add Content-Type to AllowedHeaders for this site origin. ', 'CORS configuration error. Check Azure Blob CORS: allow PUT and add Content-Type and x-ms-blob-type to Allowed headers for this site origin. ' => 'CORS configuration error. Check Azure Blob CORS: allow PUT and add Content-Type and x-ms-blob-type to Allowed headers for this site origin. ', 'Configuration example' => 'Configuration example', 'CORS configuration example' => 'CORS configuration example', 'Close' => 'Close', 'Browser upload failed: HTTP %s' => 'Browser upload failed: HTTP %s', 'View compatibility note' => 'View compatibility note', ] ), 'providerCopy' => \EdgeUpload\Utils\I18n::map( [ 'cos' => [ 'labels' => [ 'bucket' => 'Bucket', 'region' => 'Region', 'secret_id' => 'SecretId', 'secret_key' => 'SecretKey', ], 'descriptions' => [ 'bucket' => 'Tencent COS bucket name. Example: my_bucket_name-1234567890', 'region' => 'Region where the Tencent COS bucket is located. Example: ap-singapore', 'secret_id' => 'SecretId from an API key associated with an account that has full control permission for the Tencent COS bucket.', 'secret_key' => 'SecretKey from an API key associated with an account that has full control permission for the Tencent COS bucket.', ], ], 'oss' => [ 'labels' => [ 'bucket' => 'Bucket', 'region' => 'Endpoint', 'secret_id' => 'AccessKey ID', 'secret_key' => 'AccessKey Secret', ], 'descriptions' => [ 'bucket' => 'Alibaba OSS bucket name. Example: my_bucket_name', 'region' => 'Public endpoint for the Alibaba OSS bucket. Example: oss-ap-southeast-1.aliyuncs.com', 'secret_id' => 'AccessKey ID from an API key associated with a RAM user that has full control permission for the Alibaba OSS bucket.', 'secret_key' => 'AccessKey Secret from an API key associated with a RAM user that has full control permission for the Alibaba OSS bucket.', ], ], 's3' => [ 'labels' => [ 'bucket' => 'Bucket', 'region' => 'Region', 'secret_id' => 'Access key', 'secret_key' => 'Secret access key', ], 'descriptions' => [ 'bucket' => 'Amazon S3 bucket name. Example: my_bucket_name-1234567890-ap-southeast-1-an', 'region' => 'AWS region where the Amazon S3 bucket is located. Example: ap-southeast-1', 'secret_id' => 'Access key ID from an API key associated with an IAM user that has full control permission for the Amazon S3 bucket.', 'secret_key' => 'Secret access key from an API key associated with an IAM user that has full control permission for the Amazon S3 bucket.', ], ], 'azure' => [ 'labels' => [ 'bucket' => 'Storage account name', 'region' => 'Region', 'secret_id' => 'Container name', 'secret_key' => 'Account key', ], 'descriptions' => [ 'bucket' => 'Azure Storage account name. Example: storage_account_name', 'region' => 'Azure region where the storage account is located. Example: Southeast Asia', 'secret_id' => 'Azure Blob Storage container name inside the storage account. Example: container_name', 'secret_key' => 'Azure Storage account access key with permission to write and delete blobs in the container.', ], ], 'gcs' => [ 'labels' => [ 'bucket' => 'Bucket', 'region' => 'Location', 'secret_id' => 'Access key', 'secret_key' => 'Secret', ], 'descriptions' => [ 'bucket' => 'Google Cloud Storage bucket name. Example: my_bucket_name', 'region' => 'Google Cloud Storage bucket location. Example: asia-southeast1', 'secret_id' => 'Access key from Cloud Storage Settings > Interoperability.', 'secret_key' => 'Secret for the Google Cloud Storage interoperability access key.', ], ], ] ), 'corsGuideImages' => [ 'cos' => EDGEUPLOAD_URL . 'assets/images/cors-cos.png', 'oss' => EDGEUPLOAD_URL . 'assets/images/cors-oss.png', 's3' => EDGEUPLOAD_URL . 'assets/images/cors-s3.png', 'azure' => EDGEUPLOAD_URL . 'assets/images/cors-blob.png', 'gcs' => EDGEUPLOAD_URL . 'assets/images/cors-gcs.png', ], ] ); } ); add_action( 'wp_ajax_edgeupload_test_connection', ['EdgeUpload_Settings', 'ajax_test_connection'] ); add_action( 'wp_ajax_edgeupload_cleanup_cors_test', ['EdgeUpload_Settings', 'ajax_cleanup_cors_test'] ); add_action( 'rest_api_init', function () { EdgeUpload_Sign_API::register_routes(); } ); add_action( 'wp_enqueue_scripts', function () { wp_enqueue_script( 'edgeupload', EDGEUPLOAD_URL . 'assets/js/edgeupload.js', [], EDGEUPLOAD_VERSION, true ); wp_enqueue_script( 'edgeupload-utils', EDGEUPLOAD_URL . 'assets/js/core/utils.js', ['edgeupload'], EDGEUPLOAD_VERSION, true ); wp_enqueue_script( 'edgeupload-signer', EDGEUPLOAD_URL . 'assets/js/core/signer.js', ['edgeupload-utils'], EDGEUPLOAD_VERSION, true ); wp_enqueue_script( 'edgeupload-uploader', EDGEUPLOAD_URL . 'assets/js/core/uploader.js', ['edgeupload-signer'], EDGEUPLOAD_VERSION, true ); wp_enqueue_script( 'edgeupload-form', EDGEUPLOAD_URL . 'assets/js/form/index.js', ['edgeupload-uploader'], EDGEUPLOAD_VERSION, true ); wp_enqueue_script( 'edgeupload-form-helpers', EDGEUPLOAD_URL . 'assets/js/form/helpers.js', ['edgeupload-form'], EDGEUPLOAD_VERSION, true ); foreach ( \EdgeUpload\Integrations\IntegrationRegistry::all() as $integration ) { $script = $integration['script'] ?? []; if ( empty( $script['handle'] ) || empty( $script['src'] ) ) { continue; } wp_enqueue_script( $script['handle'], EDGEUPLOAD_URL . $script['src'], $script['deps'] ?? ['edgeupload-form-helpers'], EDGEUPLOAD_VERSION, true ); } wp_localize_script( 'edgeupload', 'EdgeUploadConfig', [ 'signEndpoint' => rest_url( 'edgeupload/v1/sign' ), 'nonce' => wp_create_nonce( 'wp_rest' ), 'provider' => \EdgeUpload\Providers\ProviderFactory::selected_provider(), 'publicHost' => \EdgeUpload\Providers\ProviderFactory::public_host(), 'retryCount' => \EdgeUpload\License\LicenseManager::effective_retry_count(), 'debug' => defined( 'WP_DEBUG' ) && WP_DEBUG, 'maxFiles' => \EdgeUpload\License\LicenseManager::effective_max_files(), 'maxFileSize' => \EdgeUpload\License\LicenseManager::effective_max_file_size() * 1024 * 1024, 'isPro' => \EdgeUpload\License\LicenseManager::is_pro(), 'upgradeUrl' => \EdgeUpload\License\LicenseManager::upgrade_url(), 'formIds' => \EdgeUpload\Utils\Options::identifier_list( 'edgeupload_form_ids' ), 'elementorFormIds' => \EdgeUpload\Utils\Options::identifier_list( 'edgeupload_elementor_form_ids' ), 'i18n' => \EdgeUpload\Utils\I18n::map( [ 'Uploading 0%' => 'Uploading 0%', 'Uploading %s%' => 'Uploading %s%', 'Upload complete' => 'Upload complete', 'Upload failed' => 'Upload failed', 'Upload completed without file URL' => 'Upload completed without file URL', 'EdgeUpload sign failed: %s' => 'EdgeUpload sign failed: %s', 'Upload failed: %s' => 'Upload failed: %s', 'Network error' => 'Network error', 'File upload in progress, please wait.' => 'File upload in progress, please wait.', 'Maximum %s files allowed' => 'Maximum %s files allowed', 'File "%s" is too large' => 'File "%s" is too large', 'Remove' => 'Remove', 'Free plan: only %s file per upload. Upgrade to PRO to remove this limit.' => 'Free plan: only %s file per upload. Upgrade to PRO to remove this limit.', 'Free plan: max %s MB per file. Upgrade to PRO to remove this limit.' => 'Free plan: max %s MB per file. Upgrade to PRO to remove this limit.', ] ), ] ); } ); }