PluginProbe
Image Optimizer – Compress Images and Convert to WebP or AVIF / trunk
Image Optimizer – Compress Images and Convert to WebP or AVIF vtrunk
1.7.7 1.7.6 1.7.5 1.7.4 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 All 33 releases
← All changes | image-optimization.php +71 -44 1.2.0 → trunk View file →
@@ -1,28 +1,50 @@
1 1 <?php
2 2 /**
3 - * Plugin Name: Image Optimizer by Elementor – Compress, Resize and Optimize Images
4 - * Description: Automatically compress and enhance your images, boosting your website speed, appearance, and SEO. Get Image Optimizer and optimize your images in seconds.
3 + * Plugin Name: Image Optimization - Optimize Images and Convert to WebP or AVIF
4 + * Description: Automatically resize, optimize, and convert images to WebP and AVIF. Compress images in bulk or on upload to boost your WordPress site performance.
5 5 * Plugin URI: https://go.elementor.com/wp-repo-description-tab-io-product-page/
6 - * Version: 1.2.0
6 + * Version: 1.7.7
7 7 * Author: Elementor.com
8 - * Author URI: https://go.elementor.com/wp-repo-description-tab-io-author-url/
8 + * Author URI: https://go.elementor.com/author-uri-io/
9 9 * Text Domain: image-optimization
10 10 * License: GPL-3
11 11 * License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
12 + *
13 + * Image Optimization is free software: you can redistribute it and/or modify
14 + * it under the terms of the GNU General Public License as published by
15 + * the Free Software Foundation, either version 3 of the License, or
16 + * any later version.
17 + *
18 + * Image Optimization is distributed in the hope that it will be useful,
19 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 + * GNU General Public License for more details.
12 22 */
13 23
24 +use ImageOptimization\Modules\Core\Module as CoreModule;
25 +
14 26 if ( ! defined( 'ABSPATH' ) ) {
15 27 exit; // Exit if accessed directly.
16 28 }
17 29
18 -define( 'IMAGE_OPTIMIZATION_VERSION', '1.2.0' );
19 -define( 'IMAGE_OPTIMIZATION_PATH', plugin_dir_path( __FILE__ ) );
20 -define( 'IMAGE_OPTIMIZATION_URL', plugins_url( '/', __FILE__ ) );
30 +define( 'IMAGE_OPTIMIZATION_VERSION', '1.7.7' );
31 +define( 'IMAGE_OPTIMIZATION_FILE', __FILE__ );
32 +define( 'IMAGE_OPTIMIZATION_PATH', plugin_dir_path( IMAGE_OPTIMIZATION_FILE ) );
33 +define( 'IMAGE_OPTIMIZATION_URL', plugins_url( '/', IMAGE_OPTIMIZATION_FILE ) );
21 34 define( 'IMAGE_OPTIMIZATION_ASSETS_PATH', IMAGE_OPTIMIZATION_PATH . 'assets/' );
22 35 define( 'IMAGE_OPTIMIZATION_ASSETS_URL', IMAGE_OPTIMIZATION_URL . 'assets/' );
23 -define( 'IMAGE_OPTIMIZATION_PLUGIN_FILE', basename( __FILE__ ) );
36 +define( 'IMAGE_OPTIMIZATION_PLUGIN_FILE', plugin_basename( IMAGE_OPTIMIZATION_FILE ) );
24 37
38 +if ( ! defined( 'IMAGE_OPTIMIZATION_MINIMUM_LOG_LEVEL' ) ) {
39 + define( 'IMAGE_OPTIMIZATION_MINIMUM_LOG_LEVEL', 3 );
40 +}
41 +
42 +register_deactivation_hook(
43 + __FILE__,
44 + [ CoreModule::class, 'on_deactivation' ]
45 +);
46 +
25 47 /**
26 48 * ImageOptimization Class
27 49 */
28 50 final class ImageOptimization {
@@ -38,10 +60,9 @@
38 60 *
39 61 * @access public
40 62 */
41 63 public function __construct() {
42 - // Load translation
43 - add_action( 'init', [ $this, 'i18n' ] );
64 + require_once IMAGE_OPTIMIZATION_PATH . 'vendor/autoload.php';
44 65
45 66 // Init Plugin
46 67 add_action( 'plugins_loaded', [ $this, 'init' ], -11 );
47 68 }
@@ -46,23 +67,12 @@
46 67 add_action( 'plugins_loaded', [ $this, 'init' ], -11 );
47 68 }
48 69
49 70 /**
50 - * Load Textdomain
51 - *
52 - * Load plugin localization files.
53 - * Fired by `init` action hook.
54 - *
55 - * @access public
56 - */
57 - public function i18n() {
58 - load_plugin_textdomain( 'image-optimization' );
59 - }
60 -
61 - /**
62 71 * Checks if all requirements met to safely start the plugin and renders admin notices
63 72 * if something is not right.
64 73 *
74 + * @access public
65 75 * @return bool
66 76 */
67 77 public function plugin_can_start(): bool {
68 78 $can_start = true;
@@ -67,14 +77,16 @@
67 77 public function plugin_can_start(): bool {
68 78 $can_start = true;
69 79
70 80 if ( ! version_compare( PHP_VERSION, '7.4', '>=' ) ) {
71 - /* translators: 1: PHP version. 2: Link opening tag, 3: Link closing tag. */
72 81 $this->requirements_errors[] = sprintf(
73 - esc_html__( 'PHP is outdated. Update to PHP version %1$s. %2$sShow me how%3$s', 'image-optimization' ),
74 - '7.4',
75 - '<a href="https://go.elementor.com/wp-dash-update-php/" target="_blank">',
76 - '</a>'
82 + '%1$s <a href="https://go.elementor.com/wp-dash-update-php/" target="_blank">%2$s</a>',
83 + sprintf(
84 + /* translators: %s: PHP version. */
85 + esc_html__( 'Update to PHP version %s and get back to optimizing!', 'image-optimization' ),
86 + '7.4',
87 + ),
88 + esc_html__( 'Show me how', 'image-optimization' )
77 89 );
78 90
79 91 $can_start = false;
80 92 }
@@ -91,11 +103,11 @@
91 103 }
92 104
93 105 if ( ! $this->is_db_json_supported() ) {
94 106 $this->requirements_errors[] = sprintf(
95 - /* translators: 1: MySQL minimum version. 2: MariaDB minimum version. */
107 + /* translators: 1: MySQL minimum version. 2: MariaDB minimum version. */
96 108 esc_html__(
97 - 'The database server version is outdated. Update to MySQL version %1$s or MariaDB version %2$s',
109 + 'The database server version is outdated. Update to MySQL version %1$s or MariaDB version %2$s.',
98 110 'image-optimization'
99 111 ),
100 112 '5.7',
101 113 '10.2'
@@ -118,11 +130,12 @@
118 130 return $can_start;
119 131 }
120 132
121 133 /**
122 - * Returns an array of non-loaded extensions mentioned in self::REQUIRED_EXTENSIONS.
134 + * Retrieve an array of missing extensions mentioned in self::REQUIRED_EXTENSIONS.
123 135 *
124 - * @return array Missed extensions.
136 + * @access private
137 + * @return array Missing extensions.
125 138 */
126 139 private function get_missing_extensions_list(): array {
127 140 $output = [];
128 141
@@ -134,29 +147,44 @@
134 147
135 148 return $output;
136 149 }
137 150
151 + /**
152 + * The check is strictly based on the action scheduler requirements that needs JSON partial matching to work
153 + * with action queries.
154 + *
155 + * @return bool
156 + */
138 157 public function is_db_json_supported(): bool {
139 158 global $wpdb;
140 159
141 - $result = $wpdb->query("
142 - SELECT JSON_EXTRACT('[1, 2]', '$[1]');
143 - ");
160 + $db_server_info = is_callable( array( $wpdb, 'db_server_info' ) ) ? $wpdb->db_server_info() : $wpdb->db_version();
144 161
145 - return false !== $result;
162 + if ( false !== strpos( $db_server_info, 'MariaDB' ) ) {
163 + $supports_json = version_compare(
164 + PHP_VERSION_ID >= 80016 ? $wpdb->db_version() : preg_replace( '/[^0-9.].*/', '', str_replace( '5.5.5-', '', $db_server_info ) ),
165 + '10.2',
166 + '>='
167 + );
168 + } else {
169 + $supports_json = version_compare( $wpdb->db_version(), '5.7', '>=' );
170 + }
171 +
172 + return (bool) $supports_json;
146 173 }
147 174
148 175 /**
149 176 * Renders an admin notice if the setup did not meet requirements.
150 177 *
178 + * Fired by `admin_notices` action hook.
179 + *
180 + * @access public
151 181 * @return void
152 182 */
153 183 public function add_requirements_error() {
154 184 $message = sprintf(
155 - /* translators: 1: `<h3>` opening tag, 2: `</h3>` closing tag */
156 - esc_html__( '%1$sImage Optimizer isn’t running because:%2$s', 'image-optimization' ),
157 - '<h3>',
158 - '</h3>'
185 + '<h3>%s</h3>',
186 + esc_html__( 'Image Optimization isn’t running because:', 'image-optimization' )
159 187 );
160 188
161 189 $message .= '<ul>';
162 190
@@ -176,13 +204,12 @@
176 204 echo wp_kses_post( $html_message );
177 205 }
178 206
179 207 /**
180 - * Initialize the plugin
208 + * Initialize the plugin.
181 209 *
182 - * Validates that PHP version is sufficient.
183 - * Checks for basic plugin requirements, if one check fail don't continue,
184 - * if all check have passed include the plugin class.
210 + * Validates that PHP version is sufficient. Checks for basic plugin requirements,
211 + * if one check fail don't continue, if all check have passed include the plugin class.
185 212 *
186 213 * Fired by `plugins_loaded` action hook.
187 214 *
188 215 * @access public
@@ -196,6 +223,6 @@
196 223 }
197 224 }
198 225 }
199 226
200 -// Instantiate ImageOptimization..
227 +// Instantiate ImageOptimization.
201 228 new ImageOptimization();