| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* |
| 5 |
* @link https://webdeclic.com/ |
| 6 |
* @since 1.0.0 |
| 7 |
* @package Quickwebp |
| 8 |
* |
| 9 |
* @wordpress-plugin |
| 10 |
* Plugin Name: QuickWebP - Compress / Optimize Images & Convert WebP | SEO Friendly |
| 11 |
* Plugin URI: https://webdeclic.com/projets/creation-de-lextension-wordpress-quickwebp/ |
| 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.0 |
| 14 |
* Author: Webdeclic |
| 15 |
* Requires PHP: 8.1 |
| 16 |
* Author URI: https://webdeclic.com/ |
| 17 |
* License: GPL-2.0+ |
| 18 |
* License URI: https://www.gnu.org/licenses/gpl-2.0.txt |
| 19 |
* Text Domain: quickwebp |
| 20 |
* Domain Path: /languages |
| 21 |
*/ |
| 22 |
|
| 23 |
// If this file is called directly, abort. |
| 24 |
if ( ! defined( 'WPINC' ) ) { |
| 25 |
die; |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* Check if your are in local or production environment |
| 30 |
*/ |
| 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'); |
| 33 |
|
| 34 |
/** |
| 35 |
* If you are in local environment, you can use the version number as a timestamp for better cache management in your browser |
| 36 |
*/ |
| 37 |
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound |
| 38 |
$version = get_file_data( __FILE__, array( 'Version' => 'Version' ), false )['Version']; |
| 39 |
|
| 40 |
/** |
| 41 |
* Currently plugin version. |
| 42 |
* Start at version 1.0.0 and use SemVer - https://semver.org |
| 43 |
* Rename this for your plugin and update it as you release new versions. |
| 44 |
*/ |
| 45 |
define( 'QUICKWEBP_VERSION', $version ); |
| 46 |
|
| 47 |
/** |
| 48 |
* You can use this const for check if you are in local environment |
| 49 |
*/ |
| 50 |
define( 'QUICKWEBP_DEV_MOD', $is_local ); |
| 51 |
|
| 52 |
/** |
| 53 |
* Plugin File |
| 54 |
*/ |
| 55 |
define( 'QUICKWEBP_PLUGIN_FILE', __FILE__ ); |
| 56 |
|
| 57 |
/** |
| 58 |
* Plugin Name text domain for internationalization. |
| 59 |
*/ |
| 60 |
define( 'QUICKWEBP_TEXT_DOMAIN', 'quickwebp' ); |
| 61 |
|
| 62 |
/** |
| 63 |
* Plugin Name Path for plugin includes. |
| 64 |
*/ |
| 65 |
define( 'QUICKWEBP_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); |
| 66 |
|
| 67 |
/** |
| 68 |
* Plugin Name URL for plugin sources (css, js, images etc...). |
| 69 |
*/ |
| 70 |
define( 'QUICKWEBP_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
| 71 |
|
| 72 |
/** |
| 73 |
* The code that runs during plugin activation. |
| 74 |
* This action is documented in includes/class-quickwebp-activator.php |
| 75 |
*/ |
| 76 |
function quickwebp_activate() { |
| 77 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-quickwebp-activator.php'; |
| 78 |
Quickwebp_Activator::activate(); |
| 79 |
} |
| 80 |
|
| 81 |
/** |
| 82 |
* The code that runs during plugin deactivation. |
| 83 |
* This action is documented in includes/class-quickwebp-deactivator.php |
| 84 |
*/ |
| 85 |
function quickwebp_deactivate() { |
| 86 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-quickwebp-deactivator.php'; |
| 87 |
Quickwebp_Deactivator::deactivate(); |
| 88 |
} |
| 89 |
|
| 90 |
register_activation_hook( __FILE__, 'quickwebp_activate' ); |
| 91 |
register_deactivation_hook( __FILE__, 'quickwebp_deactivate' ); |
| 92 |
|
| 93 |
/** |
| 94 |
* The core plugin class that is used to define internationalization, |
| 95 |
* admin-specific hooks, and public-facing site hooks. |
| 96 |
*/ |
| 97 |
require plugin_dir_path( __FILE__ ) . 'includes/class-quickwebp.php'; |
| 98 |
|
| 99 |
/** |
| 100 |
* Begins execution of the plugin. |
| 101 |
* |
| 102 |
* Since everything within the plugin is registered via hooks, |
| 103 |
* then kicking off the plugin from this point in the file does |
| 104 |
* not affect the page life cycle. |
| 105 |
* |
| 106 |
* @since 1.0.0 |
| 107 |
*/ |
| 108 |
function quickwebp_run() { |
| 109 |
|
| 110 |
if ( ! version_compare( PHP_VERSION, '7.4', '>=' ) ) { |
| 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 |
|
| 126 |
} |
| 127 |
quickwebp_run(); |
| 128 |
|