| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Ultimate Watermark |
| 4 |
* Plugin URI: https://mantrabrain.com/ultimate-watermark |
| 5 |
* Description: Advanced WordPress Image Watermarking Plugin |
| 6 |
* Version: 2.0.7 |
| 7 |
* Author: MantraBrain |
| 8 |
* Author URI: https://mantrabrain.com |
| 9 |
* License: GPL v3 or later |
| 10 |
* License URI: https://www.gnu.org/licenses/gpl-3.0.html |
| 11 |
* Text Domain: ultimate-watermark |
| 12 |
* Domain Path: /languages |
| 13 |
* Requires at least: 5.0 |
| 14 |
* Tested up to: 6.9 |
| 15 |
* Requires PHP: 7.4 |
| 16 |
* Network: false |
| 17 |
* |
| 18 |
* @package UltimateWatermark |
| 19 |
* @author MantraBrain |
| 20 |
* @version 2.0.7 |
| 21 |
*/ |
| 22 |
|
| 23 |
// Prevent direct access |
| 24 |
if (!defined('ABSPATH')) { |
| 25 |
exit('Direct access forbidden.'); |
| 26 |
} |
| 27 |
|
| 28 |
// Check PHP version compatibility |
| 29 |
if (version_compare(PHP_VERSION, '7.4.0', '<')) { |
| 30 |
deactivate_plugins(plugin_basename(__FILE__)); |
| 31 |
wp_die(sprintf( |
| 32 |
__('Ultimate Watermark requires PHP 7.4 or higher. You are running %s', 'ultimate-watermark'), |
| 33 |
PHP_VERSION |
| 34 |
)); |
| 35 |
} |
| 36 |
|
| 37 |
// Define plugin constants |
| 38 |
define('ULTIMATE_WATERMARK_VERSION', '2.0.7'); |
| 39 |
define('ULTIMATE_WATERMARK_FILE', __FILE__); |
| 40 |
define('ULTIMATE_WATERMARK_DIR', plugin_dir_path(__FILE__)); |
| 41 |
define('ULTIMATE_WATERMARK_URL', plugin_dir_url(__FILE__)); |
| 42 |
define('ULTIMATE_WATERMARK_BASENAME', plugin_basename(__FILE__)); |
| 43 |
define('ULTIMATE_WATERMARK_MIN_PHP', '7.4.0'); |
| 44 |
define('ULTIMATE_WATERMARK_MIN_WP', '5.0'); |
| 45 |
|
| 46 |
// Load Composer autoloader with error handling |
| 47 |
$autoloader_path = ULTIMATE_WATERMARK_DIR . 'vendor/autoload.php'; |
| 48 |
if (!file_exists($autoloader_path)) { |
| 49 |
deactivate_plugins(plugin_basename(__FILE__)); |
| 50 |
wp_die(__('Ultimate Watermark: Composer autoloader not found. Please run "composer install"', 'ultimate-watermark')); |
| 51 |
} |
| 52 |
|
| 53 |
require_once $autoloader_path; |
| 54 |
|
| 55 |
// Initialize the plugin with proper error handling |
| 56 |
add_action('plugins_loaded', function () { |
| 57 |
try { |
| 58 |
if (class_exists('MantraBrain\\UltimateWatermark\\Core\\Plugin')) { |
| 59 |
\MantraBrain\UltimateWatermark\Core\Plugin::getInstance(); |
| 60 |
} else { |
| 61 |
throw new \Exception('Plugin class not found'); |
| 62 |
} |
| 63 |
} catch (\Exception $e) { |
| 64 |
error_log('Ultimate Watermark initialization failed: ' . $e->getMessage()); |
| 65 |
if (is_admin() && current_user_can('activate_plugins')) { |
| 66 |
add_action('admin_notices', function() use ($e) { |
| 67 |
printf( |
| 68 |
'<div class="error notice"><p>%s</p></div>', |
| 69 |
sprintf( |
| 70 |
__('Ultimate Watermark initialization failed: %s', 'ultimate-watermark'), |
| 71 |
esc_html($e->getMessage()) |
| 72 |
) |
| 73 |
); |
| 74 |
}); |
| 75 |
} |
| 76 |
} |
| 77 |
}); |
| 78 |
|
| 79 |
// Activation hook with error handling |
| 80 |
register_activation_hook(__FILE__, function () { |
| 81 |
try { |
| 82 |
if (class_exists('MantraBrain\\UltimateWatermark\\Core\\Activator')) { |
| 83 |
\MantraBrain\UltimateWatermark\Core\Activator::activate(); |
| 84 |
} else { |
| 85 |
throw new \Exception('Activator class not found'); |
| 86 |
} |
| 87 |
} catch (\Exception $e) { |
| 88 |
error_log('Ultimate Watermark activation failed: ' . $e->getMessage()); |
| 89 |
deactivate_plugins(plugin_basename(__FILE__)); |
| 90 |
wp_die(sprintf( |
| 91 |
__('Ultimate Watermark activation failed: %s', 'ultimate-watermark'), |
| 92 |
esc_html($e->getMessage()) |
| 93 |
)); |
| 94 |
} |
| 95 |
}); |
| 96 |
|
| 97 |
// Deactivation hook with error handling |
| 98 |
register_deactivation_hook(__FILE__, function () { |
| 99 |
try { |
| 100 |
if (class_exists('MantraBrain\\UltimateWatermark\\Core\\Deactivator')) { |
| 101 |
\MantraBrain\UltimateWatermark\Core\Deactivator::deactivate(); |
| 102 |
} |
| 103 |
} catch (\Exception $e) { |
| 104 |
error_log('Ultimate Watermark deactivation error: ' . $e->getMessage()); |
| 105 |
} |
| 106 |
}); |
| 107 |
|