PluginProbe
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization / 4.2.15
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization v4.2.15
4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 2.5.5 2.5.6 2.5.7 3.0.0 3.0.1 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.11.0 3.11.1 3.11.2 3.11.3 All 136 releases
← All changes | inc/admin.php +1518 -460 3.10.0 → 4.2.15 View file →
@@ -9,8 +9,11 @@
9 9 * @package \Optimole\Inc
10 10 * @author Optimole <[email protected]>
11 11 */
12 12
13 +use enshrined\svgSanitize\Sanitizer;
14 +use OptimoleWP\BgOptimizer\Lazyload;
15 +use OptimoleWP\PageProfiler\Profile;
13 16 /**
14 17 * Class Optml_Admin
15 18 */
16 19 class Optml_Admin {
@@ -18,8 +21,13 @@
18 21
19 22 const IMAGE_DATA_COLLECTED = 'optml_image_data_collected';
20 23
21 24 const IMAGE_DATA_COLLECTED_BATCH = 100;
25 +
26 + const BF_PROMO_DISMISS_KEY = 'optml_bf25_notice_dismiss';
27 +
28 + const SPC_BANNER_DISMISS_KEY = 'optml_spc_banner_dismiss';
29 +
22 30 /**
23 31 * Hold the settings object.
24 32 *
25 33 * @var Optml_Settings Settings object.
@@ -33,60 +41,246 @@
33 41 */
34 42 public $conflicting_plugins;
35 43
36 44 const NEW_USER_DEFAULTS_UPDATED = 'optml_defaults_updated';
45 + const OLD_USER_ENABLED_LD = 'optml_enabled_limit_dimensions';
46 + const OLD_USER_ENABLED_CL = 'optml_enabled_cloud_sites';
37 47
48 + const SYNC_CRON = 'optml_daily_sync';
49 + const ENRICH_CRON = 'optml_pull_image_data';
38 50 /**
39 51 * Optml_Admin constructor.
40 52 */
41 53 public function __construct() {
42 - $this->settings = new Optml_Settings();
54 + $this->settings = new Optml_Settings();
43 55 $this->conflicting_plugins = new Optml_Conflicting_Plugins();
44 56
57 + $media_rename = new Optml_Attachment_Edit();
58 + $media_rename->init();
59 +
60 + $dashboard_widget = new Optml_Dashboard_Widget();
61 + $dashboard_widget->init();
62 +
45 63 add_filter( 'plugin_action_links_' . plugin_basename( OPTML_BASEFILE ), [ $this, 'add_action_links' ] );
46 64 add_action( 'admin_menu', [ $this, 'add_dashboard_page' ] );
47 65 add_action( 'admin_menu', [ $this, 'add_settings_subpage' ], 99 );
48 - add_action( 'admin_enqueue_scripts', [ $this, 'menu_icon_style' ] );
66 + add_action( 'admin_head', [ $this, 'menu_icon_style' ] );
49 67 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue' ], PHP_INT_MIN );
50 68 add_action( 'admin_notices', [ $this, 'add_notice' ] );
51 69 add_action( 'admin_notices', [ $this, 'add_notice_upgrade' ] );
52 70 add_action( 'admin_notices', [ $this, 'add_notice_conflicts' ] );
53 - add_action( 'optml_daily_sync', [ $this, 'daily_sync' ] );
71 + add_action( self::SYNC_CRON, [ $this, 'daily_sync' ] );
54 72 add_action( 'admin_init', [ $this, 'redirect_old_dashboard' ] );
73 + add_action( 'optml_purge_image_cache', [ $this, 'purge_image_cache' ] );
74 + if ( $this->settings->is_connected() ) {
75 + add_action( 'init', [ $this, 'check_domain_change' ] );
76 + add_action( self::ENRICH_CRON, [ $this, 'pull_image_data' ] );
55 77
56 - if ( $this->settings->is_connected() ) {
57 - add_action( 'init', [$this, 'check_domain_change'] );
58 - add_action( 'optml_pull_image_data_init', [$this, 'pull_image_data_init'] );
59 - add_action( 'optml_pull_image_data', [$this, 'pull_image_data'] );
60 - add_filter( 'wp_insert_attachment_data', [$this, 'detect_image_title_changes'], 10, 4 );
61 - add_action( 'updated_post_meta', [$this, 'detect_image_alt_change' ], 10, 4 );
62 - add_action( 'added_post_meta', [$this, 'detect_image_alt_change'], 10, 4 );
63 - add_action( 'init', [ $this, 'schedule_data_enhance_cron' ] );
78 + // Backwards compatibility for older versions of WordPress < 6.0.0 requiring 3 parameters for this specific filter.
79 + $below_6_0_0 = version_compare( get_bloginfo( 'version' ), '6.0.0', '<' );
80 + if ( $below_6_0_0 ) {
81 + add_filter( 'wp_insert_attachment_data', [ $this, 'legacy_detect_image_title_changes' ], 10, 3 );
82 + } else {
83 + add_filter( 'wp_insert_attachment_data', [ $this, 'detect_image_title_changes' ], 10, 4 );
84 + }
85 +
86 + add_action( 'updated_post_meta', [ $this, 'detect_image_alt_change' ], 10, 4 );
87 + add_action( 'added_post_meta', [ $this, 'detect_image_alt_change' ], 10, 4 );
88 + add_filter( 'update_attached_file', [ $this, 'listen_update_file' ], 999, 2 );
89 + if ( ! wp_next_scheduled( self::ENRICH_CRON ) ) {
90 + wp_schedule_event( time() + 10, 'hourly', self::ENRICH_CRON );
91 + }
64 92 }
65 93 add_action( 'init', [ $this, 'update_default_settings' ] );
94 + add_action( 'init', [ $this, 'update_limit_dimensions' ] );
95 + add_action( 'init', [ $this, 'update_cloud_sites_default' ] );
66 96 add_action( 'admin_init', [ $this, 'maybe_redirect' ] );
67 97 add_action( 'admin_init', [ $this, 'init_no_script' ] );
68 - if ( ! is_admin() && $this->settings->is_connected() && ! wp_next_scheduled( 'optml_daily_sync' ) ) {
69 - wp_schedule_event( time() + 10, 'daily', 'optml_daily_sync', [] );
98 + add_action( 'plugins_loaded', [ $this,'add_permission_policy' ] );
99 + if ( ! is_admin() && $this->settings->is_connected() && ! wp_next_scheduled( self::SYNC_CRON ) ) {
100 + wp_schedule_event( time() + 10, 'twicedaily', self::SYNC_CRON, [] );
70 101 }
71 102 add_action( 'optml_after_setup', [ $this, 'register_public_actions' ], 999999 );
72 103
73 104 if ( ! function_exists( 'is_wpcom_vip' ) ) {
74 - add_filter( 'upload_mimes', [ $this, 'allow_meme_types' ] ); // phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.upload_mimes
105 + add_filter(
106 + 'upload_mimes',
107 + [
108 + $this,
109 + 'allow_svg',
110 + ]
111 + ); // phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.upload_mimes
112 + add_filter( 'wp_handle_upload_prefilter', [ $this, 'check_svg_and_sanitize' ] );
75 113 }
114 +
115 + add_filter( 'themeisle-sdk/survey/' . OPTML_PRODUCT_SLUG, [ $this, 'get_survey_metadata' ], 10, 2 );
116 + add_action( 'admin_init', [ $this, 'mark_user_with_offload' ] );
76 117 }
118 +
77 119 /**
78 - * Schedules the hourly cron that starts the querying for images alt/title attributes
120 + * Add the permission policy for CH.
79 121 *
80 - * @uses action: init
122 + * @return void
81 123 */
82 - public function schedule_data_enhance_cron() {
83 - if ( ! wp_next_scheduled( 'optml_pull_image_data_init' ) ) {
84 - wp_schedule_event( time(), 'hourly', 'optml_pull_image_data_init' );
124 + public function add_permission_policy() {
125 + if ( ! $this->settings->is_connected() ) {
126 + return;
85 127 }
128 + if ( ! $this->settings->is_enabled() ) {
129 + return;
130 + }
131 + if ( headers_sent() ) {
132 + return;
133 + }
134 + $policy = $this->get_permissions_policy();
135 + if ( empty( $policy ) ) {
136 + return;
137 + }
138 + header( sprintf( 'Permissions-Policy: %s', $policy ), false );
86 139 }
87 140
88 141 /**
142 + * Build the Permissions-Policy header value based on active settings.
143 + *
144 + * @return string Comma-separated policy directives, or empty string when none apply.
145 + */
146 + public function get_permissions_policy(): string {
147 + $parts = [];
148 + $service_url = esc_url( Optml_Config::$service_url );
149 +
150 + if ( $this->settings->is_scale_enabled() ) {
151 + $parts[] = sprintf( 'ch-viewport-width=(self "%s")', $service_url );
152 + }
153 + if ( $this->settings->get( 'network_optimization' ) === 'enabled' ) {
154 + $parts[] = sprintf( 'ch-ect=(self "%s")', $service_url );
155 + }
156 + if ( $this->settings->get( 'retina_images' ) === 'enabled' ) {
157 + $parts[] = sprintf( 'ch-dpr=(self "%s")', $service_url );
158 + }
159 +
160 + return implode( ', ', $parts );
161 + }
162 + /**
163 + * Function that purges the image cache for a specific file.
164 + *
165 + * @param string $file Path or url of the file to clear.
166 + *
167 + * @return void
168 + */
169 + public function purge_image_cache( $file ) {
170 + $basename = wp_basename( $file );
171 + $settings = new Optml_Settings();
172 + $settings->clear_cache( $basename );
173 + }
174 + /**
175 + * Listen when the file is updated and clear the cache for the file.
176 + *
177 + * @param string $file The file path.
178 + * @param int $post_id The post ID.
179 + *
180 + * @return string The file path.
181 + */
182 + public function listen_update_file( $file, $post_id ) {
183 + // Purge the image cache.
184 + do_action( 'optml_purge_image_cache', $file );
185 + return $file;
186 + }
187 + /**
188 + * Check if the file is an SVG, if so handle appropriately
189 + *
190 + * @param array $file An array of data for a single file.
191 + *
192 + * @return mixed
193 + */
194 + public function check_svg_and_sanitize( $file ) {
195 + // Ensure we have a proper file path before processing.
196 + if ( ! isset( $file['tmp_name'] ) ) {
197 + return $file;
198 + }
199 +
200 + $file_name = isset( $file['name'] ) ? $file['name'] : '';
201 + $wp_filetype = wp_check_filetype_and_ext( $file['tmp_name'], $file_name );
202 + $type = ! empty( $wp_filetype['type'] ) ? $wp_filetype['type'] : '';
203 +
204 + if ( 'image/svg+xml' === $type ) {
205 + if ( ! current_user_can( 'upload_files' ) ) {
206 + $file['error'] = 'Invalid';
207 + return $file;
208 + }
209 +
210 + if ( ! $this->sanitize_svg( $file['tmp_name'] ) ) {
211 + $file['error'] = 'Invalid';
212 + }
213 + }
214 +
215 + return $file;
216 + }
217 +
218 + /**
219 + * Sanitize the SVG
220 + *
221 + * @param string $file Temp file path.
222 + *
223 + * @return bool|int
224 + */
225 + public function sanitize_svg( $file ) {
226 + // We can ignore the phpcs warning here as we're reading and writing to the Temp file.
227 + $dirty = file_get_contents( $file ); // phpcs:ignore
228 +
229 + // Is the SVG gzipped? If so we try and decode the string.
230 + $is_zipped = $this->is_gzipped( $dirty );
231 + if ( $is_zipped && ( ! function_exists( 'gzdecode' ) || ! function_exists( 'gzencode' ) ) ) {
232 + return false;
233 + }
234 +
235 + if ( $is_zipped ) {
236 + $dirty = gzdecode( $dirty );
237 +
238 + // If decoding fails, bail as we're not secure.
239 + if ( false === $dirty ) {
240 + return false;
241 + }
242 + }
243 +
244 + $sanitizer = new Sanitizer();
245 + $clean = $sanitizer->sanitize( $dirty );
246 +
247 + if ( false === $clean ) {
248 + return false;
249 + }
250 +
251 + // If we were gzipped, we need to re-zip.
252 + if ( $is_zipped ) {
253 + $clean = gzencode( $clean );
254 + }
255 +
256 + // We handle the write result below; silence the warning on I/O failure. Reading/writing the temp file is intended.
257 + $written = @file_put_contents( $file, $clean ); // phpcs:ignore WordPress.WP.AlternativeFunctions, WordPress.PHP.NoSilencedErrors
258 +
259 + // A failed write leaves the dirty upload in place, so report it as unsanitized.
260 + return is_string( $clean ) && strlen( $clean ) === $written;
261 + }
262 +
263 + /**
264 + * Check if the contents are gzipped
265 + *
266 + * @see http://www.gzip.org/zlib/rfc-gzip.html#member-format
267 + *
268 + * @param string $contents Content to check.
269 + *
270 + * @return bool
271 + */
272 + protected function is_gzipped( $contents ) {
273 + // phpcs:disable Generic.Strings.UnnecessaryStringConcat.Found
274 + if ( function_exists( 'mb_strpos' ) ) {
275 + return 0 === mb_strpos( $contents, "\x1f" . "\x8b" . "\x08" );
276 + } else {
277 + return 0 === strpos( $contents, "\x1f" . "\x8b" . "\x08" );
278 + }
279 + // phpcs:enable
280 + }
281 +
282 + /**
89 283 * Query the database for images and extract the alt/title to send them to the API
90 284 *
91 285 * @uses action: optml_pull_image_data
92 286 */
@@ -91,16 +285,16 @@
91 285 * @uses action: optml_pull_image_data
92 286 */
93 287 public function pull_image_data() {
94 288 // Get all image attachments that are not processed
95 - $args = [
96 - 'post_type' => 'attachment',
289 + $args = [
290 + 'post_type' => 'attachment',
97 291 'post_mime_type' => 'image',
98 292 'posts_per_page' => self::IMAGE_DATA_COLLECTED_BATCH,
99 - 'meta_query' => [
293 + 'meta_query' => [
100 294 'relation' => 'AND',
101 295 [
102 - 'key' => self::IMAGE_DATA_COLLECTED,
296 + 'key' => self::IMAGE_DATA_COLLECTED,
103 297 'compare' => 'NOT EXISTS',
104 298 ],
105 299 ],
106 300 ];
@@ -109,11 +303,11 @@
109 303 $image_data = [];
110 304
111 305 foreach ( $attachments as $attachment ) {
112 306 // Get image URL, alt, and title
113 - $image_url = wp_get_attachment_url( $attachment->ID );
114 - $image_alt = get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true );
115 - $image_title = $attachment->post_title;
307 + $image_url = wp_get_attachment_url( $attachment->ID );
308 + $image_alt = get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true );
309 + $image_title = $attachment->post_title;
116 310 $image_data[ $image_url ] = [];
117 311
118 312 if ( ! empty( $image_alt ) ) {
119 313 $image_data[ $image_url ]['alt'] = $image_alt;
@@ -132,25 +326,11 @@
132 326 if ( ! empty( $image_data ) ) {
133 327 $api = new Optml_Api();
134 328 $api->call_data_enrich_api( $image_data );
135 329 }
136 - if ( ! empty( $attachments ) ) {
137 - wp_schedule_single_event( time() + 5, 'optml_pull_image_data' );
138 - }
139 330 }
140 331
141 332 /**
142 - * Schedule the event to pull image alt/title
143 - *
144 - * @uses action: optml_pull_image_data_init
145 - */
146 - public function pull_image_data_init() {
147 - if ( ! wp_next_scheduled( 'optml_pull_image_data' ) ) {
148 - wp_schedule_single_event( time() + 5, 'optml_pull_image_data' );
149 - }
150 - }
151 -
152 - /**
153 333 * Delete the processed meta from an image when the alt text is changed
154 334 *
155 335 * @uses action: updated_post_meta, added_post_meta
156 336 */
@@ -160,8 +340,9 @@
160 340 if ( $meta_key === '_wp_attachment_image_alt' && get_post_type( $post_id ) === 'attachment' ) {
161 341 delete_post_meta( $post_id, self::IMAGE_DATA_COLLECTED );
162 342 }
163 343 }
344 +
164 345 /**
165 346 * Delete the processed meta from an image when the title is changed
166 347 *
167 348 * @uses filter: wp_insert_attachment_data
@@ -180,9 +361,19 @@
180 361 }
181 362
182 363 return $data;
183 364 }
365 +
184 366 /**
367 + * Delete the processed meta from an image when the title is changed
368 + *
369 + * @uses filter: wp_insert_attachment_data
370 + */
371 + public function legacy_detect_image_title_changes( $data, $postarr, $unsanitized_postarr ) {
372 + return $this->detect_image_title_changes( $data, $postarr, $unsanitized_postarr, true );
373 + }
374 +
375 + /**
185 376 * Init no_script setup value based on whether the user is connected or not.
186 377 */
187 378 public function init_no_script() {
188 379 if ( $this->settings->is_connected() ) {
@@ -191,14 +382,15 @@
191 382 $this->settings->update( 'no_script', 'enabled' );
192 383 }
193 384 }
194 385 }
386 +
195 387 /**
196 388 * Checks if domain has changed
197 389 */
198 390 public function check_domain_change() {
199 391 $previous_domain = get_option( 'optml_current_domain', 0 );
200 - $site_url = $this->to_domain_hash( get_home_url() );
392 + $site_url = $this->to_domain_hash( get_home_url() );
201 393
202 394 if ( $site_url !== $previous_domain ) {
203 395 update_option( 'optml_current_domain', $site_url );
204 396 if ( $previous_domain !== 0 ) {
@@ -205,8 +397,9 @@
205 397 $this->daily_sync();
206 398 }
207 399 }
208 400 }
401 +
209 402 /**
210 403 * Update the limit dimensions setting to enabled if the user is new.
211 404 */
212 405 public function update_default_settings() {
@@ -215,101 +408,65 @@
215 408 }
216 409
217 410 if ( $this->settings->is_connected() ) {
218 411 update_option( self::NEW_USER_DEFAULTS_UPDATED, 'yes' );
412 +
219 413 return;
220 414 }
221 415
222 416 $this->settings->update( 'limit_dimensions', 'enabled' );
223 417 $this->settings->update( 'lazyload', 'enabled' );
418 + $this->settings->update( 'skip_lazyload_images', '2' );
419 + $this->settings->update( 'compression_mode', 'speed_optimized' );
224 420
225 421 update_option( self::NEW_USER_DEFAULTS_UPDATED, 'yes' );
226 422 }
423 +
227 424 /**
228 - * Adds Optimole tag to admin bar
425 + * Enable limit dimensions for old users after removing the Resize option.
426 + *
427 + * @return void
229 428 */
230 - public function add_report_menu() {
231 - global $wp_admin_bar;
429 + public function update_limit_dimensions() {
430 + if ( get_option( self::OLD_USER_ENABLED_LD ) === 'yes' ) {
431 + return;
432 + }
232 433
233 - $wp_admin_bar->add_node(
234 - [
235 - 'id' => 'optml_report_script',
236 - 'href' => '#',
237 - 'title' => '<span class="ab-icon"></span>Optimole ' . __( 'debugger', 'optimole-wp' ),
238 - ]
239 - );
240 - $wp_admin_bar->add_menu(
241 - [
242 - 'id' => 'optml_status',
243 - 'title' => __( 'Troubleshoot this page', 'optimole-wp' ),
244 - 'parent' => 'optml_report_script',
245 - ]
246 - );
434 + // New users already have this enabled as we changed defaults.
435 + if ( ! $this->settings->is_connected() ) {
436 + return;
437 + }
438 +
439 + $this->settings->update( 'limit_dimensions', 'enabled' );
440 +
441 + update_option( self::OLD_USER_ENABLED_LD, 'yes' );
247 442 }
248 443
249 444 /**
250 - * Adds Optimole css to admin bar
445 + * Enable cloud sites and add the current site to the whitelist.
446 + *
447 + * @return void
251 448 */
252 - public function print_report_css() {
253 - ?>
254 - <style type="text/css">
255 - li#wp-admin-bar-optml_report_script > div :hover {
256 - cursor: pointer;
257 - color: #00b9eb !important;
258 - text-decoration: underline;
259 - }
449 + public function update_cloud_sites_default() {
450 + if ( get_option( self::OLD_USER_ENABLED_CL ) === 'yes' ) {
451 + return;
452 + }
260 453
261 - #wpadminbar #wp-admin-bar-optml_report_script .ab-icon:before {
262 - content: "\f227";
263 - top: 3px;
264 - }
454 + if ( ! $this->settings->is_connected() ) {
455 + return;
456 + }
265 457
266 - /* The Modal (background) */
267 - .optml-modal {
268 - display: none; /* Hidden by default */
269 - position: fixed; /* Stay in place */
270 - z-index: 2147483641; /* Sit on top */
271 - padding-top: 100px; /* Location of the box */
272 - left: 0;
273 - top: 0;
274 - width: 100%; /* Full width */
275 - height: 100%; /* Full height */
276 - overflow: auto; /* Enable scroll if needed */
277 - background-color: rgb(0, 0, 0); /* Fallback color */
278 - background-color: rgba(0, 0, 0, 0.4); /* Black w/ opacity */
279 - }
458 + // This is already enabled. Don't alter it.
459 + if ( $this->settings->get( 'cloud_images' ) === 'enabled' ) {
460 + update_option( self::OLD_USER_ENABLED_CL, 'yes' );
280 461
281 - /* Modal Content */
282 - .optml-modal-content {
283 - background-color: #fefefe;
284 - margin: auto;
285 - padding: 20px;
286 - border: 1px solid #888;
287 - width: 80%;
288 - }
462 + return;
463 + }
289 464
290 - /* The Close Button */
291 - .optml-close {
292 - color: #aaaaaa;
293 - float: right;
294 - font-size: 28px;
295 - font-weight: bold;
296 - }
465 + $this->settings->update( 'cloud_images', 'enabled' );
466 + $this->settings->update( 'cloud_sites', $this->settings->get_cloud_sites_whitelist_default() );
297 467
298 - .optml-modal-content ul {
299 - list-style: none;
300 - font-size: 80%;
301 - margin-top: 50px;
302 - }
303 -
304 - .optml-close:hover,
305 - .optml-close:focus {
306 - color: #000;
307 - text-decoration: none;
308 - cursor: pointer;
309 - }
310 - </style>
311 - <?php
468 + update_option( self::OLD_USER_ENABLED_CL, 'yes' );
312 469 }
313 470
314 471 /**
315 472 * Register public actions.
@@ -320,18 +477,13 @@
320 477
321 478 if ( Optml_Manager::should_ignore_image_tags() ) {
322 479 return;
323 480 }
324 - if ( ! is_admin() && $this->settings->get( 'report_script' ) === 'enabled' && current_user_can( 'manage_options' ) ) {
325 481
326 - add_action( 'wp_head', [ $this, 'print_report_css' ] );
327 - add_action( 'wp_before_admin_bar_render', [ $this, 'add_report_menu' ] );
328 - add_action( 'wp_enqueue_scripts', [ $this, 'add_diagnosis_script' ] );
329 - }
330 482 if ( ! $this->settings->use_lazyload()
331 483 || ( $this->settings->get( 'native_lazyload' ) === 'enabled'
332 - && $this->settings->get( 'video_lazyload' ) === 'disabled'
333 - && $this->settings->get( 'bg_replacer' ) === 'disabled' ) ) {
484 + && $this->settings->get( 'video_lazyload' ) === 'disabled'
485 + && $this->settings->get( 'bg_replacer' ) === 'disabled' ) ) {
334 486 return;
335 487 }
336 488 add_action( 'wp_enqueue_scripts', [ $this, 'frontend_scripts' ] );
337 489 add_action( 'wp_head', [ $this, 'inline_bootstrap_script' ] );
@@ -376,10 +528,9 @@
376 528 $default_network = ( $this->settings->get( 'network_optimization' ) === 'enabled' );
377 529 $limit_dimensions = $this->settings->get( 'limit_dimensions' ) === 'enabled';
378 530 $limit_width = $limit_dimensions ? $this->settings->get( 'limit_width' ) : 0;
379 531 $limit_height = $limit_dimensions ? $this->settings->get( 'limit_height' ) : 0;
380 - $retina_ready = $limit_dimensions ||
381 - ! ( $this->settings->get( 'retina_images' ) === 'enabled' );
532 + $retina_ready = ( $this->settings->get( 'retina_images' ) !== 'enabled' );
382 533 $scale_is_disabled = ( $this->settings->get( 'scale' ) === 'enabled' );
383 534 $native_lazy_enabled = ( $this->settings->get( 'native_lazyload' ) === 'enabled' );
384 535 $output = sprintf(
385 536 '
@@ -444,37 +595,18 @@
444 595 echo $output;
445 596 }
446 597
447 598 /**
448 - * Adds script for lazyload/js replacement.
449 - */
450 - public function add_diagnosis_script() {
451 -
452 - wp_enqueue_script( 'optml-report', OPTML_URL . 'assets/js/report_script.js' );
453 - $ignored_domains = [ 'gravatar.com', 'instagram.com', 'fbcdn' ];
454 - $report_script = [
455 - 'optmlCdn' => $this->settings->get_cdn_url(),
456 - 'restUrl' => untrailingslashit( rest_url( OPTML_NAMESPACE . '/v1' ) ) . '/check_redirects',
457 - 'nonce' => wp_create_nonce( 'wp_rest' ),
458 - 'ignoredDomains' => $ignored_domains,
459 - 'wait' => __( 'We are checking the current page for any issues with optimized images ...', 'optimole-wp' ),
460 - 'description' => __( 'Optimole page analyzer', 'optimole-wp' ),
461 - ];
462 - wp_localize_script( 'optml-report', 'reportScript', $report_script );
463 - }
464 -
465 - /**
466 599 * Add settings links in the plugin listing page.
467 600 *
468 - * @param array $links Old plugin links.
601 + * @param string[]|mixed $links Old plugin links.
469 602 *
470 - * @return array Altered links.
603 + * @return string[]|mixed Altered links.
471 604 */
472 - function add_action_links( $links ) {
605 + public function add_action_links( $links ) {
473 606 if ( ! is_array( $links ) ) {
474 607 return $links;
475 608 }
476 -
477 609 return array_merge(
478 610 $links,
479 611 [
480 612 '<a href="' . admin_url( 'admin.php?page=optimole' ) . '">' . __( 'Settings', 'optimole-wp' ) . '</a>',
@@ -487,9 +619,9 @@
487 619 *
488 620 * @return bool Should show?
489 621 */
490 622 public function should_show_notice() {
491 - if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
623 + if ( wp_doing_ajax() ) {
492 624 return false;
493 625 }
494 626
495 627 if ( is_network_admin() ) {
@@ -524,21 +656,32 @@
524 656 if ( ! $this->should_show_upgrade() ) {
525 657 return;
526 658 }
527 659 ?>
528 - <div class="notice optml-notice-optin" style="background-color: #577BF9; color:white; border: none !important; display: flex;">
529 - <div style="margin: 1% 2%;">
530 - <img src='<?php echo OPTML_URL . 'assets/img/upgrade_icon.png'; ?>'>
531 - </div>
532 - <div style="margin-top: 0.7%;">
533 - <p style="font-size: 16px !important;"> <?php printf( __( '%1$sIt seems your are close to the 5.0000 visits limit with %3$sOptiMole%4$s for this month.%2$s %5$s For a larger quota you may want to check the upgrade plans. If you exceed the quota we will need to deliver back your original, un-optimized images, which might decrease your site speed performance.', 'optimole-wp' ), '<strong>', '</strong>', '<strong>', '</strong>', '<br/><br/>', '<i>', '</i >', '<strong>', '</strong>' ); ?></p>
534 - <p style="margin: 1.5% 0;">
535 - <a href="https://optimole.com/pricing" target="_blank" style="border-radius: 4px;padding: 9px 10px;border: 2px solid #FFF;color: white;text-decoration: none;"><?php _e( 'Check upgrade plans', 'optimole-wp' ); ?>
536 - </a>
537 - <a style="padding: 2%; color: white;"
538 - href="<?php echo wp_nonce_url( add_query_arg( [ 'optml_hide_upg' => 'yes' ] ), 'hide_nonce', 'optml_nonce' ); ?>"><?php _e( 'I have already done this', 'optimole-wp' ); ?></a>
539 - </p>
540 - </div>
660 + <div class="notice optml-notice-optin"
661 + style="background-color: #577BF9; color:white; border: none !important; display: flex; align-items: center;">
662 + <div style="margin: 1% 2%;">
663 + <img style="max-width: 100px;" src='<?php echo OPTML_URL . 'assets/img/upgrade_icon.png'; ?>'>
664 + </div>
665 + <div style="display: grid; gap: 10px;">
666 + <p style="font-size: 16px !important;">
667 + <?php
668 + printf(
669 + /* translators: 1 - visits limit */
670 + __( 'You\'re nearing your %1$s-visit monthly cap on Optimole. If you exceed it, we\'ll serve original (unoptimized) images - expect slower pages.', 'optimole-wp' ),
671 + '<strong>' . number_format_i18n( 2000 ) . '</strong>'
672 + );
673 + ?>
674 + </p>
675 + <p style="margin: 1.5% 0;">
676 + <a href="<?php echo esc_url( tsdk_translate_link( self::get_upgrade_base_link() ) ); ?>"
677 + target="_blank"
678 + style="border-radius: 4px;padding: 9px 10px;border: 2px solid #FFF;color: white;text-decoration: none;"><?php _e( 'Check upgrade plans', 'optimole-wp' ); ?>
679 + </a>
680 + <a style="padding: 2%; color: white;"
681 + href="<?php echo wp_nonce_url( add_query_arg( [ 'optml_hide_upg' => 'yes' ] ), 'hide_nonce', 'optml_nonce' ); ?>"><?php _e( 'I have already done this', 'optimole-wp' ); ?></a>
682 + </p>
683 + </div>
541 684 </div>
542 685 <?php
543 686 }
544 687
@@ -548,13 +691,13 @@
548 691 * @return bool Should we show it?
549 692 */
550 693 public function should_show_upgrade() {
551 694 $current_screen = get_current_screen();
552 - if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ||
553 - is_network_admin() ||
554 - ! current_user_can( 'manage_options' ) ||
555 - ! $this->settings->is_connected() ||
556 - empty( $current_screen )
695 + if ( wp_doing_ajax() ||
696 + is_network_admin() ||
697 + ! current_user_can( 'manage_options' ) ||
698 + ! $this->settings->is_connected() ||
699 + empty( $current_screen )
557 700 ) {
558 701 return false;
559 702 }
560 703 if ( get_option( 'optml_notice_hide_upg', 'no' ) === 'yes' ) {
@@ -574,9 +717,9 @@
574 717 $visitors_left = isset( $service_data['visitors_left'] ) ? (int) $service_data['visitors_left'] : 0;
575 718 if ( $visitors_limit === 0 ) {
576 719 return false;
577 720 }
578 - if ( $visitors_left > 2000 ) {
721 + if ( $visitors_left > 300 ) {
579 722 return false;
580 723 }
581 724
582 725 return true;
@@ -582,8 +725,53 @@
582 725 return true;
583 726 }
584 727
585 728 /**
729 + * Build upgrade URL with current user's encoded email.
730 + *
731 + * @return string Upgrade URL.
732 + */
733 + public static function get_upgrade_base_link() {
734 + $base_url = 'https://optimole.com/upgrade';
735 + $base_url = tsdk_translate_link( $base_url );
736 + $email = self::get_account_email();
737 +
738 + if ( ! empty( $email ) ) {
739 + $base_url = add_query_arg( 'email', base64_encode( $email ), $base_url );
740 + }
741 +
742 + return $base_url;
743 + }
744 +
745 + /**
746 + * Get contact URL.
747 + *
748 + * @return string Contact URL.
749 + */
750 + public static function get_contact_base_link() {
751 + return tsdk_translate_link( 'https://optimole.com/contact' );
752 + }
753 +
754 + /**
755 + * Retrieve Optimole account email.
756 + *
757 + * @return string
758 + */
759 + private static function get_account_email() {
760 + $settings = new Optml_Settings();
761 + $service_data = $settings->get( 'service_data' );
762 +
763 + if ( isset( $service_data['user_email'] ) && is_string( $service_data['user_email'] ) ) {
764 + $email = sanitize_email( $service_data['user_email'] );
765 + if ( ! empty( $email ) ) {
766 + return $email;
767 + }
768 + }
769 +
770 + return '';
771 + }
772 +
773 + /**
586 774 * CSS styles for Notice.
587 775 */
588 776 public static function notice_styles() {
589 777 ?>
@@ -637,14 +825,14 @@
637 825 */
638 826 public static function notice_js( $action ) {
639 827 ?>
640 828 <script>
641 - jQuery(document).ready(function($) {
829 + jQuery(document).ready(function ($) {
642 830 // AJAX request to update the option value
643 - $( '.optml-notice-optin button.notice-dismiss' ).click(function(e) {
831 + $('.optml-notice-optin button.notice-dismiss').click(function (e) {
644 832 e.preventDefault();
645 833
646 - var notice = $(this).closest( '.optml-notice-optin' );
834 + var notice = $(this).closest('.optml-notice-optin');
647 835 var nonce = '<?php echo esc_attr( wp_create_nonce( $action ) ); ?>';
648 836
649 837 $.ajax({
650 838 url: window.ajaxurl,
@@ -674,19 +862,31 @@
674 862 self::notice_styles();
675 863 ?>
676 864 <div class="notice notice-info optml-notice-optin">
677 865 <div class="content">
678 - <img src="<?php echo OPTML_URL . '/assets/img/logo.svg'; ?>" alt="<?php echo esc_attr__( 'Logo', 'optimole-wp' ); ?>"/>
866 + <img src="<?php echo OPTML_URL . '/assets/img/logo.svg'; ?>"
867 + alt="<?php echo esc_attr__( 'Logo', 'optimole-wp' ); ?>"/>
679 868
680 869 <div>
681 870 <p class="notice-title"> <?php echo esc_html__( 'Finish setting up!', 'optimole-wp' ); ?></p>
682 - <p class="description"> <?php printf( __( 'Welcome to %1$sOptiMole%2$s, the easiest way to optimize your website images. Your users will enjoy a %3$sfaster%4$s website after you connect it with our service.', 'optimole-wp' ), '<strong>', '</strong>', '<strong>', '</strong>' ); ?></p>
871 + <p class="description">
872 + <?php
873 + printf(
874 + /* translators: 1 - opening strong tag, 2 - closing strong tag, 3 - opening strong tag, 4 - closing strong tag */
875 + __( 'Welcome to %1$sOptimole%2$s, the easiest way to optimize your website images. Your users will enjoy a %3$sfaster%4$s website after you connect it with our service.', 'optimole-wp' ),
876 + '<strong>',
877 + '</strong>',
878 + '<strong>',
879 + '</strong>'
880 + );
881 + ?>
882 + </p>
683 883 <div class="actions">
684 884 <a href="<?php echo esc_url( admin_url( 'admin.php?page=optimole' ) ); ?>"
685 - class="button button-primary button-hero"><?php _e( 'Connect to OptiMole', 'optimole-wp' ); ?>
885 + class="button button-primary button-hero"><?php _e( 'Connect to Optimole', 'optimole-wp' ); ?>
686 886 </a>
687 887 <a class="button button-secondary button-hero"
688 - href="<?php echo wp_nonce_url( add_query_arg( [ 'optml_hide_optin' => 'yes' ] ), 'hide_nonce', 'optml_nonce' ); ?>"><?php _e( 'I will do it later', 'optimole-wp' ); ?>
888 + href="<?php echo wp_nonce_url( add_query_arg( [ 'optml_hide_optin' => 'yes' ] ), 'hide_nonce', 'optml_nonce' ); ?>"><?php _e( 'I will do it later', 'optimole-wp' ); ?>
689 889 </a>
690 890 </div>
691 891 </div>
692 892 </div>
@@ -697,9 +897,9 @@
697 897 /**
698 898 * Adds conflicts notice.
699 899 */
700 900 public function add_notice_conflicts() {
701 - if ( $this->settings->is_connected() || ! $this->conflicting_plugins->should_show_notice() ) {
901 + if ( ! $this->conflicting_plugins->should_show_notice() ) {
702 902 return;
703 903 }
704 904
705 905 $plugins = $this->conflicting_plugins->get_conflicting_plugins();
@@ -716,16 +916,29 @@
716 916 self::notice_js( 'optml_dismiss_conflict_notice' );
717 917 ?>
718 918 <div class="notice notice-info optml-notice-optin has-dismiss">
719 919 <div class="content">
720 - <img src="<?php echo OPTML_URL . '/assets/img/logo.svg'; ?>" alt="<?php echo esc_attr__( 'Logo', 'optimole-wp' ); ?>"/>
920 + <img src="<?php echo OPTML_URL . '/assets/img/logo.svg'; ?>"
921 + alt="<?php echo esc_attr__( 'Logo', 'optimole-wp' ); ?>"/>
721 922
722 923 <div>
723 - <p class="notice-title"><strong><?php echo esc_html__( 'Oops... Multiple image optimization plugins active', 'optimole-wp' ); ?></strong></p>
724 - <p class="description"> <?php printf( __( 'We noticed multiple image optimization plugins active on your site, which may cause issues in Optimole. We recommend using only one image optimization plugin on your site for the best results. The following plugins may cause issues in Optimole: %2$s%1$s%3$s.', 'optimole-wp' ), $names, '<strong>', '</strong>' ); ?></p>
924 + <p class="notice-title">
925 + <strong><?php echo esc_html__( 'Oops... Multiple image optimization plugins active', 'optimole-wp' ); ?></strong>
926 + </p>
927 + <p class="description">
928 + <?php
929 + printf(
930 + /* translators: 1 - plugin name, 2 - opening bold tag, 3 - closing bold tag */
931 + __( 'We noticed multiple image optimization plugins active on your site, which may cause issues in Optimole. We recommend using only one image optimization plugin on your site for the best results. The following plugins may cause issues in Optimole: %2$s%1$s%3$s.', 'optimole-wp' ),
932 + $names,
933 + '<strong>',
934 + '</strong>'
935 + );
936 + ?>
937 + </p>
725 938 <div class="actions">
726 939 <a href="<?php echo esc_url( admin_url( 'plugins.php?optimole_conflicts' ) ); ?>"
727 - class="button button-primary button-hero"><?php _e( 'Manage Plugins', 'optimole-wp' ); ?>
940 + class="button button-primary button-hero"><?php _e( 'Manage Plugins', 'optimole-wp' ); ?>
728 941 </a>
729 942 </div>
730 943 </div>
731 944 </div>
@@ -750,11 +963,12 @@
750 963 }
751 964 if ( empty( $css ) ) {
752 965 return '';
753 966 }
754 - $css = implode( ",\n", $css ) . ' { background-image: none !important; } ';
967 + $css = implode( ",\n", $css ) . ' { background-image: none !important; }';
755 968
756 - return strip_tags( $css );
969 + $css = Lazyload::MARKER . "\n" . strip_tags( $css ) . "\n" . Lazyload::MARKER;
970 + return $css;
757 971 }
758 972
759 973 /**
760 974 * Enqueue frontend scripts.
@@ -786,12 +1000,57 @@
786 1000 }(window, document));
787 1001 ';
788 1002 wp_add_inline_script( 'optml-print', $script );
789 1003 }
1004 + if ( Optml_Manager::should_load_profiler() ) {
1005 + add_action(
1006 + 'wp_footer',
1007 + function () {
790 1008
1009 + print ( self::get_optimizer_script() );
1010 + }
1011 + );
1012 + }
1013 + print ( self::get_preload_links_placeholder() );
791 1014 }
1015 + /**
1016 + * Get the optimizer script.
1017 + *
1018 + * @param bool $placeholder Whether to return the placeholder or the actual script.
1019 + *
1020 + * @return string The optimizer script.
1021 + */
1022 + public static function get_optimizer_script( $placeholder = true ) {
792 1023
1024 + if ( $placeholder ) {
1025 + return '<script id=optmloptimizer></script>';
1026 + }
1027 +
1028 + return '<script async src="' . add_query_arg( 'v', OPTML_VERSION, OPTML_URL . 'assets/build/optimizer/optimizer.js' ) . '"></script><script id="optmloptimizer" >
1029 + var optimoleDataOptimizer = ' . wp_json_encode(
1030 + [
1031 + 'restUrl' => esc_js( untrailingslashit( rest_url( OPTML_NAMESPACE . '/v1' ) ) ),
1032 + 'nonce' => esc_js( wp_create_nonce( 'wp_rest' ) ),
1033 + 'missingDevices' => esc_js( Profile::PLACEHOLDER_MISSING ),
1034 + 'pageProfileId' => esc_js( Profile::PLACEHOLDER ),
1035 + 'pageProfileUrl' => esc_js( Profile::PLACEHOLDER_URL ),
1036 + '_t' => esc_js( Profile::PLACEHOLDER_TIME ),
1037 + 'hmac' => esc_js( Profile::PLACEHOLDER_HMAC ),
1038 + 'bgSelectors' => array_values( Optml_Lazyload_Replacer::get_background_lazyload_selectors() ),
1039 + ]
1040 + ) . ';
1041 + </script>';
1042 + }
1043 +
793 1044 /**
1045 + * Get the preload links placeholder.
1046 + *
1047 + * @return string The preload links placeholder.
1048 + */
1049 + public static function get_preload_links_placeholder(): string {
1050 + return '<script id=optmlpreload></script>';
1051 + }
1052 + /**
794 1053 * Maybe redirect to dashboard page.
795 1054 */
796 1055 public function maybe_redirect() {
797 1056 if ( isset( $_GET['optml_nonce'] ) && isset( $_GET['optml_hide_optin'] ) && $_GET['optml_hide_optin'] === 'yes' && wp_verify_nonce( $_GET['optml_nonce'], 'hide_nonce' ) ) {
@@ -805,9 +1064,9 @@
805 1064 if ( ! get_transient( 'optml_fresh_install' ) ) {
806 1065 return;
807 1066 }
808 1067
809 - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
1068 + if ( wp_doing_ajax() ) {
810 1069 return;
811 1070 }
812 1071
813 1072 delete_transient( 'optml_fresh_install' );
@@ -833,19 +1092,48 @@
833 1092 }
834 1093 if ( ! $this->settings->is_enabled() ) {
835 1094 return;
836 1095 }
837 - echo '<meta name="generator" content="Optimole ' . esc_attr( OPTML_VERSION ) . '">';
1096 +
1097 + $hints = $this->get_accept_ch_hints();
1098 + if ( empty( $hints ) ) {
1099 + return;
1100 + }
1101 + echo sprintf( '<meta http-equiv="Accept-CH" content="%s" />', esc_attr( $hints ) );
838 1102 }
839 1103
840 1104 /**
1105 + * Build the Accept-CH meta content value based on active settings.
1106 + *
1107 + * Mirrors the directives used in get_permissions_policy() so both
1108 + * the Permissions-Policy header and the Accept-CH meta stay in sync.
1109 + *
1110 + * @return string Comma-separated hint tokens, or empty string when none apply.
1111 + */
1112 + public function get_accept_ch_hints(): string {
1113 + $hints = [];
1114 +
1115 + if ( $this->settings->is_scale_enabled() ) {
1116 + $hints[] = 'Viewport-Width';
1117 + }
1118 + if ( $this->settings->get( 'network_optimization' ) === 'enabled' ) {
1119 + $hints[] = 'ECT';
1120 + }
1121 + if ( $this->settings->get( 'retina_images' ) === 'enabled' ) {
1122 + $hints[] = 'DPR';
1123 + }
1124 +
1125 + return implode( ', ', $hints );
1126 + }
1127 +
1128 + /**
841 1129 * Update daily the quota routine.
842 1130 */
843 - function daily_sync() {
1131 + public function daily_sync() {
844 1132
845 - $api_key = $this->settings->get( 'api_key' );
1133 + $api_key = $this->settings->get( 'api_key' );
846 1134 $service_data = $this->settings->get( 'service_data' );
847 - $application = '';
1135 + $application = '';
848 1136
849 1137 if ( isset( $service_data['cdn_key'] ) ) {
850 1138 $application = $service_data['cdn_key'];
851 1139 }
@@ -861,8 +1149,9 @@
861 1149 }
862 1150 if ( $data === 'disconnect' ) {
863 1151 $settings = new Optml_Settings();
864 1152 $settings->reset();
1153 +
865 1154 return;
866 1155 }
867 1156
868 1157 add_filter( 'optml_dont_trigger_settings_updated', '__return_true' );
@@ -871,10 +1160,34 @@
871 1160 if ( isset( $data['extra_visits'] ) ) {
872 1161 $this->settings->update_frontend_banner_from_remote( $data['extra_visits'] );
873 1162 }
874 1163
1164 + // Here the account got deactivated, in this case we check if the user is using offloaded images and we roll them back.
1165 + $should_revert_offloading = isset( $data['status'] ) && $data['status'] === 'inactive';
1166 +
1167 + // The user is now on a plan without offloading and the grace period is over.
1168 + if ( isset( $data['should_revert_offload'] ) && (bool) $data['should_revert_offload'] ) {
1169 + $should_revert_offloading = true;
1170 + }
1171 +
1172 + if ( $should_revert_offloading ) {
1173 + // We check if the user has images offloaded.
1174 + if ( $this->settings->get( 'offload_media' ) === 'disabled' ) {
1175 + return;
1176 + }
1177 +
1178 + $in_progress = $this->settings->get( 'offloading_status' ) !== 'disabled';
1179 + // We check if there is an in progress transfer, we stop it.
1180 + if ( $in_progress ) {
1181 + $this->settings->update( 'offloading_status', 'disabled' );
1182 + }
1183 + $this->settings->update( 'rollback_status', 'enabled' );
1184 + // We start the rollback process.
1185 + Optml_Logger::instance()->add_log( 'rollback_images', 'Account deactivated, starting rollback.' );
1186 + Optml_Media_Offload::move_images( 'rollback_images', false );
1187 + $this->settings->update( 'offload_media', 'disabled' );
1188 + }
875 1189 remove_filter( 'optml_dont_trigger_settings_updated', '__return_true' );
876 -
877 1190 }
878 1191
879 1192 /**
880 1193 * Adds cdn url for prefetch.
@@ -885,9 +1198,9 @@
885 1198 * @return array Altered hints array.
886 1199 */
887 1200 public function add_dns_prefetch( $hints, $relation_type ) {
888 1201 if ( 'dns-prefetch' !== $relation_type &&
889 - 'preconnect' !== $relation_type
1202 + 'preconnect' !== $relation_type
890 1203 ) {
891 1204 return $hints;
892 1205 }
893 1206 if ( ! $this->settings->is_connected() ) {
@@ -925,9 +1238,31 @@
925 1238 *
926 1239 * @return void
927 1240 */
928 1241 public function menu_icon_style() {
929 - echo '<style>#toplevel_page_optimole img{ max-width:22px;padding-top:6px!important;opacity:.9!important;} #toplevel_page_optimole li.wp-first-item{ display:none }</style>';
1242 + $conflicts_count = $this->get_active_notices_count();
1243 + $badge_html = '';
1244 +
1245 + if ( $conflicts_count > 0 ) {
1246 + $badge_html = sprintf(
1247 + '<style>
1248 + #toplevel_page_optimole .wp-menu-name::after {
1249 + content: "%d";
1250 + background: #d63638;
1251 + border-radius: 10px;
1252 + padding: 1.5px 1px;
1253 + font-size: 11px;
1254 + margin-left: 5px;
1255 + min-width: 18px;
1256 + display: inline-block;
1257 + text-align: center;
1258 + }
1259 + </style>',
1260 + $conflicts_count
1261 + );
1262 + }
1263 +
1264 + echo '<style>#toplevel_page_optimole img{ max-width:22px;padding-top:6px!important;opacity:.9!important;} #toplevel_page_optimole li.wp-first-item{ display:none }</style>' . $badge_html;
930 1265 }
931 1266
932 1267 /**
933 1268 * Add the settings page.
@@ -990,8 +1325,13 @@
990 1325 if ( get_option( 'optml_notice_optin', 'no' ) !== 'yes' ) {
991 1326 update_option( 'optml_notice_optin', 'yes' );
992 1327 }
993 1328 ?>
1329 + <style>
1330 + .notice:not(.optml-notice-optin) {
1331 + display: none !important;
1332 + }
1333 + </style>
994 1334 <div id="optimole-app"></div>
995 1335 <?php
996 1336 }
997 1337
@@ -1005,19 +1345,44 @@
1005 1345 $current_screen = get_current_screen();
1006 1346 if ( ! isset( $current_screen->id ) ) {
1007 1347 return;
1008 1348 }
1349 + if ( $current_screen->id === 'upload' ) {
1350 + wp_enqueue_script( OPTML_NAMESPACE . '-media-admin', OPTML_URL . 'assets/js/media.js', [], OPTML_VERSION );
1351 + wp_localize_script(
1352 + OPTML_NAMESPACE . '-media-admin',
1353 + 'optimoleMediaListing',
1354 + [
1355 + 'rest_url' => rest_url( OPTML_NAMESPACE . '/v1/move_image' ),
1356 + 'nonce' => wp_create_nonce( 'wp_rest' ),
1357 + ]
1358 + );
1009 1359
1360 + wp_register_style( 'optml_media_admin_style', false );
1361 + wp_add_inline_style(
1362 + 'optml_media_admin_style',
1363 + '
1364 + .is-loading {
1365 + pointer-events: none;
1366 + opacity: 0.5;
1367 + display: inline-block;
1368 + }
1369 + .spinner {
1370 + margin-top: 0px;
1371 + }
1372 + '
1373 + );
1374 + wp_enqueue_style( 'optml_media_admin_style' );
1375 + }
1010 1376 if ( $current_screen->id !== 'toplevel_page_optimole' ) {
1011 1377 return;
1012 1378 }
1013 1379
1014 1380 $asset_file = include OPTML_PATH . 'assets/build/dashboard/index.asset.php';
1015 -
1016 1381 wp_register_script(
1017 1382 OPTML_NAMESPACE . '-admin',
1018 1383 OPTML_URL . 'assets/build/dashboard/index.js',
1019 - $asset_file['dependencies'],
1384 + array_merge( $asset_file['dependencies'], [ 'updates' ] ),
1020 1385 $asset_file['version'],
1021 1386 true
1022 1387 );
1023 1388
@@ -1031,8 +1396,10 @@
1031 1396 'wp-components',
1032 1397 ],
1033 1398 $asset_file['version']
1034 1399 );
1400 +
1401 + do_action( 'themeisle_internal_page', OPTML_PRODUCT_SLUG, 'dashboard' );
1035 1402 }
1036 1403
1037 1404 /**
1038 1405 * Localize the dashboard app.
@@ -1046,13 +1413,16 @@
1046 1413 $is_offload_media_available = 'no';
1047 1414 if ( version_compare( $wp_version, '5.3', '>=' ) ) {
1048 1415 $is_offload_media_available = 'yes';
1049 1416 }
1050 - $api_key = $this->settings->get( 'api_key' );
1051 - $service_data = $this->settings->get( 'service_data' );
1052 - $user = get_userdata( get_current_user_id() );
1053 - $user_status = 'inactive';
1054 - $auto_connect = get_option( Optml_Settings::OPTML_USER_EMAIL, 'no' );
1417 + $api_key = $this->settings->get( 'api_key' );
1418 + $service_data = $this->settings->get( 'service_data' );
1419 + if ( ! is_array( $service_data ) ) {
1420 + $service_data = [];
1421 + }
1422 + $user = get_userdata( get_current_user_id() );
1423 + $user_status = 'inactive';
1424 + $auto_connect = get_option( Optml_Settings::OPTML_USER_EMAIL, 'no' );
1055 1425 $available_apps = isset( $service_data['available_apps'] ) ? $service_data['available_apps'] : null;
1056 1426 if ( isset( $service_data['cdn_key'] ) && $available_apps !== null ) {
1057 1427 foreach ( $service_data['available_apps'] as $app ) {
1058 1428 if ( isset( $app['key'] ) && $app['key'] === $service_data['cdn_key'] && isset( $app['status'] ) && $app['status'] === 'active' ) {
@@ -1065,9 +1435,29 @@
1065 1435 foreach ( $route_type as $route => $details ) {
1066 1436 $routes[ $route ] = OPTML_NAMESPACE . '/v1/' . $route;
1067 1437 }
1068 1438 }
1439 + // Disable this for now, we need a better way to detect it.
1440 + // $cron_disabled = apply_filters( 'optml_offload_wp_cron_disabled', defined( 'DISABLE_WP_CRON' ) && constant( 'DISABLE_WP_CRON' ) === true );
1069 1441
1442 + $language = get_user_locale();
1443 + $available_languages = [
1444 + 'de_DE' => 'de',
1445 + 'de_DE_formal' => 'de',
1446 + ];
1447 + $lang_code = isset( $available_languages[ $language ] ) ? 'de' : 'en';
1448 +
1449 + $site_settings = $this->settings->get_site_settings();
1450 + if ( ! empty( $service_data ) ) {
1451 + $service_data['domain_dns'] = $this->settings->get_cdn_url();
1452 + }
1453 + if ( isset( $service_data['renews_on'] ) ) {
1454 + $service_data['renews_on_formatted'] = date_i18n( get_option( 'date_format' ), $service_data['renews_on'] );
1455 +
1456 + }
1457 +
1458 + $user_plan = isset( $service_data['plan'] ) ? $service_data['plan'] : 'free';
1459 +
1070 1460 return [
1071 1461 'strings' => $this->get_dashboard_strings(),
1072 1462 'assets_url' => OPTML_URL . 'assets/',
1073 1463 'dam_url' => 'admin.php?page=optimole-dam',
@@ -1076,8 +1466,9 @@
1076 1466 'user_status' => $user_status,
1077 1467 'available_apps' => $available_apps,
1078 1468 'api_key' => $api_key,
1079 1469 'routes' => $routes,
1470 + 'language' => $lang_code,
1080 1471 'nonce' => wp_create_nonce( 'wp_rest' ),
1081 1472 'user_data' => $service_data,
1082 1473 'remove_latest_images' => defined( 'OPTML_REMOVE_LATEST_IMAGES' ) && constant( 'OPTML_REMOVE_LATEST_IMAGES' ) ? ( OPTML_REMOVE_LATEST_IMAGES ? 'yes' : 'no' ) : 'no',
1083 1474 'current_user' => [
@@ -1082,13 +1473,21 @@
1082 1473 'remove_latest_images' => defined( 'OPTML_REMOVE_LATEST_IMAGES' ) && constant( 'OPTML_REMOVE_LATEST_IMAGES' ) ? ( OPTML_REMOVE_LATEST_IMAGES ? 'yes' : 'no' ) : 'no',
1083 1474 'current_user' => [
1084 1475 'email' => $user->user_email,
1085 1476 ],
1086 - 'site_settings' => $this->settings->get_site_settings(),
1477 + 'site_settings' => $site_settings,
1478 + 'offload_limit' => $this->settings->get( 'offload_limit' ),
1087 1479 'home_url' => home_url(),
1480 + 'optimoleHome' => tsdk_translate_link( 'https://optimole.com/' ),
1481 + 'optimoleDashHome' => tsdk_translate_link( 'https://dashboard.optimole.com/', 'query' ),
1482 + 'optimoleDashBilling' => tsdk_translate_link( 'https://dashboard.optimole.com/settings/billing', 'query' ),
1483 + 'optimoleDashMetrics' => tsdk_translate_link( tsdk_utmify( 'https://dashboard.optimole.com/metrics', 'wp-plugin', 'shortcut' ) ),
1484 + 'offload_upgrade_url' => tsdk_translate_link( tsdk_utmify( 'https://optimole.com/pricing/', 'offload' ) ),
1485 + 'days_since_install' => round( ( time() - get_option( 'optimole_wp_install', 0 ) ) / DAY_IN_SECONDS ),
1088 1486 'is_offload_media_available' => $is_offload_media_available,
1089 1487 'auto_connect' => $auto_connect,
1090 - 'submenu_links' => [
1488 + 'cron_disabled' => false, // $cron_disabled && ! function_exists( 'as_schedule_single_action' ),
1489 + 'submenu_links' => [
1091 1490 [
1092 1491 'href' => 'admin.php?page=optimole#settings',
1093 1492 'text' => __( 'Settings', 'optimole-wp' ),
1094 1493 'hash' => '#settings',
@@ -1093,12 +1492,199 @@
1093 1492 'text' => __( 'Settings', 'optimole-wp' ),
1094 1493 'hash' => '#settings',
1095 1494 ],
1096 1495 ],
1496 + 'bf_notices' => $this->get_bf_notices( $user_plan ),
1497 + 'spc_banner' => $this->get_spc_banner(),
1498 + 'show_exceed_plan_quota_notice' => $this->should_show_exceed_quota_warning(),
1499 + 'show_free_user_with_offload_notice' => get_option( 'optml_has_offloading_enabled_on_upgrade', 'no' ),
1500 + 'report_issue_url' => add_query_arg(
1501 + [
1502 + 'utm_source' => 'plugin',
1503 + 'utm_medium' => 'wp_dashboard',
1504 + 'utm_campaign' => 'report_issue',
1505 + 'contact_website' => home_url(),
1506 + ],
1507 + self::get_contact_base_link()
1508 + ),
1509 + 'upgrade_url' => esc_url( self::get_upgrade_base_link() ),
1097 1510 ];
1098 1511 }
1099 1512
1100 1513 /**
1514 + * Get the SPC banner data.
1515 + *
1516 + * @return array|null
1517 + */
1518 + private function get_spc_banner() {
1519 + // User can't dismiss notice or install plugins.
1520 + if ( ! current_user_can( 'manage_options' ) || ! current_user_can( 'install_plugins' ) ) {
1521 + return null;
1522 + }
1523 +
1524 + // User has dismissed the notice.
1525 + if ( get_option( self::SPC_BANNER_DISMISS_KEY ) === 'yes' ) {
1526 + return null;
1527 + }
1528 +
1529 + // User has installed the pro plugin.
1530 + if ( defined( 'SPC_PRO_PATH' ) ) {
1531 + return null;
1532 + }
1533 +
1534 + // User has installed the plugin.
1535 + if ( defined( 'SPC_PATH' ) ) {
1536 + return null;
1537 + }
1538 +
1539 + return [
1540 + 'activate_url' => $this->get_spc_activate_url(),
1541 + 'status' => $this->get_spc_status(),
1542 + 'banner_dismiss_key' => self::SPC_BANNER_DISMISS_KEY,
1543 + 'i18n' => [
1544 + 'dismiss' => __( 'Dismiss', 'optimole-wp' ),
1545 + 'title' => __( 'Pair Optimole with Super Page Cache', 'optimole-wp' ),
1546 + 'byline' => __( 'Improve your Core Web Vitals with our recommended caching solution', 'optimole-wp' ),
1547 + 'features' => [
1548 + __( 'Edge Caching (with Cloudflare free plan)', 'optimole-wp' ),
1549 + __( 'Works with Optimole optimization', 'optimole-wp' ),
1550 + __( 'Lightning Speed Disk Caching', 'optimole-wp' ),
1551 + ],
1552 + 'cta' => __( 'Get Super Page Cache', 'optimole-wp' ),
1553 + 'activate' => __( 'Activate Super Page Cache', 'optimole-wp' ),
1554 + 'installing' => __( 'Installing Super Page Cache...', 'optimole-wp' ),
1555 + 'activating' => __( 'Activating Super Page Cache...', 'optimole-wp' ),
1556 + 'activated' => __( 'Super Page Cache is active!', 'optimole-wp' ),
1557 + 'error' => __( 'Something went wrong. Please refresh the page and try again.', 'optimole-wp' ),
1558 + ],
1559 + ];
1560 + }
1561 +
1562 + /**
1563 + * Get the SPC activate URL.
1564 + *
1565 + * @return string
1566 + */
1567 + private function get_spc_activate_url() {
1568 + return add_query_arg(
1569 + [
1570 + 'plugin_status' => 'all',
1571 + 'paged' => 1,
1572 + 'action' => 'activate',
1573 + 'plugin' => rawurlencode( 'wp-cloudflare-page-cache/wp-cloudflare-super-page-cache.php' ),
1574 + '_wpnonce' => wp_create_nonce( 'activate-plugin_wp-cloudflare-page-cache/wp-cloudflare-super-page-cache.php' ),
1575 + ],
1576 + admin_url( 'plugins.php' )
1577 + );
1578 + }
1579 +
1580 + /**
1581 + * Get the SPC status.
1582 + *
1583 + * @return string
1584 + */
1585 + private function get_spc_status() {
1586 + if ( is_plugin_active( 'wp-cloudflare-page-cache/wp-cloudflare-super-page-cache.php' ) ) {
1587 + return 'active';
1588 + }
1589 +
1590 + if ( file_exists( WP_PLUGIN_DIR . '/wp-cloudflare-page-cache/wp-cloudflare-super-page-cache.php' ) ) {
1591 + return 'installed';
1592 + }
1593 +
1594 + return 'not-installed';
1595 + }
1596 +
1597 + /**
1598 + * Get the black friday notices.
1599 + *
1600 + * @param non-empty-string $user_plan User plan.
1601 + *
1602 + * @return array<string, mixed> Notice data.
1603 + */
1604 + public function get_bf_notices( $user_plan ) {
1605 +
1606 + $notices = [];
1607 + $has_free_plan = 'free' === $user_plan;
1608 +
1609 + if ( ! $has_free_plan ) {
1610 + return $notices;
1611 + }
1612 +
1613 + /**
1614 + * The black friday sale period flag.
1615 + *
1616 + * @var bool $is_black_friday Whether is black friday sale period or not.
1617 + */
1618 + $is_black_friday = apply_filters( 'themeisle_sdk_is_black_friday_sale', false );
1619 +
1620 + if ( ! $is_black_friday ) {
1621 + return $notices;
1622 + }
1623 +
1624 + /**
1625 + * The current date.
1626 + *
1627 + * @var DateTime $now Current date.
1628 + */
1629 + $now = apply_filters( 'themeisle_sdk_current_date', new \DateTime( 'now' ) );
1630 + $current_year = $now->format( 'Y' );
1631 +
1632 + $black_friday_day = new \DateTime( "last Friday of November $current_year" );
1633 + $sale_start = clone $black_friday_day;
1634 + $sale_start->modify( 'monday this week' );
1635 + $sale_start->setTime( 0, 0 );
1636 +
1637 + $end = clone $sale_start;
1638 + $end->modify( '+7 days' );
1639 + $end->setTime( 23, 59, 59 );
1640 +
1641 + $promo_code = 'BFCM2525';
1642 +
1643 + $notices['sidebar'] = [
1644 + 'title' => sprintf(
1645 + '<span class="text-promo-orange">%1$s:</span> %2$s - %3$s',
1646 + __( 'Private Sale', 'optimole-wp' ),
1647 + wp_date( 'j M', $sale_start->getTimestamp() ),
1648 + wp_date( 'j M', $end->getTimestamp() )
1649 + ),
1650 + 'subtitle' => sprintf(
1651 + /* translators: %1$s is the promo code, %2$s is the discount amount ('25 off') */
1652 + __( 'Use code %1$s for %2$s on yearly plans.', 'optimole-wp' ),
1653 + '<span class="border-b border-0 border-white border-dashed text-promo-orange">' . $promo_code . '</span>',
1654 + '<span class="text-promo-orange uppercase">' . __( '25% discount', 'optimole-wp' ) . '</span>'
1655 + ),
1656 + 'cta_link' => esc_url_raw( tsdk_utmify( tsdk_translate_link( self::get_upgrade_base_link() ), 'bfcm25', 'sidebarnotice' ) ),
1657 + ];
1658 +
1659 + if ( get_option( self::BF_PROMO_DISMISS_KEY ) === 'yes' ) {
1660 + return $notices;
1661 + }
1662 +
1663 + $message = sprintf(
1664 + // translators: %1$s is the promo code, %2$s is the discount amount ('25% off')
1665 + __( 'Use coupon code %1$s for an instant %2$s on Optimole yearly plans', 'optimole-wp' ),
1666 + '<span class="border-b border-0 border-white border-dashed text-promo-orange">' . $promo_code . '</span>',
1667 + '<span class="text-promo-orange uppercase">' . __( '25% discount', 'optimole-wp' ) . '</span>'
1668 + );
1669 + $cta_link = esc_url_raw( tsdk_utmify( self::get_upgrade_base_link(), 'bfcm25', 'notice' ) );
1670 + $cta_text = __( 'Claim now', 'optimole-wp' );
1671 +
1672 + $notices['banner'] = [
1673 + /* translators: number of days left */
1674 + 'urgency' => sprintf( __( 'Hurry up! only %s left', 'optimole-wp' ), human_time_diff( $end->getTimestamp(), $now->getTimestamp() ) ),
1675 + /* translators: private sale */
1676 + 'title' => sprintf( __( 'Black Friday %s', 'optimole-wp' ), '<span class="text-promo-orange">' . __( 'private sale', 'optimole-wp' ) . '</span>' ),
1677 + 'subtitle' => $message,
1678 + 'cta_text' => $cta_text,
1679 + 'cta_link' => $cta_link,
1680 + 'dismiss_key' => self::BF_PROMO_DISMISS_KEY,
1681 + ];
1682 +
1683 + return $notices;
1684 + }
1685 +
1686 + /**
1101 1687 * Get all dashboard strings.
1102 1688 *
1103 1689 * @codeCoverageIgnore
1104 1690 * @return array
@@ -1104,113 +1690,174 @@
1104 1690 * @return array
1105 1691 */
1106 1692 private function get_dashboard_strings() {
1107 1693 return [
1108 - 'optimole' => 'Optimole',
1109 - 'version' => OPTML_VERSION,
1110 - 'terms_menu' => __( 'Terms', 'optimole-wp' ),
1111 - 'privacy_menu' => __( 'Privacy', 'optimole-wp' ),
1112 - 'testdrive_menu' => __( 'Test Optimole', 'optimole-wp' ),
1113 - 'service_details' => __( 'Image optimization service', 'optimole-wp' ),
1114 - 'connect_btn' => __( 'Connect to Optimole', 'optimole-wp' ),
1115 - 'disconnect_btn' => __( 'Disconnect', 'optimole-wp' ),
1116 - 'select' => __( 'Select', 'optimole-wp' ),
1117 - 'your_domain' => __( 'your domain', 'optimole-wp' ),
1118 - 'add_api' => __( 'Add your API Key', 'optimole-wp' ),
1119 - 'your_api_key' => __( 'Your API Key', 'optimole-wp' ),
1120 - 'looking_for_api_key' => __( 'LOOKING FOR YOUR API KEY?', 'optimole-wp' ),
1121 - 'refresh_stats_cta' => __( 'Refresh Stats', 'optimole-wp' ),
1122 - 'updating_stats_cta' => __( 'UPDATING STATS', 'optimole-wp' ),
1123 - 'api_key_placeholder' => __( 'API Key', 'optimole-wp' ),
1124 - 'account_needed_heading' => __( 'Sign-up for API key', 'optimole-wp' ),
1125 - 'invalid_key' => __( 'Invalid API Key', 'optimole-wp' ),
1126 - 'keep_connected' => __( 'Ok, keep me connected', 'optimole-wp' ),
1127 - 'cloud_library' => __( 'Cloud Library', 'optimole-wp' ),
1128 - 'disconnect_title' => __( 'You are about to disconnect from the Optimole API', 'optimole-wp' ),
1129 - 'disconnect_desc' => __(
1694 + 'optimole' => 'Optimole',
1695 + 'version' => OPTML_VERSION,
1696 + 'terms_menu' => __( 'Terms', 'optimole-wp' ),
1697 + 'privacy_menu' => __( 'Privacy', 'optimole-wp' ),
1698 + 'testdrive_menu' => __( 'Test Optimole', 'optimole-wp' ),
1699 + 'service_details' => __( 'Image optimization service', 'optimole-wp' ),
1700 + 'dashboard_title' => __( 'Image Optimization Overview', 'optimole-wp' ),
1701 + 'banner_title' => __( 'All images are automatically optimized!', 'optimole-wp' ),
1702 + 'banner_description' => __( 'Optimole is handling all your images in real-time with our CloudFront CDN (450+ locations worldwide)', 'optimole-wp' ),
1703 + 'quick_action_title' => __( 'Quick Actions', 'optimole-wp' ),
1704 + 'connect_btn' => __( 'Connect to Optimole', 'optimole-wp' ),
1705 + 'disconnect_btn' => __( 'Disconnect', 'optimole-wp' ),
1706 + 'select' => __( 'Select', 'optimole-wp' ),
1707 + 'your_domain' => __( 'your domain', 'optimole-wp' ),
1708 + 'add_api' => __( 'Add your API Key', 'optimole-wp' ),
1709 + 'your_api_key' => __( 'Your API Key', 'optimole-wp' ),
1710 + 'looking_for_api_key' => __( 'LOOKING FOR YOUR API KEY?', 'optimole-wp' ),
1711 + 'refresh_stats_cta' => __( 'Refresh Stats', 'optimole-wp' ),
1712 + 'updating_stats_cta' => __( 'UPDATING STATS', 'optimole-wp' ),
1713 + 'api_key_placeholder' => __( 'API Key', 'optimole-wp' ),
1714 + 'account_needed_heading' => __( 'Supercharge Your WordPress Images in 60 Seconds', 'optimole-wp' ),
1715 + 'account_needed_sub_heading' => __( 'Stop sacrificing image quality for page speed. Optimole delivers both.', 'optimole-wp' ),
1716 + 'account_needed_trust_badge' => __( 'TRUSTED BY 200,000+ HAPPY USERS', 'optimole-wp' ),
1717 + 'account_needed_setup_time' => __( 'Setup is instant - just click connect', 'optimole-wp' ),
1718 + 'account_needed_benefits_toggle' => __( 'See what you\'ll get', 'optimole-wp' ),
1719 + 'invalid_key' => __( 'Invalid API Key', 'optimole-wp' ),
1720 + 'keep_connected' => __( 'Ok, keep me connected', 'optimole-wp' ),
1721 + 'cloud_library' => __( 'Cloud Library', 'optimole-wp' ),
1722 + 'image_storage' => __( 'Image Storage', 'optimole-wp' ),
1723 + 'word' => __( 'word', 'optimole-wp' ),
1724 + 'path' => __( 'path', 'optimole-wp' ),
1725 + 'disconnect_title' => __( 'You are about to disconnect from the Optimole API', 'optimole-wp' ),
1726 + 'disconnect_desc' => __(
1130 1727 'Please note that disconnecting your site from the Optimole API will impact your website performance.
1131 1728 If you still want to disconnect click the button below.',
1132 1729 'optimole-wp'
1133 1730 ),
1134 - 'email_address_label' => __( 'Your email address', 'optimole-wp' ),
1135 - 'steps_connect_api_title' => __( 'Connect your account', 'optimole-wp' ),
1136 - 'register_btn' => __( 'Create & connect your account ', 'optimole-wp' ),
1137 - 'step_one_api_title' => __( 'Enter your API key.', 'optimole-wp' ),
1138 - 'optml_dashboard' => sprintf( __( 'Get it from the %1$s Optimole Dashboard%2$s.', 'optimole-wp' ), '<a style="white-space:nowrap; text-decoration: underline !important;" href="https://dashboard.optimole.com/" target="_blank"> ', '<span style="text-decoration:none; font-size:15px; margin-top:2px;" class="dashicons dashicons-external"></span></a>' ),
1139 - 'steps_connect_api_desc' => sprintf( __( 'Copy the API Key you have received via email or you can get it from %1$s Optimole dashboard%2$s. If your account has multiple domains select the one you want to use. <br/>', 'optimole-wp' ), '<a href="https://dashboard.optimole.com/" target="_blank"> ', '</a>' ),
1140 - 'api_exists' => __( 'I already have an API key.', 'optimole-wp' ),
1141 - 'back_to_register' => __( 'Register account', 'optimole-wp' ),
1142 - 'back_to_connect' => __( 'Go to previous step', 'optimole-wp' ),
1143 - 'error_register' => sprintf( __( 'Error registering account. You can try again %1$shere%2$s ', 'optimole-wp' ), '<a href="https://dashboard.optimole.com/register" target="_blank"> ', '</a>' ),
1144 - 'invalid_email' => __( 'Please use a valid email address.', 'optimole-wp' ),
1145 - 'connected' => __( 'CONNECTED', 'optimole-wp' ),
1146 - 'connecting' => __( 'CONNECTING', 'optimole-wp' ),
1147 - 'not_connected' => __( 'NOT CONNECTED', 'optimole-wp' ),
1148 - 'usage' => __( 'Monthly Usage', 'optimole-wp' ),
1149 - 'quota' => __( 'Monthly visits quota', 'optimole-wp' ),
1150 - 'logged_in_as' => __( 'LOGGED IN AS', 'optimole-wp' ),
1151 - 'private_cdn_url' => __( 'IMAGES DOMAIN', 'optimole-wp' ),
1152 - 'existing_user' => __( 'Existing user?', 'optimole-wp' ),
1153 - 'notification_message_register' => __( 'We sent you the API Key in the email. Add it below to connect to Optimole.', 'optimole-wp' ),
1154 - 'premium_support' => __( 'Access our Premium Support', 'optimole-wp' ),
1155 - 'account_needed_title' => sprintf(
1156 - __( 'In order to get access to free image optimization service you will need an API key from %s.', 'optimole-wp' ),
1157 - ' <a href="https://dashboard.optimole.com/register" target="_blank">optimole.com</a>'
1731 + 'email_address_label' => __( 'Your email address', 'optimole-wp' ),
1732 + 'steps_connect_api_title' => __( 'Connect your account', 'optimole-wp' ),
1733 + 'register_btn' => __( 'Create & connect your account', 'optimole-wp' ),
1734 + 'secure_connection' => __( 'Secure connection - your data is protected', 'optimole-wp' ),
1735 + 'step_one_api_title' => __( 'Enter your API key.', 'optimole-wp' ),
1736 + 'optml_dashboard' => sprintf(
1737 + /* translators: 1 is the opening anchor tag, 2 is the closing anchor tag */
1738 + __( 'Get it from the %1$s Optimole Dashboard%2$s.', 'optimole-wp' ),
1739 + '<a style="white-space:nowrap; text-decoration: underline !important;" href="' . esc_url( tsdk_translate_link( 'https://dashboard.optimole.com/', 'query' ) ) . '" target="_blank"> ',
1740 + '<span style="text-decoration:none; font-size:15px; margin-top:2px;" class="dashicons dashicons-external"></span></a>'
1158 1741 ),
1159 - 'account_needed_subtitle_1' => sprintf(
1160 - __( 'You will get access to our %1$simage optimization service for FREE%2$s in the limit of %3$s5k%4$s %5$svisitors%6$s per month. ', 'optimole-wp' ),
1742 + 'steps_connect_api_desc' => sprintf(
1743 + /* translators: 1 is the opening anchor tag, 2 is the closing anchor tag */
1744 + __( 'Copy the API Key you have received via email or you can get it from %1$s Optimole dashboard%2$s. If your account has multiple domains select the one you want to use. <br/>', 'optimole-wp' ),
1745 + '<a href="' . esc_url( tsdk_translate_link( 'https://dashboard.optimole.com/', 'query' ) ) . '" target="_blank"> ',
1746 + '</a>'
1747 + ),
1748 + 'api_exists' => __( 'I already have an API key.', 'optimole-wp' ),
1749 + 'back_to_register' => __( 'Register account', 'optimole-wp' ),
1750 + 'back_to_connect' => __( 'Go to previous step', 'optimole-wp' ),
1751 + /* translators: 1 is starting anchor tag, 2 is ending anchor tag */
1752 + 'error_register' => sprintf( __( 'Error registering account. You can try again %1$shere%2$s', 'optimole-wp' ), '<a href="' . esc_url( tsdk_translate_link( 'https://dashboard.optimole.com/register', 'query' ) ) . '" target="_blank"> ', '</a>' ),
1753 + 'invalid_email' => __( 'Please use a valid email address.', 'optimole-wp' ),
1754 + 'connected' => __( 'CONNECTED', 'optimole-wp' ),
1755 + 'connecting' => __( 'CONNECTING', 'optimole-wp' ),
1756 + 'not_connected' => __( 'NOT CONNECTED', 'optimole-wp' ),
1757 + 'usage' => __( 'Monthly Usage', 'optimole-wp' ),
1758 + 'quota' => __( 'Monthly visits:', 'optimole-wp' ),
1759 + 'tooltip_visits_title' => __( 'What are visits?', 'optimole-wp' ),
1760 + /* translators: 1 is the day when the visits reset, for example 1st of each month */
1761 + 'tooltip_visits_description' => __( 'Each visitor to your site is counted as a unique daily user, regardless of their actions or return visits on the same day. Your visit count resets on %s.', 'optimole-wp' ),
1762 + 'logged_in_as' => __( 'LOGGED IN AS', 'optimole-wp' ),
1763 + 'private_cdn_url' => __( 'IMAGES DOMAIN', 'optimole-wp' ),
1764 + 'existing_user' => __( 'Existing user?', 'optimole-wp' ),
1765 + 'notification_message_register' => __( 'We sent you the API Key in the email. Add it below to connect to Optimole.', 'optimole-wp' ),
1766 + 'premium_support' => __( 'Access our Premium Support', 'optimole-wp' ),
1767 + 'account_needed_title' => sprintf(
1768 + /* translators: 1 is the link to optimole.com */
1769 + __( 'Connect to Optimole\'s powerful image optimization service with a free API key from %s.', 'optimole-wp' ),
1770 + ' <a href="' . esc_url( tsdk_translate_link( 'https://dashboard.optimole.com/register', 'query' ) ) . '" target="_blank">optimole.com</a>'
1771 + ),
1772 + 'account_needed_subtitle_1' => sprintf(
1773 + /* translators: 1 is the starting bold tag, 2 is the ending bold tag, 3 is the starting bold tag, 4 is the limit number, 5 is ending bold tag, 6 is the starting anchor tag for the docs link on how we count visits, 7 is the ending anchor tag. */
1774 + __( '%1$sOptimize unlimited images%2$s for up to %3$s monthly %4$svisitors%5$s - completely FREE.', 'optimole-wp' ),
1161 1775 '<strong>',
1162 1776 '</strong>',
1163 - '<strong>',
1164 - '</strong>',
1777 + number_format_i18n( 2000 ),
1165 1778 '<a href="https://docs.optimole.com/article/1134-how-optimole-counts-the-number-of-visitors" target="_blank">',
1166 1779 '</a>'
1167 1780 ),
1168 - 'account_needed_subtitle_3' => sprintf(
1781 + 'account_needed_subtitle_3' => sprintf(
1782 + /* translators: 1 is the starting anchor tag for the docs link, 2 is the ending anchor tag. */
1169 1783 __( 'Need help? %1$sGetting Started with Optimole%2$s', 'optimole-wp' ),
1170 1784 '<a target="_blank" href="https://docs.optimole.com/article/1173-how-to-get-started-with-optimole-in-just-3-steps">',
1171 1785 '</a>'
1172 1786 ),
1173 - 'account_needed_subtitle_2' => sprintf(
1787 + 'account_needed_subtitle_2' => sprintf(
1788 + /* translators: 1 is the starting bold tag, 2 is the ending bold tag */
1174 1789 __(
1175 - 'Bonus, if you dont use a CDN, we got you covered, %1$swe will serve the images using CloudFront CDN%2$s from 450+ locations.',
1790 + '%1$sInstant global delivery%2$s with CloudFront CDN - your images load 2-3x faster worldwide from 450+ locations.',
1176 1791 'optimole-wp'
1177 1792 ),
1178 1793 '<strong>',
1179 1794 '</strong>'
1180 1795 ),
1181 - 'account_needed_footer' => __( 'Trusted by more than 100k happy users', 'optimole-wp' ),
1182 - 'account_connecting_title' => __( 'Connecting to Optimole', 'optimole-wp' ),
1183 - 'account_connecting_subtitle' => __( 'Sit tight while we connect you to the Dashboard', 'optimole-wp' ),
1184 - 'notice_just_activated' => ! $this->settings->is_connected() ?
1185 - sprintf( __( '%1$sImage optimisation is currently running.%2$s <br/> Your visitors will now view the best image for their device automatically, all served from the Optimole Cloud Service on the fly. You might see for the very first image request being redirected to the original URL while we do the optimization in the background. You can relax, we\'ll take it from here.', 'optimole-wp' ), '<strong>', '</strong>' )
1186 - : '',
1187 - 'notice_api_not_working' => __(
1796 + 'account_needed_subtitle_4' => sprintf(
1797 + /* translators: 1 is the starting bold tag, 2 is the ending bold tag */
1798 + __(
1799 + '%1$sAdaptive optimization%2$s that perfectly sizes images for every visitor\'s device and connection speed.',
1800 + 'optimole-wp'
1801 + ),
1802 + '<strong>',
1803 + '</strong>'
1804 + ),
1805 + 'account_needed_footer' => sprintf(
1806 + /* translators: 1 is the number of users using Optimole */
1807 + __( 'Trusted by more than %1$s happy users', 'optimole-wp' ),
1808 + number_format_i18n( 200000, 0 )
1809 + ),
1810 + 'account_connecting_title' => __( 'Connecting to Optimole', 'optimole-wp' ),
1811 + 'account_connecting_subtitle' => __( 'Sit tight while we connect you to the Dashboard', 'optimole-wp' ),
1812 + 'notice_just_activated' => ! $this->settings->is_connected() ?
1813 + sprintf(
1814 + /* translators: 1 starting bold tag, 2 is the ending bold tag */
1815 + __( '%1$sImage optimisation is currently running.%2$s <br/> Your visitors will now view the best image for their device automatically, all served from the Optimole Cloud Service on the fly. You might see for the very first image request being redirected to the original URL while we do the optimization in the background. You can relax, we\'ll take it from here.', 'optimole-wp' ),
1816 + '<strong>',
1817 + '</strong>'
1818 + )
1819 + : '',
1820 + 'notice_api_not_working' => __(
1188 1821 'It seems there is an issue with your WordPress configuration and the core REST API functionality is not available. This is crucial as Optimole relies on this functionality in order to work.<br/>
1189 1822 The root cause might be either a security plugin which blocks this feature or some faulty server configuration which constrain this WordPress feature.You can try to disable any of the security plugins that you use in order to see if the issue persists or ask the hosting company to further investigate.',
1190 1823 'optimole-wp'
1191 1824 ),
1192 - 'notice_disabled_account' => sprintf( __( '%3$sYour account has been disabled due to exceeding quota.%4$s All images are being redirected to the original unoptimized URL. %5$sPlease %1$supgrade%2$s to re-activate the account.', 'optimole-wp' ), '<b><a href="https://optimole.com/pricing">', '</a></b>', '<b>', '</b>', '<br>' ),
1193 - 'signup_terms' => sprintf( __( 'By signing up, you agree to our %1$sTerms of Service %3$s and %2$sPrivacy Policy %3$s.', 'optimole-wp' ), '<a href="https://optimole.com/terms/" target="_blank" >', '<a href="https://optimole.com/privacy-policy/" target="_blank">', '</a>' ),
1194 - 'dashboard_menu_item' => __( 'Dashboard', 'optimole-wp' ),
1195 - 'settings_menu_item' => __( 'Settings', 'optimole-wp' ),
1196 - 'help_menu_item' => __( 'Help', 'optimole-wp' ),
1197 - 'settings_exclusions_menu_item' => __( 'Exclusions', 'optimole-wp' ),
1198 - 'settings_resize_menu_item' => __( 'Resize', 'optimole-wp' ),
1199 - 'settings_compression_menu_item' => __( 'Compression', 'optimole-wp' ),
1200 - 'advanced_settings_menu_item' => __( 'Advanced', 'optimole-wp' ),
1201 - 'general_settings_menu_item' => __( 'General', 'optimole-wp' ),
1202 - 'lazyload_settings_menu_item' => __( 'Lazyload', 'optimole-wp' ),
1203 - 'offload_media_settings_menu_item' => __( 'Cloud Integration', 'optimole-wp' ),
1204 - 'watermarks_menu_item' => __( 'Watermark', 'optimole-wp' ),
1205 - 'conflicts_menu_item' => __( 'Possible Issues', 'optimole-wp' ),
1206 - 'conflicts' => [
1825 + 'notice_disabled_account' => sprintf(
1826 + /* translators: 1 anchor tag to pricing, 2 is the ending endin anchor tag, 3 is the bold tag start, 4 ending bold tag, 5 new line tag */
1827 + __( '%3$sYour account has been disabled due to exceeding quota.%4$s All images are being redirected to the original unoptimized URL. %5$sPlease %1$supgrade%2$s to re-activate the account.', 'optimole-wp' ),
1828 + '<b><a href="' . esc_url( tsdk_translate_link( self::get_upgrade_base_link() ) ) . '">',
1829 + '</a></b>',
1830 + '<b>',
1831 + '</b>',
1832 + '<br>'
1833 + ),
1834 + 'signup_terms' => sprintf(
1835 + /* translators: 1 is starting anchor tag to terms, 2 is starting anchor tag to privacy link and 3 is ending anchor tag. */
1836 + __( 'By signing up, you agree to our %1$sTerms of Service %3$s and %2$sPrivacy Policy %3$s.', 'optimole-wp' ),
1837 + '<a href="' . esc_url( tsdk_translate_link( 'https://optimole.com/terms/' ) ) . '" target="_blank" >',
1838 + '<a href="' . esc_url( tsdk_translate_link( 'https://optimole.com/privacy-policy/' ) ) . '" target="_blank">',
1839 + '</a>'
1840 + ),
1841 + 'dashboard_menu_item' => __( 'Dashboard', 'optimole-wp' ),
1842 + 'settings_menu_item' => __( 'Settings', 'optimole-wp' ),
1843 + 'help_menu_item' => __( 'Help', 'optimole-wp' ),
1844 + 'settings_watermark_menu_item' => __( 'Watermark', 'optimole-wp' ),
1845 + 'settings_exclusions_menu_item' => __( 'Exclusions', 'optimole-wp' ),
1846 + 'settings_resize_menu_item' => __( 'Resize', 'optimole-wp' ),
1847 + 'settings_compression_menu_item' => __( 'Compression', 'optimole-wp' ),
1848 + 'advanced_settings_menu_item' => __( 'Advanced', 'optimole-wp' ),
1849 + 'general_settings_menu_item' => __( 'General', 'optimole-wp' ),
1850 + 'lazyload_settings_menu_item' => __( 'Lazyload', 'optimole-wp' ),
1851 + 'watermarks_menu_item' => __( 'Watermark', 'optimole-wp' ),
1852 + 'conflicts_menu_item' => __( 'Possible Issues', 'optimole-wp' ),
1853 + 'conflicts' => [
1207 1854 'title' => __( 'We might have some possible conflicts with the plugins that you use. In order to benefit from Optimole\'s full potential you will need to address this issues.', 'optimole-wp' ),
1208 1855 'message' => __( 'Details', 'optimole-wp' ),
1209 1856 'conflict_close' => __( 'I\'ve done this.', 'optimole-wp' ),
1210 1857 'no_conflicts_found' => __( 'No conflicts found. We are all peachy now. 🍑', 'optimole-wp' ),
1211 1858 ],
1212 - 'upgrade' => [
1859 + 'upgrade' => [
1213 1860 'title' => __( 'Upgrade', 'optimole-wp' ),
1214 1861 'title_long' => __( 'Upgrade to Optimole Pro', 'optimole-wp' ),
1215 1862 'reason_1' => __( 'Priority & Live Chat support', 'optimole-wp' ),
1216 1863 'reason_2' => __( 'Extend visits limit', 'optimole-wp' ),
@@ -1217,9 +1864,9 @@
1217 1864 'reason_3' => __( 'Custom domain', 'optimole-wp' ),
1218 1865 'reason_4' => __( 'Site audit', 'optimole-wp' ),
1219 1866 'cta' => __( 'View plans', 'optimole-wp' ),
1220 1867 ],
1221 - 'neve' => [
1868 + 'neve' => [
1222 1869 'is_active' => defined( 'NEVE_VERSION' ) ? 'yes' : 'no',
1223 1870 'byline' => __( 'Fast, perfomance built-in WordPress theme.', 'optimole-wp' ),
1224 1871 'reason_1' => __( 'Lightweight, 25kB in page-weight.', 'optimole-wp' ),
1225 1872 'reason_2' => __( '100+ Starter Sites available.', 'optimole-wp' ),
@@ -1226,175 +1873,397 @@
1226 1873 'reason_3' => __( 'AMP/Mobile ready.', 'optimole-wp' ),
1227 1874 'reason_4' => __( 'Lots of customizations options.', 'optimole-wp' ),
1228 1875 'reason_5' => __( 'Fully compatible with Optimole.', 'optimole-wp' ),
1229 1876 ],
1230 - 'metrics' => [
1877 + 'metrics' => [
1231 1878 'metricsTitle1' => __( 'Images optimized', 'optimole-wp' ),
1232 1879 'metricsSubtitle1' => __( 'Since plugin activation', 'optimole-wp' ),
1233 - 'metricsTitle2' => __( 'Saved file size', 'optimole-wp' ),
1234 - 'metricsSubtitle2' => __( 'For the latest 10 images', 'optimole-wp' ),
1235 - 'metricsTitle3' => __( 'Average compression', 'optimole-wp' ),
1236 - 'metricsSubtitle3' => __( 'During last month', 'optimole-wp' ),
1237 - 'metricsTitle4' => __( 'Traffic', 'optimole-wp' ),
1238 - 'metricsSubtitle4' => __( 'During last month', 'optimole-wp' ),
1880 + 'metricsTitle2' => __( 'Saved File Size', 'optimole-wp' ),
1881 + 'metricsSubtitle2' => __( 'Latest 10 images', 'optimole-wp' ),
1882 + 'metricsTitle3' => __( 'Average Compression', 'optimole-wp' ),
1883 + 'metricsSubtitle3' => __( 'Average Reduction', 'optimole-wp' ),
1884 + 'metricsTitle4' => __( 'CDN Traffic', 'optimole-wp' ),
1885 + 'metricsSubtitle4' => __( 'This month', 'optimole-wp' ),
1886 + 'metricsTitle5' => __( 'Offloaded images', 'optimole-wp' ),
1887 + 'metricsSubtitle5' => __( 'Offloaded to cloud', 'optimole-wp' ),
1888 + // translators: is used as singular when the number of images is 1 for a unit label.
1889 + 'image' => __( 'image', 'optimole-wp' ),
1890 + // translators: is used as plural when the number of images is more than 1 for a unit label.
1891 + 'images' => __( 'images', 'optimole-wp' ),
1892 + 'view_analytics' => __( 'View Analytics', 'optimole-wp' ),
1893 + 'adjust_compression' => __( 'Adjust Compression', 'optimole-wp' ),
1894 + 'manage_offloading' => __( 'Manage image offloading', 'optimole-wp' ),
1239 1895 ],
1240 - 'options_strings' => [
1241 - 'best_format_title' => __( 'Enable Best Format', 'optimole-wp' ),
1242 - 'best_format_desc' => __( 'Intelligently selects the optimal image format for you. It analyzes image complexity and tries various formats, including AVIF or WebP, to achieve the smallest file size without compromising quality.', 'optimole-wp' ),
1243 - 'add_filter' => __( 'Add filter', 'optimole-wp' ),
1244 - 'add_site' => __( 'Add site', 'optimole-wp' ),
1245 - 'admin_bar_desc' => __( 'Show in the WordPress admin bar the available quota from Optimole service.', 'optimole-wp' ),
1246 - 'auto_q_title' => __( 'Auto', 'optimole-wp' ),
1247 - 'cache_desc' => __( 'Clear all cached resources(images,js,css) by Optimole from this site. Useful if you updated them and Optimole shows the old version.', 'optimole-wp' ),
1248 - 'cache_title' => __( 'Clear cached resources', 'optimole-wp' ),
1249 - 'clear_cache_notice' => __( 'Clearing cached resources will re-optimize the images and might affect for a few minutes the site performance.', 'optimole-wp' ),
1250 - 'image_size_notice' => __( 'If you have images that are no longer cropped after optimization you should add those images sizes here.', 'optimole-wp' ),
1251 - 'clear_cache_images' => __( 'Clear cached images', 'optimole-wp' ),
1252 - 'clear_cache_assets' => __( 'Clear cached CSS & JS', 'optimole-wp' ),
1253 - 'connect_step_0' => __( 'Connecting your site to the Optimole service.', 'optimole-wp' ),
1254 - 'connect_step_1' => __( 'Checking for possible conflicts.', 'optimole-wp' ),
1255 - 'connect_step_2' => __( 'Inspecting the images from your site.', 'optimole-wp' ),
1256 - 'connect_step_3' => __( 'All done, Optimole is currently optimizing your site.', 'optimole-wp' ),
1257 - 'disabled' => __( 'Disabled', 'optimole-wp' ),
1258 - 'enable_avif_title' => __( 'Enable avif conversion', 'optimole-wp' ),
1259 - 'enable_avif_desc' => __( 'Automatically convert images to avif format, if the browser supports avif', 'optimole-wp' ),
1260 - 'enable_bg_lazyload_desc' => __( 'Lazyload images used as CSS backgrounds.', 'optimole-wp' ),
1261 - 'enable_bg_lazyload_title' => __( 'Enable lazyload for background images', 'optimole-wp' ),
1262 - 'enable_video_lazyload_desc' => __( 'Lazyload iframes/videos', 'optimole-wp' ),
1263 - 'enable_video_lazyload_title' => __( 'Enable lazyload for embedded videos and iframes.', 'optimole-wp' ),
1264 - 'enable_noscript_desc' => __( 'The noscript tag offers fallback images for browsers that can\'t handle JavaScript-based lazy loading or related features. Disabling it may resolve conflicts with other plugins or configurations and decrease HTML page size.', 'optimole-wp' ),
1265 - 'enable_noscript_title' => __( 'Enable noscript tag', 'optimole-wp' ),
1266 - 'enable_gif_replace_title' => __( 'Enable Gif to Video conversion', 'optimole-wp' ),
1267 - 'enable_report_title' => __( 'Enable error diagnosis tool', 'optimole-wp' ),
1268 - 'enable_report_desc' => __( 'Provides a troubleshooting mechanism which should help you identify any possible issues with your site using Optimole.', 'optimole-wp' ),
1269 - 'enable_offload_media_title' => __( 'Enable offloading images', 'optimole-wp' ),
1270 - 'enable_offload_media_desc' => __( 'Offload your new images automatically to Optimole Cloud. You will no longer store them on your server and you can restore them back anytime.', 'optimole-wp' ),
1271 - 'enable_cloud_images_title' => __( 'Enable cloud library browsing', 'optimole-wp' ),
1272 - 'enable_cloud_images_desc' => sprintf( __( 'Grant permission for this site to access all images stored in your Optimole account. %1$s More details here%2$s', 'optimole-wp' ), '<a style="white-space: nowrap;" target=”_blank” href="https://docs.optimole.com/article/1323-cloud-library-browsing">', '<span style="font-size:15px; margin-top:2px;" class="dashicons dashicons-external"></span></a>' ),
1273 - 'enable_image_replace' => __( 'Enable image replacement', 'optimole-wp' ),
1274 - 'enable_lazyload_placeholder_desc' => __( 'Enabling this might affect the user experience in some cases, however it will reduce the number of total requests and page weight. Try it out and see how works best for you!', 'optimole-wp' ) . ' ' . sprintf( __( '%1$sMore details here%2$s.', 'optimole-wp' ), '<a target=”_blank” href="https://docs.optimole.com/article/1192-lazy-load-generic-placeholder">', '<span style="font-size:15px; margin-top:2px;" class="dashicons dashicons-external"></span></a>' ),
1275 - 'enable_lazyload_placeholder_title' => __( 'Enable generic lazyload placeholder', 'optimole-wp' ),
1276 - 'enable_network_opt_desc' => __( 'Optimole provides an option to automatically downgrade the image quality when it detects a slower network.', 'optimole-wp' ),
1277 - 'enable_network_opt_title' => __( 'Enable network based optimizations', 'optimole-wp' ),
1278 - 'enable_resize_smart_desc' => __( 'Detects the most interesting section of the image and considers it as the center of the resulting image.', 'optimole-wp' ),
1279 - 'enable_resize_smart_title' => __( 'Enable Smart Cropping', 'optimole-wp' ),
1280 - 'enable_retina_desc' => __( 'Deliver retina ready images to your visitors', 'optimole-wp' ),
1281 - 'enable_retina_title' => __( 'Enable Retina images', 'optimole-wp' ),
1282 - 'enable_limit_dimensions_desc' => __( 'This feature allows you to set a maximum width or height for images on your website, automatically resizing larger images to fit within the defined limits while maintaining the original aspect ratio.', 'optimole-wp' ),
1283 - 'enable_limit_dimensions_title' => __( 'Limit Image Dimensions with max width/height', 'optimole-wp' ),
1284 - 'enable_limit_dimensions_notice' => __( 'When you enable this feature to define a max width or height for image resizing, please note that DPR (retina) images will be disabled. This is done to ensure consistency in image dimensions across your website. Although this may result in slightly lower image quality for high-resolution displays, it will help maintain uniform image sizes, improving your website\'s overall layout and potentially boosting performance. ', 'optimole-wp' ),
1285 - 'enable_badge_title' => __( 'Enable Optimole badge', 'optimole-wp' ),
1286 - 'enable_badge_description' => sprintf( __( 'Get 20.000 more visits for free by enabling the Optimole badge on your websites. %1$sMore details here%2$s.', 'optimole-wp' ), '<a class="inline-block" target=”_blank” href="https://docs.optimole.com/article/1173-how-to-get-started-with-optimole-in-just-3-steps#settings">', '<span style="font-size:15px; margin-top:2px;" class="dashicons dashicons-external"></span></a>' ),
1287 - 'image_sizes_title' => __( 'Your cropped image sizes', 'optimole-wp' ),
1288 - 'enabled' => __( 'Enabled', 'optimole-wp' ),
1289 - 'exclude_class_desc' => sprintf( __( '%1$sImage tag%2$s contains class', 'optimole-wp' ), '<strong>', '</strong>' ),
1290 - 'exclude_ext_desc' => sprintf( __( '%1$sImage extension%2$s is', 'optimole-wp' ), '<strong>', '</strong>' ),
1291 - 'exclude_filename_desc' => sprintf( __( '%1$sImage filename%2$s contains', 'optimole-wp' ), '<strong>', '</strong>' ),
1292 - 'exclude_title_lazyload' => __( 'Don\'t lazyload images if', 'optimole-wp' ),
1293 - 'exclude_title_optimize' => __( 'Don\'t optimize images if', 'optimole-wp' ),
1294 - 'exclude_url_desc' => sprintf( __( '%1$sPage url%2$s contains', 'optimole-wp' ), '<strong>', '</strong>' ),
1295 - 'name' => sprintf( __( '%1$sName: %2$s', 'optimole-wp' ), '<strong>', '</strong>' ),
1296 - 'cropped' => __( 'cropped', 'optimole-wp' ),
1297 - 'exclude_url_match_desc' => sprintf( __( '%1$sPage url%2$s matches', 'optimole-wp' ), '<strong>', '</strong>' ),
1298 - 'exclude_first' => __( 'Exclude first', 'optimole-wp' ),
1299 - 'images' => __( 'images', 'optimole-wp' ),
1300 - 'exclude_first_images_title' => __( 'Exclude the first X images from lazyload', 'optimole-wp' ),
1301 - 'exclude_first_images_desc' => __( 'Exclude the first <number> images from lazyload on every page to avoid lazy load on above the fold images. Use 0 to disable this.', 'optimole-wp' ),
1302 - 'filter_class' => __( 'Image class', 'optimole-wp' ),
1303 - 'filter_ext' => __( 'Image extension', 'optimole-wp' ),
1304 - 'filter_filename' => __( 'Image filename', 'optimole-wp' ),
1305 - 'filter_operator_contains' => __( 'contains', 'optimole-wp' ),
1306 - 'filter_operator_matches' => __( 'matches', 'optimole-wp' ),
1307 - 'filter_operator_is' => __( 'is', 'optimole-wp' ),
1308 - 'filter_url' => __( 'Page URL', 'optimole-wp' ),
1309 - 'filter_helper' => __( 'For homepage use `home` keyword.', 'optimole-wp' ),
1310 - 'gif_replacer_desc' => __( 'Automatically convert GIF images to Video files(MP4 and WebM)', 'optimole-wp' ),
1311 - 'height_field' => __( 'Height', 'optimole-wp' ),
1312 - 'add_image_size_button' => __( 'Add size', 'optimole-wp' ),
1313 - 'add_image_size_desc' => __( 'Add a new crop image size', 'optimole-wp' ),
1314 - 'here' => __( ' here.', 'optimole-wp' ),
1315 - 'hide' => __( 'Hide', 'optimole-wp' ),
1316 - 'high_q_title' => __( 'High', 'optimole-wp' ),
1317 - 'image_1_label' => __( 'Original', 'optimole-wp' ),
1318 - 'image_2_label' => __( 'Optimized', 'optimole-wp' ),
1319 - 'lazyload_desc' => __( 'We will generate images size based on your visitor\'s screen using javascript and render them without blocking the page execution via lazyload .', 'optimole-wp' ),
1320 - 'filter_length_error' => __( 'The filter should be at least 3 characters long.', 'optimole-wp' ),
1321 - 'scale_desc' => __( 'When this option is off, we disable the automatic scaling of images on lazyload.', 'optimole-wp' ),
1322 - 'low_q_title' => __( 'Low', 'optimole-wp' ),
1323 - 'medium_q_title' => __( 'Medium', 'optimole-wp' ),
1324 - 'no_images_found' => __( 'You dont have any images in your Media Library. Add one and check how the Optimole will perform.', 'optimole-wp' ),
1325 - 'native_desc' => __( 'Use browser native lazyload. When using browser native lazyload the auto scale feature is disabled', 'optimole-wp' ),
1326 - 'option_saved' => __( 'Option saved.', 'optimole-wp' ),
1327 - 'ml_quality_desc' => 'Optimole ML algorithms will predict the right quality for your image in order to get the smallest possible size with minimum perceived quality losses. Turning this off will allow you to control manually the quality.',
1328 - 'quality_desc' => __( 'Lower image quality might not always be perceived by users and would result in a boost of your loading speed by lowering the page size. Try experimenting with the setting, then click the View sample image link to see what option works best for you.', 'optimole-wp' ),
1329 - 'quality_selected_value' => __( 'Selected value', 'optimole-wp' ),
1330 - 'quality_slider_desc' => __( 'See one sample image which will help you choose the right quality of the compression.', 'optimole-wp' ),
1331 - 'quality_title' => __( 'Enable Auto Quality powered by ML(Machine Learning)', 'optimole-wp' ),
1332 - 'strip_meta_title' => __( 'Strip Image Metadata', 'optimole-wp' ),
1333 - 'strip_meta_desc' => __( 'When enabled, Optimole will strip the metadata (EXIF, IPTC, etc.) from output images.', 'optimole-wp' ),
1334 - 'replacer_desc' => __( 'Replace all the image urls from your website with the ones optimized by Optimole.', 'optimole-wp' ),
1335 - 'sample_image_loading' => __( 'Loading a sample image. ', 'optimole-wp' ),
1336 - 'save_changes' => __( 'Save changes', 'optimole-wp' ),
1337 - 'show' => __( 'Show', 'optimole-wp' ),
1338 - 'selected_sites_title' => __( 'CURRENTLY SHOWING IMAGES FROM', 'optimole-wp' ),
1339 - 'selected_sites_desc' => __( 'Site: ', 'optimole-wp' ),
1340 - 'selected_all_sites_desc' => __( 'Currently viewing images from all sites ', 'optimole-wp' ),
1341 - 'select_all_sites_desc' => __( 'View images from all sites ', 'optimole-wp' ),
1342 - 'size_desc' => __( 'We resize all images with sizes greater than the values defined here. Changing this option is not recommended unless large images are not being processed correctly. This does NOT affect the scaling of images on the frontend.', 'optimole-wp' ),
1343 - 'size_title' => __( 'Resize large images original source.', 'optimole-wp' ),
1344 - 'select_site' => __( 'Select a website', 'optimole-wp' ),
1345 - 'cloud_site_title' => __( 'Show images only from these sites: ', 'optimole-wp' ),
1346 - 'cloud_site_desc' => __( 'Only the images from the selected sites will be displayed on this site. Defaults to all.', 'optimole-wp' ),
1347 - 'toggle_ab_item' => __( 'Admin bar status', 'optimole-wp' ),
1348 - 'toggle_lazyload' => __( 'Scale images & Lazy load', 'optimole-wp' ),
1349 - 'toggle_scale' => __( 'Scale Images', 'optimole-wp' ),
1350 - 'toggle_native' => __( 'Use native lazyload', 'optimole-wp' ),
1351 - 'on_toggle' => __( 'On', 'optimole-wp' ),
1352 - 'off_toggle' => __( 'Off', 'optimole-wp' ),
1353 - 'view_sample_image' => __( 'View sample image', 'optimole-wp' ),
1354 - 'watch_desc_lazyload' => __( 'You can add each CSS selector on a new line or separated by comma(,).', 'optimole-wp' ),
1355 - 'watch_title_lazyload' => __( 'Lazyload background images for selectors:', 'optimole-wp' ),
1356 - 'width_field' => __( 'Width', 'optimole-wp' ),
1357 - 'crop' => __( 'crop', 'optimole-wp' ),
1358 - 'toggle_cdn' => __( 'Serve CSS & JS through Optimole', 'optimole-wp' ),
1359 - 'cdn_desc' => __( 'Useful when you have images into CSS/JS files. Optimole will optimize the images from them and serve the CSS/JS through the CDN.', 'optimole-wp' ),
1360 - 'enable_css_minify_title' => __( 'Minify CSS files', 'optimole-wp' ),
1361 - 'css_minify_desc' => __( 'Once Optimole will serve your CSS files, it will also minify the files and serve them via CDN.', 'optimole-wp' ),
1362 - 'enable_js_minify_title' => __( 'Minify JS files', 'optimole-wp' ),
1363 - 'js_minify_desc' => __( 'Once Optimole will serve your JS files, it will also minify the files and serve them via CDN.', 'optimole-wp' ),
1364 - 'sync_title' => __( 'Offload existing images', 'optimole-wp' ),
1365 - 'rollback_title' => __( 'Restore offloaded images', 'optimole-wp' ),
1366 - 'sync_desc' => __( 'Right now all the new images uploaded to your site are moved automatically to Optimole Cloud. In order to offload the existing ones, please click Sync images and wait for the process to finish. You can rollback anytime.', 'optimole-wp' ),
1367 - 'rollback_desc' => __( 'Pull all the offloaded images to Optimole Cloud back to your server.', 'optimole-wp' ),
1368 - 'sync_media' => __( 'Sync images', 'optimole-wp' ),
1369 - 'rollback_media' => __( 'Rollback images', 'optimole-wp' ),
1370 - 'sync_media_progress' => __( 'Moving your images to Optimole...', 'optimole-wp' ),
1371 - 'estimated_time' => __( 'Estimated time remaining', 'optimole-wp' ),
1372 - 'calculating_estimated_time' => __( 'We are currently calculating the estimated time for this job...', 'optimole-wp' ),
1373 - 'images_processing' => __( 'We are currently processing your images in the background. Leaving the page won\'t stop the process.', 'optimole-wp' ),
1374 - 'active_exclusions' => __( 'Active Exclusions', 'optimole-wp' ),
1375 - 'minutes' => __( 'minutes', 'optimole-wp' ),
1376 - 'stop' => __( 'Stop', 'optimole-wp' ),
1377 - 'rollback_media_progress' => __( 'Moving images into your media library...', 'optimole-wp' ),
1378 - 'rollback_media_error' => __( 'An unexpected error occured while pulling the offloaded back to your site', 'optimole-wp' ),
1379 - 'rollback_media_error_desc' => __( 'You can try again to pull back the rest of the images.', 'optimole-wp' ),
1380 - 'remove_notice' => __( 'Remove notice', 'optimole-wp' ),
1381 - 'sync_media_error' => __( 'An unexpected error occured while offloading all existing images from your site to Optimole ', 'optimole-wp' ),
1382 - 'sync_media_link' => __( 'The selected images have been offloaded to our servers, you can check them', 'optimole-wp' ),
1383 - 'rollback_media_link' => __( 'The selected images have been restored to your server, you can check them', 'optimole-wp' ),
1384 - 'sync_media_error_desc' => __( 'You can try again to offload the rest of the images to Optimole.', 'optimole-wp' ),
1385 - 'offload_disable_warning_title' => __( 'Important! Please read carefully', 'optimole-wp' ),
1386 - 'offload_disable_warning_desc' => __( 'If you disable this option you will not be able to see the images in the media library without restoring the images first, do you want to restore the images to your site upon disabling the option ?', 'optimole-wp' ),
1387 - 'offload_enable_info_desc' => sprintf( __( 'You are not required to use the offload functionality for the plugin to work, use it if you want to save on hosting space. %1$s More details%2$s', 'optimole-wp' ), '<a style="white-space: nowrap;" target=”_blank” href="https://docs.optimole.com/article/1323-cloud-library-browsing">', '<span style="font-size:15px; margin-top:2px;" class="dashicons dashicons-external"></span></a>' ),
1388 - 'offload_conflicts_part_1' => __( 'We have detected the following plugins that conflict with the offload features: ', 'optimole-wp' ),
1389 - 'offload_conflicts_part_2' => __( 'Please disable those plugins temporarily in order for Optimole to rollback the images to your site.', 'optimole-wp' ),
1390 - 'select' => __( 'Please select one ...', 'optimole-wp' ),
1391 - 'yes' => __( 'Restore images after disabling', 'optimole-wp' ),
1392 - 'no' => __( 'Do not restore images after disabling', 'optimole-wp' ),
1393 - 'lazyload_placeholder_color' => __( 'Placeholder Color', 'optimole-wp' ),
1394 - 'clear' => __( 'Clear', 'optimole-wp' ),
1896 + 'quick_actions' => [
1897 + 'speed_test_title' => __( 'Test Your Site Speed', 'optimole-wp' ),
1898 + 'speed_test_desc' => __( 'Run speed test', 'optimole-wp' ),
1899 + 'speed_test_link' => add_query_arg( 'url', get_site_url(), 'https://pagespeed.web.dev/analysis' ),
1900 + 'clear_cache_images' => __( 'Clear Cached Images', 'optimole-wp' ),
1901 + 'clear_cache' => __( 'Clear cache', 'optimole-wp' ),
1902 + 'offload_images' => __( 'Enable Offload Images', 'optimole-wp' ),
1903 + 'offload_images_desc' => __( 'Free up space on your server', 'optimole-wp' ),
1904 + 'advance_settings' => __( 'Advanced Settings', 'optimole-wp' ),
1905 + 'configure_settings' => __( 'Configure settings', 'optimole-wp' ),
1395 1906 ],
1396 - 'help' => [
1907 + 'options_strings' => [
1908 + 'watermark_media_desc' => __( 'Protect your brand by adding a watermark to your images. Configure placement, opacity, and rules directly in your Optimole Dashboard.', 'optimole-wp' ),
1909 + 'watermark_media_title' => __( 'Watermarks', 'optimole-wp' ),
1910 + 'learn_more' => __( 'Learn more', 'optimole-wp' ),
1911 + 'open_optimole_dashboard' => __( 'Open Optimole Dashboard', 'optimole-wp' ),
1912 + 'watermark_footer' => __( 'Watermark rules and exclusions are fully managed in your Optimole Dashboard.', 'optimole-wp' ),
1913 + 'watermark_info_1' => __( 'Choose from multiple watermark positions and set opacity.', 'optimole-wp' ),
1914 + 'watermark_info_2' => __( 'Set different watermarks for different image sizes.', 'optimole-wp' ),
1915 + 'watermark_info_3' => __( 'Create rule-based targeting by filename, page URL, class, and more.', 'optimole-wp' ),
1916 + 'compression_mode' => __( 'Compression Mode', 'optimole-wp' ),
1917 + 'compression_mode_speed_optimized' => __( 'Speed Optimized', 'optimole-wp' ),
1918 + 'compression_mode_quality_optimized' => __( 'Quality Optimized', 'optimole-wp' ),
1919 + 'compression_mode_custom' => __( 'Custom', 'optimole-wp' ),
1920 + 'compression_mode_speed_optimized_desc' => __( 'Prioritizes faster loading and smaller image sizes by applying a balanced level of lossy compression. This setting reduces file size significantly without severely degrading visual quality.', 'optimole-wp' ),
1921 + 'compression_mode_quality_optimized_desc' => __( 'Delivers high-quality images by applying lossless or near-lossless optimization. Ensures images retain their sharpness and details while still benefiting from moderate file size reduction.', 'optimole-wp' ),
1922 + 'compression_mode_custom_desc' => __( 'Customize each setting individually for complete control over image compression.', 'optimole-wp' ),
1923 +
1924 + 'best_format_title' => __( 'Automatic Best Image Format Selection', 'optimole-wp' ),
1925 + 'best_format_desc' => sprintf(
1926 + /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */
1927 + __( 'When enabled, Optimole chooses the best format for your images, balancing quality with speed. It tries options like AVIF and WebP to keep visuals sharp and pages fast, though uncached images may take a bit longer to process. %1$sLearn more%2$s.', 'optimole-wp' ),
1928 + '<a class="inline-block text-purple-gray underline" target=”_blank” href="https://docs.optimole.com/article/1942-best-format">',
1929 + '</a>'
1930 + ),
1931 + 'add_filter' => __( 'Add filter', 'optimole-wp' ),
1932 + 'add_site' => __( 'Add site', 'optimole-wp' ),
1933 + 'admin_bar_desc' => __( 'Show in the WordPress admin bar the available quota from Optimole service.', 'optimole-wp' ),
1934 + 'auto_q_title' => __( 'Auto', 'optimole-wp' ),
1935 + 'cache_desc' => sprintf(
1936 + /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */
1937 + __( 'Clears all Optimole’s cached resources (images, JS, CSS). Useful if you made changes to your images and don\'t see those applying on your site. %1$sLearn more%2$s', 'optimole-wp' ),
1938 + '<a class="inline-block text-purple-gray underline" target=”_blank” href="https://docs.optimole.com/article/1941-clear-cached-resources">',
1939 + '</a>'
1940 + ),
1941 + 'cache_title' => __( 'Clear Cached Resources', 'optimole-wp' ),
1942 + 'clear_cache_notice' => __( 'Clearing cached resources will re-optimize the images and might affect the site performance for a few minutes.', 'optimole-wp' ),
1943 + 'image_size_notice' => sprintf(
1944 + /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */
1945 + __( 'Use this option if you notice images are not cropped correctly after using Optimole. Add the affected image sizes here to automatically adjust and correct their cropping for optimal display. %1$sLearn more%2$s', 'optimole-wp' ),
1946 + '<a class="inline-block text-purple-gray underline" target=”_blank” href="https://docs.optimole.com/article/1947-add-new-image-crop-size">',
1947 + '</a>'
1948 + ),
1949 + 'clear_cache_images' => __( 'Clear cached images', 'optimole-wp' ),
1950 + 'clear_cache_assets' => __( 'Clear cached CSS & JS', 'optimole-wp' ),
1951 + 'connect_step_0' => __( 'Connecting your site to the Optimole service.', 'optimole-wp' ),
1952 + 'connect_step_1' => __( 'Checking for possible conflicts.', 'optimole-wp' ),
1953 + 'connect_step_2' => __( 'Inspecting the images from your site.', 'optimole-wp' ),
1954 + 'connect_step_3' => __( 'All done, Optimole is currently optimizing your site.', 'optimole-wp' ),
1955 + 'disabled' => __( 'Disabled', 'optimole-wp' ),
1956 + 'enable_avif_title' => __( 'AVIF Image Support', 'optimole-wp' ),
1957 + 'enable_avif_desc' => sprintf(
1958 + /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */
1959 + __( 'Enable this to automatically convert images to the AVIF format on browsers that support it. This format provides quality images with reduced file sizes, and faster webpage loading. %1$sLearn more%2$s', 'optimole-wp' ),
1960 + '<a class="inline-block text-purple-gray underline" target=”_blank” href="https://docs.optimole.com/article/1943-avif-conversion">',
1961 + '</a>'
1962 + ),
1963 + 'enable_bg_lazyload_desc' => sprintf(
1964 + /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */
1965 + __( 'Apply lazy loading to CSS background images. The toggle below enables it globally. The selector list is optional and only needed to extend coverage if certain elements are missed. %1$sLearn more%2$s', 'optimole-wp' ),
1966 + '<a class="inline-block text-purple-gray underline" target="_blank" href="https://docs.optimole.com/article/1169-how-to-enable-the-background-lazyload-feature-for-certain-background-images">',
1967 + '</a>'
1968 + ),
1969 + 'enable_bg_lazyload_title' => __( 'CSS Background Lazy Load', 'optimole-wp' ),
1970 + 'enable_video_lazyload_desc' => __( 'Lazy load embedded videos and iframe content', 'optimole-wp' ),
1971 + 'enable_video_lazyload_title' => __( 'Video & iframes', 'optimole-wp' ),
1972 + 'enable_noscript_desc' => sprintf(
1973 + /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */
1974 + __( 'Enables fallback images for browsers that can\'t handle JavaScript-based lazy loading or related features. Disabling it may resolve conflicts with other plugins or configurations and decrease HTML page size. %1$sLearn more%2$s', 'optimole-wp' ),
1975 + '<a class="inline-block text-purple-gray underline" target=”_blank” href="https://docs.optimole.com/article/1959-noscript-tag">',
1976 + '</a>'
1977 + ),
1978 + // translators: %s is the name of the html tag (e.g: <noscript> );
1979 + 'enable_noscript_title' => sprintf( __( 'Enable %s fallback', 'optimole-wp' ), '<custom_component/>' ),
1980 + 'enable_gif_replace_title' => __( 'GIF to Video Conversion', 'optimole-wp' ),
1981 + 'enable_offload_media_title' => __( 'Store Your Images in Optimole Cloud', 'optimole-wp' ),
1982 + 'enable_offload_media_desc' => sprintf( /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */ __( 'Free up space on your server by transferring your images to Optimole Cloud; you can transfer them back anytime. Once moved, the images will still be visible in the Media Library and can be used as before. %1$sLearn more%2$s', 'optimole-wp' ), '<a class="inline-block text-purple-gray underline" target=”_blank” href="https://docs.optimole.com/article/1967-store-your-images-in-optimole-cloud">', '</a>' ),
1983 + 'enable_cloud_images_title' => __( 'Unified Image Access', 'optimole-wp' ),
1984 + 'enable_cloud_images_desc' => sprintf(
1985 + /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */
1986 + __( 'Enable this setting to access all your Optimole images, including those from other websites connected to your Optimole account, directly on this site. They will be available for browsing in the Cloud Library tab. %1$sLearn more%2$s', 'optimole-wp' ),
1987 + '<a class="inline-block text-purple-gray underline" target=”_blank” href="https://docs.optimole.com/article/1323-cloud-library-browsing">',
1988 + '</a>'
1989 + ),
1990 + 'enable_image_replace' => __( 'Enable Optimole Image Handling', 'optimole-wp' ),
1991 + 'enable_lazyload_placeholder_desc' => sprintf(
1992 + /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */
1993 + __( 'Enable this to use a generic transparent placeholder instead of the blurry images during lazy loading. %1$sLearn more%2$s', 'optimole-wp' ),
1994 + '<a class="inline-block underline text-white" target=”_blank” href="https://docs.optimole.com/article/1192-lazy-load-generic-placeholder">',
1995 + '</a>'
1996 + ),
1997 +
1998 + 'lazyload_behaviour_title' => __( 'Loading Method', 'optimole-wp' ),
1999 + 'lazyload_behaviour_desc' => sprintf(
2000 + /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */
2001 + __( 'Choose how Optimole will handle lazy loading for images on your website. %1$sLearn more%2$s', 'optimole-wp' ),
2002 + '<a class="inline-block text-purple-gray underline" target=”_blank” href="https://docs.optimole.com/article/1958-lazy-loading-behaviour">',
2003 + '</a>'
2004 + ),
2005 + 'lazyload_behaviour_all' => __( 'Lazy Load All Images', 'optimole-wp' ),
2006 + 'lazyload_behaviour_all_desc' => __( 'All images will use lazy loading regardless of position.', 'optimole-wp' ),
2007 + 'lazyload_behaviour_viewport' => __( 'Skip images above the fold', 'optimole-wp' ),
2008 + 'lazyload_behaviour_viewport_desc' => __( 'Automatically detects and immediately loads images visible in the initial viewport. Detection is done with a lightweight client-side script that identifies what\'s visible on each user\'s screen. All other images will lazy load.', 'optimole-wp' ),
2009 + 'lazyload_behaviour_fixed' => __( 'Skip lazy loading for first images', 'optimole-wp' ),
2010 + 'lazyload_behaviour_fixed_desc' => __( 'Indicate how many images at the top of each page should bypass lazy loading, ensuring they\'re instantly visible.', 'optimole-wp' ),
2011 + 'enable_lazyload_placeholder_title' => __( 'Enable generic placeholder color', 'optimole-wp' ),
2012 + 'enable_network_opt_desc' => sprintf(
2013 + /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */
2014 + __( 'When enabled, Optimole will automatically reduce the image quality when it detects a slower network, making your images load faster on low-speed internet connections. %1$sLearn more%2$s', 'optimole-wp' ),
2015 + '<a class="inline-block text-purple-gray underline" target=”_blank” href="https://docs.optimole.com/article/1945-network-based-optimizations">',
2016 + '</a>'
2017 + ),
2018 + 'enable_network_opt_title' => __( 'Network-based Optimizations', 'optimole-wp' ),
2019 + 'enable_resize_smart_desc' => sprintf(
2020 + /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */
2021 + __( 'When enabled, Optimole automatically detects the most interesting or important part of your images. When pictures are resized or cropped, this feature ensures the focus stays on the most interesting part of the picture. %1$sLearn more%2$s', 'optimole-wp' ),
2022 + '<a class="inline-block text-purple-gray underline" target=”_blank” href="https://docs.optimole.com/article/1871-how-to-use-the-smart-cropping-in-optimole">',
2023 + '</a>'
2024 + ),
2025 + 'enable_resize_smart_title' => __( 'Smart Cropping', 'optimole-wp' ),
2026 + 'enable_retina_desc' => sprintf(
2027 + /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */
2028 + __( 'Optimizes images for Retina (high-DPI) screens for sharper results. Always enabled for images under 150px wide. %1$sLearn more%2$s', 'optimole-wp' ),
2029 + '<a class="inline-block text-purple-gray underline" target=”_blank” href="https://docs.optimole.com/article/1391-what-is-a-retina-image">',
2030 + '</a>'
2031 + ),
2032 + 'enable_retina_title' => __( 'Retina Quality', 'optimole-wp' ),
2033 + 'enable_limit_dimensions_desc' => sprintf(
2034 + /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */
2035 + __( 'Define the max width or height limits for images on your website. Larger images will be automatically adjusted to fit within these parameters while preserving their original aspect ratio. %1$sLearn more%2$s', 'optimole-wp' ),
2036 + '<a class="inline-block text-purple-gray underline" target=”_blank” href="https://docs.optimole.com/article/1946-limit-image-sizes">',
2037 + '</a>'
2038 + ),
2039 + 'enable_limit_dimensions_title' => __( 'Limit Image Sizes', 'optimole-wp' ),
2040 + 'enable_limit_dimensions_notice' => __( 'When you enable this feature to define a max width or height for image resizing, please note that DPR (retina) images will be disabled. This is done to ensure consistency in image dimensions across your website. Although this may result in slightly lower image quality for high-resolution displays, it will help maintain uniform image sizes, improving your website\'s overall layout and potentially boosting performance.', 'optimole-wp' ),
2041 + 'enable_badge_title' => __( 'Enable Optimole Badge', 'optimole-wp' ),
2042 + 'enable_badge_settings' => __( 'Badge settings', 'optimole-wp' ),
2043 + 'enable_badge_show_icon' => __( 'Show only Optimole icon', 'optimole-wp' ),
2044 + 'enable_badge_position' => __( 'Badge Position', 'optimole-wp' ),
2045 + 'badge_position_text_1' => __( 'Left', 'optimole-wp' ),
2046 + 'badge_position_text_2' => __( 'Right', 'optimole-wp' ),
2047 + 'enable_badge_description' => sprintf(
2048 + /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */
2049 + __( 'Get 20.000 more visits for free by enabling the Optimole badge on your websites. %1$sLearn more%2$s', 'optimole-wp' ),
2050 + '<a class="inline-block text-purple-gray underline" target=”_blank” href="https://docs.optimole.com/article/1940-optimole-badge">',
2051 + '</a>'
2052 + ),
2053 + 'image_sizes_title' => __( 'Your cropped image sizes', 'optimole-wp' ),
2054 + 'enabled' => __( 'Enabled', 'optimole-wp' ),
2055 + 'exclude_class_desc' => sprintf(
2056 + /* translators: 1 is the starting bold tag, 2 is the ending bold tag */
2057 + __( '%1$sImage tag%2$s contains class', 'optimole-wp' ),
2058 + '<strong>',
2059 + '</strong>'
2060 + ),
2061 + 'exclude_ext_desc' => sprintf(
2062 + /* translators: 1 is the starting bold tag, 2 is the ending bold tag */
2063 + __( '%1$sImage extension%2$s is', 'optimole-wp' ),
2064 + '<strong>',
2065 + '</strong>'
2066 + ),
2067 + 'exclude_filename_desc' => sprintf(
2068 + /* translators: 1 is the starting bold tag, 2 is the ending bold tag */ __( '%1$sImage filename%2$s contains', 'optimole-wp' ),
2069 + '<strong>',
2070 + '</strong>'
2071 + ),
2072 + 'exclude_desc_optimize' => sprintf(
2073 + /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */
2074 + __( 'Here you can define exceptions, in case you don\'t want some images to be optimised. %1$sLearn more%2$s', 'optimole-wp' ),
2075 + '<a class="inline-block text-purple-gray underline" target=”_blank” href="https://docs.optimole.com/article/1191-exclude-from-optimizing-or-lazy-loading">',
2076 + '</a>'
2077 + ),
2078 + 'exclude_title_lazyload' => __( 'Don\'t lazy-load images if', 'optimole-wp' ),
2079 + 'exclude_desc_lazyload' => sprintf(
2080 + /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */
2081 + __( 'Define exceptions, in case you don\'t want the lazy-load to be active on certain images. %1$sLearn more%2$s', 'optimole-wp' ),
2082 + '<a class="inline-block text-purple-gray underline" target=”_blank” href="https://docs.optimole.com/article/1191-exclude-from-optimizing-or-lazy-loading">',
2083 + '</a>'
2084 + ),
2085 + 'exclude_title_optimize' => __( 'Don\'t optimize and don\'t lazy-load images if', 'optimole-wp' ),
2086 + 'exclude_url_desc' => sprintf(
2087 + /* translators: 1 is the starting bold tag, 2 is the ending bold tag */ __( '%1$sPage url%2$s contains', 'optimole-wp' ),
2088 + '<strong>',
2089 + '</strong>'
2090 + ),
2091 + 'name' => sprintf(
2092 + /* translators: 1 is the starting bold tag, 2 is the ending bold tag */ __( '%1$sName: %2$s', 'optimole-wp' ),
2093 + '<strong>',
2094 + '</strong>'
2095 + ),
2096 + 'cropped' => __( 'cropped', 'optimole-wp' ),
2097 + 'exclude_url_match_desc' => sprintf(
2098 + /* translators: 1 is the starting bold tag, 2 is the ending bold tag */ __( '%1$sPage url%2$s matches', 'optimole-wp' ),
2099 + '<strong>',
2100 + '</strong>'
2101 + ),
2102 + 'exclude_first' => __( 'Exclude first', 'optimole-wp' ),
2103 + 'images' => __( 'images', 'optimole-wp' ),
2104 + 'exclude_first_images_title' => __( 'Bypass Lazy Load for First Images', 'optimole-wp' ),
2105 + 'exclude_first_images_desc' => sprintf( /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */ __( 'Indicate how many images at the top of each page should bypass lazy loading, ensuring they’re instantly visible. Enter 0 to not exclude any images from the lazy loading process. %1$sLearn more%2$s', 'optimole-wp' ), '<a class="inline-block text-purple-gray underline" target=”_blank” href="https://docs.optimole.com/article/1948-bypass-lazy-load-for-first-images">', '</a>' ),
2106 + 'filter_class' => __( 'Image class', 'optimole-wp' ),
2107 + 'filter_ext' => __( 'Image extension', 'optimole-wp' ),
2108 + 'filter_filename' => __( 'Image filename', 'optimole-wp' ),
2109 + 'filter_operator_contains' => __( 'contains', 'optimole-wp' ),
2110 + 'filter_operator_matches' => __( 'matches', 'optimole-wp' ),
2111 + 'filter_operator_is' => __( 'is', 'optimole-wp' ),
2112 + 'filter_url' => __( 'Page URL', 'optimole-wp' ),
2113 + 'filter_helper' => __( 'For homepage use `home` keyword.', 'optimole-wp' ),
2114 + 'gif_replacer_desc' => sprintf( /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */ __( 'Enable this to automatically convert GIF images to Video files (MP4 and WebM). %1$sLearn more%2$s', 'optimole-wp' ), '<a class="inline-block text-purple-gray underline" target=”_blank” href="https://docs.optimole.com/article/1171-gif-to-video-conversion">', '</a>' ),
2115 + 'height_field' => __( 'Height', 'optimole-wp' ),
2116 + 'add_image_size_button' => __( 'Add size', 'optimole-wp' ),
2117 + 'add_image_size_desc' => __( 'Add New Image Crop Size', 'optimole-wp' ),
2118 + 'here' => __( ' here.', 'optimole-wp' ),
2119 + 'hide' => __( 'Hide', 'optimole-wp' ),
2120 + 'high_q_title' => __( 'High', 'optimole-wp' ),
2121 + 'image_1_label' => __( 'Original', 'optimole-wp' ),
2122 + 'image_2_label' => __( 'Optimized', 'optimole-wp' ),
2123 + 'lazyload_desc' => sprintf( /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */ __( 'Images load only when they\'re about to enter the viewport. %1$sLearn more%2$s', 'optimole-wp' ), '<a class="inline-block text-purple-gray underline" target=”_blank” href="https://docs.optimole.com/article/1948-bypass-lazy-load-for-first-images">', '</a>' ),
2124 + 'filter_length_error' => __( 'The filter should be at least 3 characters long.', 'optimole-wp' ),
2125 + 'scale_desc' => __( 'Automatically resize the images based on device and viewport', 'optimole-wp' ),
2126 + 'low_q_title' => __( 'Low', 'optimole-wp' ),
2127 + 'medium_q_title' => __( 'Medium', 'optimole-wp' ),
2128 + 'no_images_found' => __( 'You dont have any images in your Media Library. Add one and check how the Optimole will perform.', 'optimole-wp' ),
2129 + 'native_desc' => __( 'Uses the browser\'s built-in lazy loading feature. Enabling this will disable the auto scale.', 'optimole-wp' ),
2130 + 'option_saved' => __( 'Option saved.', 'optimole-wp' ),
2131 + 'ml_quality_desc' => sprintf( /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */ __( 'Optimole ML algorithms will predict the optimal image quality to get the smallest possible size with minimum perceived quality losses. When disabled, you can control the quality manually. %1$sLearn more%2$s', 'optimole-wp' ), '<a class="inline-block text-purple-gray underline" target=”_blank” href="https://docs.optimole.com/article/1016-what-is-the-difference-between-the-auto-high-medium-low-compression-levels">', '</a>' ),
2132 + 'quality_desc' => __( 'Lower image quality might boost your loading speed by lowering the size. However, the low image quality may negatively impact the visual appearance of the images. Try experimenting with the setting, then click the View sample image link to see what option works best for you.', 'optimole-wp' ),
2133 + 'quality_selected_value' => __( 'Selected value', 'optimole-wp' ),
2134 + 'quality_slider_desc' => __( 'See one sample image which will help you choose the right quality of the compression.', 'optimole-wp' ),
2135 + 'quality_title' => __( 'Auto Quality Powered by ML(Machine Learning)', 'optimole-wp' ),
2136 + 'strip_meta_title' => __( 'Strip Image Metadata', 'optimole-wp' ),
2137 + 'strip_meta_desc' => sprintf( /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */ __( 'Removes extra information from images, including EXIF and IPTC data (like camera settings and copyright info). This makes the pictures lighter and helps your website load faster. %1$sLearn more%2$s', 'optimole-wp' ), '<a class="inline-block text-purple-gray underline" target=”_blank” href="https://docs.optimole.com/article/1944-strip-image-metadata">', '</a>' ),
2138 + 'replacer_desc' => sprintf( /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */ __( 'When enabled, Optimole will manage, optimize, and serve all the images on your website. If disabled, optimization, lazy loading, and other features will no longer be available. %1$sLearn more%2$s', 'optimole-wp' ), '<a class="inline-block text-purple-gray underline" target=”_blank” href="https://docs.optimole.com/article/1218-how-to-turn-off-image-replacement-in-optimoles-wordpress-plugin">', '</a>' ),
2139 + 'sample_image_loading' => __( 'Loading a sample image.', 'optimole-wp' ),
2140 + 'save_changes' => __( 'Save changes', 'optimole-wp' ),
2141 + 'show' => __( 'Show', 'optimole-wp' ),
2142 + 'selected_sites_title' => __( 'CURRENTLY SHOWING IMAGES FROM', 'optimole-wp' ),
2143 + 'selected_sites_desc' => __( 'Site:', 'optimole-wp' ),
2144 + 'selected_all_sites_desc' => __( 'Currently viewing images from all sites', 'optimole-wp' ),
2145 + 'select_all_sites_desc' => __( 'View images from all sites', 'optimole-wp' ),
2146 + 'select_site' => __( 'Select a website', 'optimole-wp' ),
2147 + 'cloud_site_title' => __( 'Show images only from these sites:', 'optimole-wp' ),
2148 + 'cloud_site_desc' => __( 'Browse images only from the specified websites. Otherwise, images from all websites will appear in the library.', 'optimole-wp' ),
2149 + 'toggle_ab_item' => __( 'Admin bar status', 'optimole-wp' ),
2150 + 'toggle_lazyload' => __( 'Enable Lazy Loading & Scaling', 'optimole-wp' ),
2151 + 'toggle_scale' => __( 'Smart Image Scaling', 'optimole-wp' ),
2152 + 'toggle_native' => __( 'Native Browser Loading', 'optimole-wp' ),
2153 + 'on_toggle' => __( 'On', 'optimole-wp' ),
2154 + 'off_toggle' => __( 'Off', 'optimole-wp' ),
2155 + 'view_sample_image' => __( 'View sample image', 'optimole-wp' ),
2156 + 'watch_placeholder_lazyload' => __( 'Optional selectors to extend coverage (one per line or comma-separated)', 'optimole-wp' ),
2157 + // translators: %s is the example selector list.
2158 + 'watch_placeholder_lazyload_example' => sprintf( __( 'Example: %s', 'optimole-wp' ), '.hero-bg, #banner-image, .lazy-bg, .footer-bg' ),
2159 + 'watch_desc_lazyload' => __( 'If everything is covered out of the box, leave this empty.', 'optimole-wp' ),
2160 + 'smart_loading_title' => __( 'Smart Loading', 'optimole-wp' ),
2161 + 'smart_loading_desc' => __( 'JavaScript-driven with advanced controls', 'optimole-wp' ),
2162 + 'browser_native_lazy' => __( 'Uses the browser\'s built-in lazy loading feature', 'optimole-wp' ),
2163 + // translators: viewport is the visible area of a web page on a display device.
2164 + 'viewport_detection' => __( 'Viewport detection', 'optimole-wp' ),
2165 + // translators: set the colors for the placeholder image.
2166 + 'placeholders_color' => __( 'Placeholders', 'optimole-wp' ),
2167 + // translators: it can handle many images without slowing down the site.
2168 + 'auto_scaling' => __( 'Auto Scaling', 'optimole-wp' ),
2169 + // translators: it uses the browser's built-in lazy loading feature without any additional scripts.
2170 + 'lightweight_native' => __( 'Lightweight', 'optimole-wp' ),
2171 +
2172 + 'watch_title_lazyload' => __( 'Extend CSS Background Images', 'optimole-wp' ),
2173 + 'width_field' => __( 'Width', 'optimole-wp' ),
2174 + 'crop' => __( 'crop', 'optimole-wp' ),
2175 + 'toggle_cdn' => __( 'Serve CSS & JS Through Optimole', 'optimole-wp' ),
2176 + 'cdn_desc' => sprintf( /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */ __( 'When enabled, Optimole will optimize your CSS and JS files and, if they contain images, the images as well, then deliver them via the CDN for faster webpage loading. %1$sLearn more%2$s', 'optimole-wp' ), '<a class="inline-block text-purple-gray underline" target=”_blank” href="https://docs.optimole.com/article/1966-serve-css-js-through-optimole">', '</a>' ),
2177 + 'enable_css_minify_title' => __( 'Minify CSS files', 'optimole-wp' ),
2178 + 'css_minify_desc' => __( 'Once Optimole will serve your CSS files, it will also minify the files and serve them via CDN.', 'optimole-wp' ),
2179 + 'enable_js_minify_title' => __( 'Minify JS files', 'optimole-wp' ),
2180 + 'js_minify_desc' => __( 'Once Optimole will serve your JS files, it will also minify the files and serve them via CDN.', 'optimole-wp' ),
2181 + 'sync_title' => __( 'Offload Existing Images', 'optimole-wp' ),
2182 + 'rollback_title' => __( 'Restore Offloaded Images', 'optimole-wp' ),
2183 + 'sync_desc' => __( 'Right now all the new images uploaded to your site are moved automatically to Optimole Cloud. In order to offload the existing ones, please click Sync images and wait for the process to finish. You can rollback anytime.', 'optimole-wp' ),
2184 + 'rollback_desc' => __( 'Pull all the offloaded images to Optimole Cloud back to your server.', 'optimole-wp' ),
2185 + 'sync_media' => __( 'Sync images', 'optimole-wp' ),
2186 + 'rollback_media' => __( 'Rollback images', 'optimole-wp' ),
2187 + 'sync_media_progress' => __( 'Moving your images to Optimole...', 'optimole-wp' ),
2188 + 'estimated_time' => __( 'Estimated time remaining', 'optimole-wp' ),
2189 + 'calculating_estimated_time' => __( 'We are currently calculating the estimated time for this job...', 'optimole-wp' ),
2190 + 'images_processing' => __( 'We are currently processing your images in the background. Leaving the page won\'t stop the process.', 'optimole-wp' ),
2191 + 'active_optimize_exclusions' => __( 'Active Optimizing Exclusions', 'optimole-wp' ),
2192 + 'active_lazyload_exclusions' => __( 'Active Lazy-loading Exclusions', 'optimole-wp' ),
2193 + 'minutes' => __( 'minutes', 'optimole-wp' ),
2194 + 'stop' => __( 'Stop', 'optimole-wp' ),
2195 + 'show_logs' => __( 'Show Logs', 'optimole-wp' ),
2196 + 'hide_logs' => __( 'Hide Logs', 'optimole-wp' ),
2197 + 'view_logs' => __( 'View Full Logs', 'optimole-wp' ),
2198 + 'rollback_media_progress' => __( 'Moving images into your media library...', 'optimole-wp' ),
2199 + 'rollback_media_error' => __( 'An unexpected error occured while pulling the offloaded back to your site', 'optimole-wp' ),
2200 + 'rollback_media_error_desc' => __( 'You can try again to pull back the rest of the images.', 'optimole-wp' ),
2201 + 'remove_notice' => __( 'Remove notice', 'optimole-wp' ),
2202 + 'sync_media_error' => __( 'An unexpected error occured while offloading all existing images from your site to Optimole', 'optimole-wp' ),
2203 + 'sync_media_link' => __( 'The selected images have been offloaded to our servers, you can check them', 'optimole-wp' ),
2204 + 'rollback_media_link' => __( 'The selected images have been restored to your server, you can check them', 'optimole-wp' ),
2205 + 'sync_media_error_desc' => __( 'You can try again to offload the rest of the images to Optimole.', 'optimole-wp' ),
2206 + 'offload_disable_warning_title' => __( 'Important! Please read carefully', 'optimole-wp' ),
2207 + 'offload_disable_warning_desc' => __( 'If you turn off this option, you will not be able to see the images in the Media Library without restoring the images first. Do you want to restore the images to your site upon turning off the option?', 'optimole-wp' ),
2208 + 'offload_enable_info_desc' => sprintf( /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */ __( 'You are not required to use the offload functionality for the plugin to work, use it if you want to save on hosting space. %1$s More details%2$s', 'optimole-wp' ), '<a style="white-space: nowrap;" target=”_blank” href="https://docs.optimole.com/article/1323-cloud-library-browsing">', '<span style="font-size:15px; margin-top:2px;" class="dashicons dashicons-external"></span></a>' ),
2209 + 'offload_conflicts_part_1' => __( 'We have detected the following plugins that conflict with the offload features:', 'optimole-wp' ),
2210 + 'offload_conflicts_part_2' => __( 'Please disable those plugins temporarily in order for Optimole to rollback the images to your site.', 'optimole-wp' ),
2211 + 'offloading_success' => sprintf( /* translators: 1 is the starting bold tag, 2 is the ending bold tag */ __( '%s Your images are now stored in Optimole Cloud.', 'optimole-wp' ), '<strong>' . __( 'Transfer Complete.', 'optimole-wp' ) . '</strong>' ),
2212 + 'rollback_success' => sprintf( /* translators: 1 is the starting bold tag, 2 is the ending bold tag */ __( '%s Your images have been restored to your website.', 'optimole-wp' ), '<strong>' . __( 'Transfer Complete.', 'optimole-wp' ) . '</strong>' ),
2213 + 'offloading_radio_legend' => __( 'Where your images are stored', 'optimole-wp' ),
2214 + 'offload_radio_option_rollback_title' => __( 'Optimole Cloud and your website', 'optimole-wp' ),
2215 + 'offload_radio_option_rollback_desc' => __( 'Images are stored in both the local WordPress media library and Optimole Cloud.', 'optimole-wp' ),
2216 + 'offload_radio_option_offload_title' => __( 'Optimole Cloud only', 'optimole-wp' ),
2217 + 'offload_radio_option_offload_desc' => __( 'Images are stored only in Optimole Cloud, allowing you to save space on your server. When enabled, any new images you upload in the Media Library will be automatically transferred to Optimole Cloud.', 'optimole-wp' ),
2218 + 'offload_limit_reached' => sprintf( /* translators: Current limit of offloaded images */ __( 'You have reached the maximum offloading limit of %s images. To increase the offload limit and for more information, contact our support.', 'optimole-wp' ), '<strong>#offload_limit#</strong>' ),
2219 + 'select' => __( 'Please select one ...', 'optimole-wp' ),
2220 + 'yes' => __( 'Restore images after disabling', 'optimole-wp' ),
2221 + 'no' => __( 'Do not restore images after disabling', 'optimole-wp' ),
2222 + 'lazyload_placeholder_color' => __( 'Placeholder Color', 'optimole-wp' ),
2223 + 'clear' => __( 'Clear', 'optimole-wp' ),
2224 + 'settings_saved' => __( 'Settings saved', 'optimole-wp' ),
2225 + 'settings_saved_error' => __( 'Error saving settings. Please reload the page and try again.', 'optimole-wp' ),
2226 + 'cache_cleared' => __( 'Cache cleared', 'optimole-wp' ),
2227 + 'cache_cleared_error' => __( 'Error clearing cache. Please reload the page and try again.', 'optimole-wp' ),
2228 + 'offloading_start_title' => __( 'Transfer your images to Optimole', 'optimole-wp' ),
2229 + 'offloading_start_description' => __( 'This process will transfer and store your images in Optimole Cloud and may take a while, depending on the number of images.', 'optimole-wp' ),
2230 + 'offloading_start_action' => __( 'Transfer to Optimole Cloud', 'optimole-wp' ),
2231 + 'offloading_stop_title' => __( 'Are you sure?', 'optimole-wp' ),
2232 + 'offloading_stop_description' => __( 'This will halt the ongoing process. To retrieve images transferred from the Optimole Cloud, use the Rollback option.', 'optimole-wp' ),
2233 + 'offloading_stop_action' => __( 'Cancel the transfer to Optimole', 'optimole-wp' ),
2234 + 'rollback_start_title' => __( 'Transfer back all images to your site', 'optimole-wp' ),
2235 + 'rollback_start_description' => __( 'This process will transfer back all images from Optimole to your website and may take a while, depending on the number of images.', 'optimole-wp' ),
2236 + 'rollback_start_action' => __( 'Transfer back from Optimole', 'optimole-wp' ),
2237 + 'rollback_stop_title' => __( 'Are you sure?', 'optimole-wp' ),
2238 + 'rollback_stop_description' => __( 'Canceling will halt the ongoing process, and any remaining images will stay in the Optimole Cloud. To transfer images to the Optimole Cloud, use the Offloading option.', 'optimole-wp' ),
2239 + 'rollback_stop_action' => __( 'Cancel the transfer from Optimole', 'optimole-wp' ),
2240 + 'cloud_library_btn_text' => __( 'Go to Cloud Library', 'optimole-wp' ),
2241 + 'cloud_library_btn_link' => add_query_arg( 'page', 'optimole-dam', admin_url( 'admin.php' ) ),
2242 + 'exceed_plan_quota_notice_title' => __( 'Your site has already reached over 50% of your monthly visits limit within just two weeks.', 'optimole-wp' ),
2243 + 'exceed_plan_quota_notice_description' => sprintf( /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */ __( 'Based on this trend, you are likely to exceed your free quota before the month ends. To avoid any disruption in service, we strongly recommend %1$supgrading%2$s your plan or waiting until your traffic stabilizes before offloading your images. Do you still wish to proceed?', 'optimole-wp' ), '<a style="white-space: nowrap;" target=”_blank” href="https://dashboard.optimole.com/settings/billing/">', '</a>' ),
2244 + 'exceed_plan_quota_notice_start_action' => __( 'Yes, Transfer to Optimole Cloud', 'optimole-wp' ),
2245 + 'exceed_plan_quota_notice_secondary_action' => __( 'No, keep images on my website', 'optimole-wp' ),
2246 + 'plan_update_notice_title' => __( 'Plan Update', 'optimole-wp' ),
2247 + 'plan_update_notice_desc' => __( 'We\'ve changed how plans work. Users on the Optimole Free plan cannot offload new images. Existing images that are already offloaded will remain offloaded.', 'optimole-wp' ),
2248 + 'upgrade_to_use_offloading_notice_desc' => __( 'Offloading images is a PRO feature. Please upgrade your plan to enable image transfer to Optimole Cloud.', 'optimole-wp' ),
2249 + 'visual_settings' => __( 'Visual Settings', 'optimole-wp' ),
2250 + 'extended_features' => __( 'Extended Features', 'optimole-wp' ),
2251 + // translators: mark that the options are aplied globally.
2252 + 'global_option' => __( 'Global', 'optimole-wp' ),
2253 + // translators: This option is discouraged from being used.
2254 + 'not_recommended' => __( 'Not recommended', 'optimole-wp' ),
2255 + // translators: %1$s is the starting bold tag, %2$s is the ending bold tag.
2256 + 'viewport_skip_images_notice' => sprintf( __( 'When %1$sskip above the fold%2$s and %1$sskip first images%2$s are both enabled: the skip rule applies on a user\'s first page view. On subsequent views, once viewport data exists, the skip rule is ignored in favor of the viewport data.', 'optimole-wp' ), '<strong>', '</strong>' ),
2257 + // translators: %1$s is the starting bold tag, %2$s is the ending bold tag.
2258 + 'native_lazy_load_warning' => sprintf( __( 'Native browser loading works with viewport detection, but it does not support smart image scaling. It can offer better cross-browser compatibility. Still, we do %1$snot recommend%2$s it for most sites due to fewer controls and features compared to Smart Loading.', 'optimole-wp' ), '<strong>', '</strong>' ),
2259 + 'performance_impact_alert_title' => __( 'Performance Impact Alert', 'optimole-wp' ),
2260 + 'performance_impact_alert_lazy_desc' => __( 'Disabling Lazy Load may significantly impact your site\'s loading speed and Core Web Vitals scores.', 'optimole-wp' ),
2261 + 'performance_impact_alert_scale_desc' => __( 'Disabling Image Scaling may significantly impact your site\'s loading speed and Core Web Vitals scores.', 'optimole-wp' ),
2262 + 'performance_impact_alert_action_label' => __( 'Continue with disabling', 'optimole-wp' ),
2263 + 'performance_impact_alert_secondary_action_label' => __( 'Keep enabled and get help', 'optimole-wp' ),
2264 + ],
2265 + 'help' => [
1397 2266 'section_one_title' => __( 'Help and Support', 'optimole-wp' ),
1398 2267 'section_two_title' => __( 'Documentation', 'optimole-wp' ),
1399 2268 'section_two_sub' => __( 'Docs Page', 'optimole-wp' ),
1400 2269 'get_support_title' => __( 'Get Support', 'optimole-wp' ),
@@ -1418,9 +2287,9 @@
1418 2287 'api_item_one' => __( 'Cloud Library Browsing', 'optimole-wp' ),
1419 2288 'api_item_two' => __( 'Exclude from Optimizing or Lazy Loading', 'optimole-wp' ),
1420 2289 'api_item_three' => __( 'Custom Integration', 'optimole-wp' ),
1421 2290 ],
1422 - 'watermarks' => [
2291 + 'watermarks' => [
1423 2292 'image' => __( 'Image', 'optimole-wp' ),
1424 2293 'loading_remove_watermark' => __( 'Removing watermark resource ...', 'optimole-wp' ),
1425 2294 'max_allowed' => __( 'You are allowed to save maximum 5 images.', 'optimole-wp' ),
1426 2295 'list_header' => __( 'Possible watermarks', 'optimole-wp' ),
@@ -1456,37 +2325,55 @@
1456 2325 'scale_title' => __( 'Watermark scale', 'optimole-wp' ),
1457 2326 'scale_desc' => __( 'A value between 0 and 300 for the scale of the watermark (100 is the original size and 300 is 3x the size) relative to the resulting image size. If set to 0 it will default to the original size.', 'optimole-wp' ),
1458 2327 'save_changes' => __( 'Save changes', 'optimole-wp' ),
1459 2328 ],
1460 - 'latest_images' => [
2329 + 'latest_images' => [
1461 2330 'image' => __( 'Image', 'optimole-wp' ),
1462 - 'no_images_found' => sprintf( __( 'We are currently optimizing your images. Meanwhile you can visit your %1$shomepage%2$s and check how our plugin performs. ', 'optimole-wp' ), '<a href="' . esc_url( home_url() ) . '" target="_blank" >', '</a>' ),
2331 + 'no_images_found' => sprintf( /* translators: 1 is the starting anchor tag, 2 is the ending anchor tag */ __( 'We are currently optimizing your images. Meanwhile you can visit your %1$shomepage%2$s and check how our plugin performs.', 'optimole-wp' ), '<a href="' . esc_url( home_url() ) . '" target="_blank" >', '</a>' ),
1463 2332 'compression' => __( 'Optimization', 'optimole-wp' ),
1464 2333 'loading_latest_images' => __( 'Loading your optimized images...', 'optimole-wp' ),
1465 - 'last' => __( 'Last', 'optimole-wp' ),
1466 - 'saved' => __( 'Saved', 'optimole-wp' ),
1467 - 'smaller' => __( 'smaller', 'optimole-wp' ),
1468 - 'optimized_images' => __( 'optimized images', 'optimole-wp' ),
1469 - 'same_size' => __( '🙉 We couldn\'t do better, this image is already optimized at maximum. ', 'optimole-wp' ),
2334 + 'last_optimized_images' => __( 'Last optimized images', 'optimole-wp' ),
2335 + // translators: %s is the percentage (e.g. 10%).
2336 + 'percentage_saved' => sprintf( __( '%s Saved', 'optimole-wp' ), '{ratio}%' ),
2337 + // translators: %s is the percentage (e.g. 10%).
2338 + 'percentage_smaller' => sprintf( __( '%s smaller', 'optimole-wp' ), '{ratio}%' ),
2339 + 'same_size' => __( '🙉 We couldn\'t do better, this image is already optimized at maximum.', 'optimole-wp' ),
1470 2340 'small_optimization' => __( '😬 Not that much, just <strong>{ratio}</strong> smaller.', 'optimole-wp' ),
1471 2341 'medium_optimization' => __( '🤓 We are on the right track, <strong>{ratio}</strong> squeezed.', 'optimole-wp' ),
1472 - 'big_optimization' => __( '❤️❤️❤️ Our moles just nailed it, this one is <strong>{ratio}</strong> smaller. ', 'optimole-wp' ),
2342 + 'big_optimization' => __( '❤️❤️❤️ Our moles just nailed it, this one is <strong>{ratio}</strong> smaller.', 'optimole-wp' ),
1473 2343 ],
1474 - 'csat' => [
1475 - 'title' => __( 'Your opinion matters', 'optimole-wp' ),
2344 + 'csat' => [
1476 2345 'close' => __( 'Close', 'optimole-wp' ),
1477 - 'heading_one' => __( 'How easy did you find to get started using Optimole, on a scale of 1 to 5?', 'optimole-wp' ),
1478 - 'heading_two' => __( 'Any specific feedback you would like to add?', 'optimole-wp' ),
1479 - 'heading_three' => __( 'Thank you!', 'optimole-wp' ),
1480 - 'low' => __( 'Very Poor', 'optimole-wp' ),
1481 - 'high' => __( 'Excellent', 'optimole-wp' ),
1482 - 'feedback_placeholder' => __( 'Add your feedback here (optional)', 'optimole-wp' ),
1483 - 'skip' => __( 'Skip', 'optimole-wp' ),
1484 - 'submit' => __( 'Submit', 'optimole-wp' ),
1485 - 'privacy' => __( 'What info we collect?', 'optimole-wp' ),
1486 - 'privacy_tooltip' => __( 'We value privacy, that\'s why no IP addresses are collected after you submit the survey.', 'optimole-wp' ),
1487 - 'thank_you' => __( 'Your input is highly appreciated and helps us shape a better experience in Optimole.', 'optimole-wp' ),
1488 2346 ],
2347 + 'cron_error' => sprintf( /* translators: 1 is code to disable cron, 2 value of the constant */ __( 'It seems that you have the %1$s constant defined as %2$s. The offloading process uses cron events to offload the images in the background. Please remove the constant from your wp-config.php file in order for the offloading process to work.', 'optimole-wp' ), '<code>DISABLE_WP_CRON</code>', '<code>true</code>' ),
2348 + 'cancel' => __( 'Cancel', 'optimole-wp' ),
2349 + 'optimization_status' => [
2350 + 'title' => __( 'Optimization Status', 'optimole-wp' ),
2351 + 'statusTitle1' => __( 'Image Handling', 'optimole-wp' ),
2352 + 'statusSubTitle1' => __( 'All images are optimized automatically', 'optimole-wp' ),
2353 + 'statusTitle2' => __( 'Smart Lazy-Loading', 'optimole-wp' ),
2354 + 'statusSubTitle2' => __( 'Images load as visitors scroll', 'optimole-wp' ),
2355 + 'statusTitle3' => __( 'Image Scalling', 'optimole-wp' ),
2356 + 'statusSubTitle3' => __( 'All images are perfectly sized for devices', 'optimole-wp' ),
2357 + 'disable' => __( 'Disable', 'optimole-wp' ),
2358 + 'enable' => __( 'Enable', 'optimole-wp' ),
2359 + 'manage' => __( 'Manage', 'optimole-wp' ),
2360 + ],
2361 + 'optimization_tips' => sprintf(
2362 + /* translators: 1 is the opening anchor tag, 2 is the closing anchor tag */
2363 + __( '%1$sView all optimization tips%2$s', 'optimole-wp' ),
2364 + '<a class="flex justify-center items-center font-semibold" href="https://docs.optimole.com/article/2238-optimization-tips" target="_blank"> ',
2365 + '<span style="text-decoration:none; font-size:15px; margin-top:2px;" class="dashicons dashicons-external"></span></a>'
2366 + ),
2367 + 'contact_support' => [
2368 + // translators: %s is the email main subject.
2369 + 'title_prefix' => __( '[Lazy Load Issue] %s', 'optimole-wp' ),
2370 + 'disable_lazy_load_scaling' => __( 'Disable Lazy Load & Scaling', 'optimole-wp' ),
2371 + 'disable_image_scaling' => __( 'Disable Image Scaling', 'optimole-wp' ),
2372 + 'enable_native_lazy_load' => __( 'Enable Native Lazy Load', 'optimole-wp' ),
2373 + ],
2374 + // translators: %s is the date of the renewal.
2375 + 'renew_date' => __( 'Renews %s', 'optimole-wp' ),
1489 2376 ];
1490 2377 }
1491 2378
1492 2379 /**
@@ -1497,9 +2384,180 @@
1497 2384 * @return array
1498 2385 * @access public
1499 2386 * @uses filter:upload_mimes
1500 2387 */
1501 - public function allow_meme_types( $mimes ) {
1502 - $mimes['svg'] = 'image/svg+xml';
2388 + public function allow_svg( $mimes ) {
2389 + $mimes['svg'] = 'image/svg+xml';
2390 +
1503 2391 return $mimes;
2392 + }
2393 +
2394 + /**
2395 + * Get the Formbricks survey metadata.
2396 + *
2397 + * @param array $data The data in Formbricks format.
2398 + * @param string $page_slug The slug of the page.
2399 + *
2400 + * @return array - The data in Formbricks format.
2401 + */
2402 + public function get_survey_metadata( $data, $page_slug ) {
2403 +
2404 + if ( 'dashboard' !== $page_slug ) {
2405 + return $data;
2406 + }
2407 +
2408 + $dashboard_data = $this->localize_dashboard_app();
2409 + $user_data = $dashboard_data['user_data'];
2410 +
2411 + if ( ! isset( $user_data['plan'] ) ) {
2412 + return $data;
2413 + }
2414 +
2415 + $data = [
2416 + 'environmentId' => 'clo8wxwzj44orpm0gjchurujm',
2417 + 'attributes' => [
2418 + 'plan' => $user_data['plan'],
2419 + 'status' => $user_data['status'],
2420 + 'cname_assigned' => ! empty( $user_data['is_cname_assigned'] ) ? $user_data['is_cname_assigned'] : 'no',
2421 + 'connected_websites' => isset( $user_data['whitelist'] ) ? strval( count( $user_data['whitelist'] ) ) : '0',
2422 + 'install_days_number' => intval( $dashboard_data['days_since_install'] ),
2423 + 'traffic' => strval( isset( $user_data['traffic'] ) ? $this->survey_category( $user_data['traffic'], 500 ) : 0 ),
2424 + 'images_number' => strval( isset( $user_data['images_number'] ) ? $this->survey_category( $user_data['images_number'], 100 ) : 0 ),
2425 + ],
2426 + ];
2427 +
2428 + return $data;
2429 + }
2430 +
2431 + /**
2432 + * Categorize a number for survey based on its scale.
2433 + *
2434 + * @param int $value The value.
2435 + * @param int $scale The scale.
2436 + *
2437 + * @return int - The category.
2438 + */
2439 + public function survey_category( $value, $scale = 1 ) {
2440 + $value = intval( $value / $scale );
2441 +
2442 + if ( 1 < $value && 8 > $value ) {
2443 + return 7;
2444 + }
2445 +
2446 + if ( 8 <= $value && 31 > $value ) {
2447 + return 30;
2448 + }
2449 +
2450 + if ( 30 < $value && 90 > $value ) {
2451 + return 90;
2452 + }
2453 +
2454 + if ( 90 <= $value ) {
2455 + return 91;
2456 + }
2457 +
2458 + return 0;
2459 + }
2460 +
2461 + /**
2462 + * Determines whether the exceed quota warning should be displayed to users.
2463 + *
2464 + * This function checks if the user's quota usage has exceeded a predefined limit
2465 + * and returns a boolean value indicating whether the warning should be shown.
2466 + *
2467 + * @return bool True if the exceed quota warning should be displayed, false otherwise.
2468 + */
2469 + public function should_show_exceed_quota_warning() {
2470 + if ( ! $this->settings->is_connected() ) {
2471 + return false;
2472 + }
2473 + if ( get_option( 'optml_notice_hide_upg', 'no' ) === 'yes' ) {
2474 + return false;
2475 + }
2476 +
2477 + $service_data = $this->settings->get( 'service_data' );
2478 +
2479 + if ( ! isset( $service_data['plan'] ) ) {
2480 + return false;
2481 + }
2482 + if ( $service_data['plan'] !== 'free' ) {
2483 + return false;
2484 + }
2485 + if ( ! isset( $service_data['renews_on'] ) ) {
2486 + return false;
2487 + }
2488 + $renews_on = $service_data['renews_on'];
2489 + $timestamp_before_two_weeks = strtotime( '-2 weeks', $renews_on );
2490 + $today_timestamp = strtotime( 'today' );
2491 +
2492 + if ( $timestamp_before_two_weeks < $today_timestamp ) {
2493 + return false;
2494 + }
2495 +
2496 + $visitors_limit = isset( $service_data['visitors_limit'] ) ? (int) $service_data['visitors_limit'] : 0;
2497 + $visitors_left = isset( $service_data['visitors_left'] ) ? (int) $service_data['visitors_left'] : 0;
2498 +
2499 + if ( ! $visitors_limit || ! $visitors_left ) {
2500 + return false;
2501 + }
2502 +
2503 + $used_quota = $visitors_limit - $visitors_left;
2504 + $is_50_percent_used = ( $used_quota / $visitors_limit ) >= 0.5;
2505 +
2506 + if ( ! $is_50_percent_used ) {
2507 + return false;
2508 + }
2509 +
2510 + return true;
2511 + }
2512 +
2513 + /**
2514 + * Get the number of active notices (not dismissed).
2515 + *
2516 + * @return int - Number of active notices
2517 + */
2518 + private function get_active_notices_count() {
2519 + $conflicting_plugins = $this->conflicting_plugins->get_conflicting_plugins();
2520 + $conflicts_count = 0;
2521 +
2522 + foreach ( $conflicting_plugins as $key => $plugin ) {
2523 + $key = str_replace( 'wp-', '', $key );
2524 + $class_name = 'Optml_' . ucfirst( $key );
2525 +
2526 + if ( ! class_exists( $class_name ) ) {
2527 + continue;
2528 + }
2529 + $conflict_instance = new $class_name();
2530 +
2531 + if ( ! is_a( $conflict_instance, 'Optml_Abstract_Conflict' ) ) {
2532 + continue;
2533 + }
2534 +
2535 + if ( $conflict_instance->is_conflict_valid() ) {
2536 + ++$conflicts_count;
2537 + }
2538 + }
2539 +
2540 + $dismissed_notices = get_option( 'optml_dismissed_conflicts', [] );
2541 +
2542 + return $conflicts_count - count( $dismissed_notices );
2543 + }
2544 +
2545 + /**
2546 + * Mark if the user had offloading enabled on first run.
2547 + *
2548 + * If it is an old free user that had offloading enabled, we will use the mark to show a notice about the plan changes.
2549 + *
2550 + * @return void
2551 + */
2552 + public function mark_user_with_offload() {
2553 + if ( ! $this->settings->is_connected() ) {
2554 + return;
2555 + }
2556 +
2557 + if ( false !== get_option( 'optml_has_offloading_enabled_on_upgrade', false ) ) {
2558 + return;
2559 + }
2560 +
2561 + update_option( 'optml_has_offloading_enabled_on_upgrade', $this->settings->is_offload_enabled() ? 'yes' : 'no' );
1504 2562 }
1505 2563 }