| @@ -8,11 +8,12 @@ | ||
| 8 | 8 | * |
| 9 | 9 | * @wordpress-plugin |
| 10 | 10 | * Plugin Name: QuickWebP - Compress / Optimize Images & Convert WebP | SEO Friendly |
| 11 | 11 | * Plugin URI: https://webdeclic.com/projets/creation-de-lextension-wordpress-quickwebp/ |
| 12 | - * Description: Description | |
| 13 | - * Version: 2.0.0 | |
| 12 | + * Description: Convert JPG and PNG images to WebP, compress uploads locally, improve image SEO, and unlock AVIF with QuickWebP Pro. | |
| 13 | + * Version: 4.1.1 | |
| 14 | 14 | * Author: Webdeclic |
| 15 | + * Requires PHP: 8.1 | |
| 15 | 16 | * Author URI: https://webdeclic.com/ |
| 16 | 17 | * License: GPL-2.0+ |
| 17 | 18 | * License URI: https://www.gnu.org/licenses/gpl-2.0.txt |
| 18 | 19 | * Text Domain: quickwebp |
| @@ -26,14 +27,16 @@ | ||
| 26 | 27 | |
| 27 | 28 | /** |
| 28 | 29 | * Check if your are in local or production environment |
| 29 | 30 | */ |
| 30 | -$is_local = $_SERVER['REMOTE_ADDR'] == '127.0.0.1' || $_SERVER['REMOTE_ADDR'] == '::1'; | |
| 31 | +// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound | |
| 32 | +$is_local = isset($_SERVER['REMOTE_ADDR']) && ($_SERVER['REMOTE_ADDR'] == '127.0.0.1' || $_SERVER['REMOTE_ADDR'] == '::1'); | |
| 31 | 33 | |
| 32 | 34 | /** |
| 33 | 35 | * If you are in local environment, you can use the version number as a timestamp for better cache management in your browser |
| 34 | 36 | */ |
| 35 | -$version = $is_local ? time() : '2.0.0'; | |
| 37 | +// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound | |
| 38 | +$version = get_file_data( __FILE__, array( 'Version' => 'Version' ), false )['Version']; | |
| 36 | 39 | |
| 37 | 40 | /** |
| 38 | 41 | * Currently plugin version. |
| 39 | 42 | * Start at version 1.0.0 and use SemVer - https://semver.org |
| @@ -46,8 +49,13 @@ | ||
| 46 | 49 | */ |
| 47 | 50 | define( 'QUICKWEBP_DEV_MOD', $is_local ); |
| 48 | 51 | |
| 49 | 52 | /** |
| 53 | + * Plugin File | |
| 54 | + */ | |
| 55 | +define( 'QUICKWEBP_PLUGIN_FILE', __FILE__ ); | |
| 56 | + | |
| 57 | +/** | |
| 50 | 58 | * Plugin Name text domain for internationalization. |
| 51 | 59 | */ |
| 52 | 60 | define( 'QUICKWEBP_TEXT_DOMAIN', 'quickwebp' ); |
| 53 | 61 | |
| @@ -64,9 +72,9 @@ | ||
| 64 | 72 | /** |
| 65 | 73 | * The code that runs during plugin activation. |
| 66 | 74 | * This action is documented in includes/class-quickwebp-activator.php |
| 67 | 75 | */ |
| 68 | -function activate_quickwebp() { | |
| 76 | +function quickwebp_activate() { | |
| 69 | 77 | require_once plugin_dir_path( __FILE__ ) . 'includes/class-quickwebp-activator.php'; |
| 70 | 78 | Quickwebp_Activator::activate(); |
| 71 | 79 | } |
| 72 | 80 | |
| @@ -73,15 +81,15 @@ | ||
| 73 | 81 | /** |
| 74 | 82 | * The code that runs during plugin deactivation. |
| 75 | 83 | * This action is documented in includes/class-quickwebp-deactivator.php |
| 76 | 84 | */ |
| 77 | -function deactivate_quickwebp() { | |
| 85 | +function quickwebp_deactivate() { | |
| 78 | 86 | require_once plugin_dir_path( __FILE__ ) . 'includes/class-quickwebp-deactivator.php'; |
| 79 | 87 | Quickwebp_Deactivator::deactivate(); |
| 80 | 88 | } |
| 81 | 89 | |
| 82 | -register_activation_hook( __FILE__, 'activate_quickwebp' ); | |
| 83 | -register_deactivation_hook( __FILE__, 'deactivate_quickwebp' ); | |
| 90 | +register_activation_hook( __FILE__, 'quickwebp_activate' ); | |
| 91 | +register_deactivation_hook( __FILE__, 'quickwebp_deactivate' ); | |
| 84 | 92 | |
| 85 | 93 | /** |
| 86 | 94 | * The core plugin class that is used to define internationalization, |
| 87 | 95 | * admin-specific hooks, and public-facing site hooks. |
| @@ -96,11 +104,24 @@ | ||
| 96 | 104 | * not affect the page life cycle. |
| 97 | 105 | * |
| 98 | 106 | * @since 1.0.0 |
| 99 | 107 | */ |
| 100 | -function run_quickwebp() { | |
| 108 | +function quickwebp_run() { | |
| 101 | 109 | |
| 102 | - $plugin = new Quickwebp(); | |
| 103 | - $plugin->run(); | |
| 110 | + if ( ! version_compare( PHP_VERSION, '7.4', '>=' ) ) { | |
| 104 | 111 | |
| 112 | + add_action( 'admin_notices', function() { | |
| 113 | + ?> | |
| 114 | + <div class="notice notice-error"> | |
| 115 | + <p><?php esc_html_e( "Oops! QuickWebP isn't running because PHP is outdated. Update to PHP version 7.4", 'quickwebp' ); ?></p> | |
| 116 | + </div> | |
| 117 | + <?php | |
| 118 | + }); | |
| 119 | + | |
| 120 | + } else { | |
| 121 | + | |
| 122 | + $plugin = new Quickwebp(); | |
| 123 | + $plugin->run(); | |
| 124 | + } | |
| 125 | + | |
| 105 | 126 | } |
| 106 | -run_quickwebp(); | |
| 127 | +quickwebp_run(); | |