PluginProbe
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization / trunk
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization vtrunk
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 3.12.0 All 135 releases
← All changes | vendor/codeinwp/themeisle-sdk/src/Loader.php +428 -3 3.0.1 → trunk View file →
@@ -36,9 +36,9 @@
36 36 private static $version = '2.0.0';
37 37 /**
38 38 * Holds registered products.
39 39 *
40 - * @var array The products which use the SDK.
40 + * @var array<Product> The products which use the SDK.
41 41 */
42 42 private static $products = [];
43 43 /**
44 44 * Holds available modules to load.
@@ -45,8 +45,10 @@
45 45 *
46 46 * @var array The modules which SDK will be using.
47 47 */
48 48 private static $available_modules = [
49 + 'crash_reporter',
50 + 'script_loader',
49 51 'dashboard_widget',
50 52 'rollback',
51 53 'uninstall_feedback',
52 54 'licenser',
@@ -51,12 +53,329 @@
51 53 'uninstall_feedback',
52 54 'licenser',
53 55 'logger',
54 56 'translate',
57 + 'translations',
55 58 'review',
56 59 'recommendation',
57 60 'notification',
61 + 'promotions',
62 + 'welcome',
63 + 'compatibilities',
64 + 'about_us',
65 + 'announcements',
66 + 'featured_plugins',
67 + 'float_widget',
68 + 'migrator',
69 + ];
70 + /**
71 + * Holds the labels for the modules.
72 + *
73 + * @var array The labels for the modules.
74 + */
75 + public static $labels = [
76 + 'announcements' => [
77 + 'notice_link_label' => 'See the deals',
78 + 'max_savings' => 'Best WordPress Black Friday deals of %s — themes, plugins, hosting. Curated by the Themeisle team.',
79 + 'black_friday' => 'Black Friday Sale',
80 + 'time_left' => '%s left',
81 + 'plugin_meta_message' => 'Black Friday Sale - 60% OFF',
82 + ],
83 + 'compatibilities' => [
84 + 'notice' => '%s requires a newer version of %s. Please %supdate%s %s %s to the latest version.',
85 + 'notice2' => '%s update requires a newer version of %s. Please %supdate%s %s %s.',
86 + 'notice_theme' => '%1$sWarning:%2$s This theme has not been tested with your current version of %1$s%3$s%2$s. Please update %3$s plugin.',
87 + 'notice_plugin' => '%1$sWarning:%2$s This plugin has not been tested with your current version of %1$s%3$s%2$s. Please update %3$s %4$s.',
88 + 'theme' => 'theme',
89 + 'plugin' => 'plugin',
90 + ],
91 + 'dashboard_widget' => [
92 + 'title' => 'WordPress Guides/Tutorials',
93 + 'popular' => 'Popular %s',
94 + 'install' => 'Install',
95 + 'powered' => 'Powered by %s',
96 + ],
97 + 'licenser' => [
98 + 'activate' => 'Activate',
99 + 'invalid_msg' => 'Invalid license.',
100 + 'error_notice' => 'ERROR: Failed to connect to the license service. Please try again later. Reason: %s',
101 + 'error_notice2' => 'ERROR: Failed to validate license. Please try again in one minute.',
102 + 'error_invalid' => 'ERROR: Invalid license provided.',
103 + 'update_license' => 'Updating this theme will lose any customizations you have made. Cancel to stop, OK to update.',
104 + 'invalid_msg' => 'Invalid license.',
105 + 'already_active' => 'License is already active.',
106 + 'notice_update' => '%1$s is available. %2$sCheck out what\'s%3$s new or %4$supdate now%3$s.',
107 + 'not_active' => 'License not active.',
108 + 'deactivate' => 'Deactivate',
109 + 'renew_cta' => 'Renew license to update',
110 + 'autoactivate_notice' => '%s has been successfully activated using %s license !',
111 + 'valid' => 'Valid',
112 + 'invalid' => 'Invalid',
113 + 'notice' => 'Enter your license from %s purchase history in order to get %s updates',
114 + 'expired' => '%s license expired',
115 + 'expired_date' => 'Expired on %s',
116 + 'expired_notice' => 'Your current setup continues working, but premium features are disabled and you\'re no longer receive updates - including critical patches - or support.',
58 117
118 + 'inactive' => 'In order to benefit from updates and support for %s, please add your license code from your %spurchase history%s and validate it %shere%s.',
119 + 'no_activations' => 'No more activations left for %s. You need to upgrade your plan in order to use %s on more websites. If you need assistance, please get in touch with %s staff.',
120 + 'renew_license' => 'Renew License',
121 + 'learn_more' => 'Learn More',
122 + ],
123 + 'promotions' => [
124 + 'recommended' => 'Recommended by %s',
125 + 'installActivate' => 'Install & Activate',
126 + 'preview' => 'Preview',
127 + 'installing' => 'Installing',
128 + 'activating' => 'Activating',
129 + 'connecting' => 'Connecting to API',
130 + 'learnmore' => 'Learn More',
131 + 'activate' => 'Activate',
132 + 'all_set' => 'Awesome! You are all set!',
133 + 'woo' => [
134 + 'title' => 'More extensions from Themeisle',
135 + 'title2' => 'Recommended extensions',
136 + 'cta_install' => 'Install',
137 + 'learn_more' => 'Learn More',
138 + 'dismiss' => 'Dismiss this suggestion',
139 + 'ppom_title' => 'Product Add-Ons',
140 + 'ppom_desc' => 'Add extra custom fields & add-ons on your product pages, like sizes, colors & more.',
141 + 'spark_title1' => 'Wishlist',
142 + 'spark_title2' => 'Multi-Announcement Bars',
143 + 'spark_title3' => 'Advanced Product Review',
144 + 'spark_desc1' => 'Loyalize your customers by allowing them to save their favorite products.',
145 + 'spark_desc2' => 'Add a top notification bar on your website to highlight the latest products, offers, or upcoming events.',
146 + 'spark_desc3' => 'Enable an advanced review section, enlarging the basic review options with lots of capabilities.',
147 + ],
148 +
149 + 'feedzy' => [
150 + 'import_desc' => 'Schedule automatic content imports from any RSS feed directly to your site. %sBuilt by %s%s',
151 + 'install_now' => 'Install Now',
152 + 'by' => 'by %s',
153 + 'editor_recommends' => '%s recommends %sFeedzy%s to display entries from any RSS feed with more advanced styling and filtering options.',
154 + ],
155 + 'optimole' => [
156 + 'installOptimole' => 'Install Optimole',
157 + 'gotodash' => 'Go to Optimole dashboard',
158 + 'dismisscta' => 'Dismiss this notice.',
159 + 'message1' => 'Increase this page speed and SEO ranking by optimizing images with Optimole.',
160 + 'message3' => 'Save your server space by storing images to Optimole and deliver them optimized from 400 locations around the globe. Unlimited images, Unlimited traffic.',
161 + 'message4' => 'This image looks to be too large and would affect your site speed, we recommend you to install Optimole to optimize your images.',
162 + 'message2' => 'Leverage Optimole\'s full integration with Elementor to automatically lazyload, resize, compress to AVIF/WebP and deliver from 400 locations around the globe!',
163 + ],
164 + 'redirectionCF7' => [
165 + 'gotodash' => 'Go to Contact Forms',
166 + 'dismisscta' => 'Dismiss this notice.',
167 + 'gst' => 'Get Started Free',
168 + 'message' => 'Add URL redirects, spam protection, execute JavaScript after submissions, and more with the Redirection for CF7 free plugin.',
169 + ],
170 + 'hyve' => [
171 + 'gotodash' => 'Go to Hyve Dashboard',
172 + 'install' => 'Install Hyve',
173 + 'dismisscta' => 'Dismiss this notice.',
174 + 'message' => 'Hyve is an AI-powered chatbot that turns your WordPress content into interactive conversations, helping you efficiently handle user inquiries.',
175 + ],
176 + 'wp_full_pay' => [
177 + 'gotodash' => 'Go to WP Full Pay Settings',
178 + 'install' => 'Install WP Full Pay',
179 + 'dismisscta' => 'Dismiss this notice.',
180 + 'message' => 'Enhance your donation page with WP Full Pay—create custom Stripe forms for one-time and recurring donations, manage transactions easily, and boost support with a seamless setup.',
181 + ],
182 + 'masteriyo' => [
183 + 'gotodash' => 'Go to Masteriyo Dashboard',
184 + 'install' => 'Install Masteriyo',
185 + 'dismisscta' => 'Dismiss this notice.',
186 + 'message' => 'Transform your site into a learning hub with Masteriyo LMS. Build engaging courses with intuitive tools, track student progress effortlessly, and grow your education business with powerful marketing features and seamless payment integration.',
187 + ],
188 + 'easy_mcp' => [
189 + 'gotodash' => 'Go to Easy MCP Dashboard',
190 + 'install' => 'Install Easy MCP AI',
191 + 'dismisscta' => 'Dismiss this notice.',
192 + 'message' => 'Connect Claude, ChatGPT, and other AI assistants to this site with Easy MCP AI — a free MCP server that lets your AI manage content, media, and SEO data, with per-scope permissions and a full audit trail.',
193 + ],
194 + ],
195 + 'welcome' => [
196 + 'ctan' => 'No, thanks.',
197 + 'ctay' => 'Upgrade Now!',
198 + 'message' => '<p>You\'ve been using <b>{product}</b> for 7 days now and we appreciate your loyalty! We also want to make sure you\'re getting the most out of our product. That\'s why we\'re offering you a special deal - upgrade to <b>{pro_product}</b> in the next 5 days and receive a discount of <b>up to 30%</b>. <a href="{cta_link}" target="_blank">Upgrade now</a> and unlock all the amazing features of <b>{pro_product}</b>!</p>',
199 + ],
200 + 'uninstall' => [
201 + 'heading_plugin' => 'What\'s wrong?',
202 + 'heading_theme' => 'What does not work for you in {theme}?',
203 + 'submit' => 'Submit',
204 + 'cta_info' => 'What info do we collect?',
205 + 'button_submit' => 'Submit &amp; Deactivate',
206 + 'button_cancel' => 'Skip &amp; Deactivate',
207 + 'disclosure' => [
208 + 'title' => 'Below is a detailed view of all data that Themeisle will receive if you fill in this survey. No email address or IP addresses are transmitted after you submit the survey.',
209 + 'version' => '%s %s version %s %s %s %s',
210 + 'website' => '%sCurrent website:%s %s %s %s',
211 + 'usage' => '%sUsage time:%s %s %s%s',
212 + 'reason' => '%s Uninstall reason %s %s Selected reason from the above survey %s ',
213 + 'diagnostics' => '%sCrash diagnostics:%s Anonymized technical details of errors recorded for this product, if any.',
214 + ],
215 +
216 + 'options' => [
217 + 'id3' => [
218 + 'title' => 'I found a better plugin',
219 + 'placeholder' => 'What\'s the plugin\'s name?',
220 + ],
221 + 'id4' => [
222 +
223 + 'title' => 'I could not get the plugin to work',
224 + 'placeholder' => 'What problem are you experiencing?',
225 + ],
226 + 'id5' => [
227 +
228 + 'title' => 'I no longer need the plugin',
229 + 'placeholder' => 'If you could improve one thing about our product, what would it be?',
230 + ],
231 + 'id6' => [
232 + 'title' => 'It\'s a temporary deactivation. I\'m just debugging an issue.',
233 + 'placeholder' => 'What problem are you experiencing?',
234 + ],
235 + 'id7' => [
236 + 'title' => 'I don\'t know how to make it look like demo',
237 + ],
238 + 'id8' => [
239 +
240 + 'placeholder' => 'What option is missing?',
241 + 'title' => 'It lacks options',
242 + ],
243 + 'id9' => [
244 + 'title' => 'Is not working with a plugin that I need',
245 + 'placeholder' => 'What is the name of the plugin',
246 + ],
247 + 'id10' => [
248 + 'title' => 'I want to try a new design, I don\'t like {theme} style',
249 + ],
250 + 'id999' => [
251 + 'title' => 'Other',
252 + 'placeholder' => 'What can we do better?',
253 + ],
254 + ],
255 + ],
256 + 'review' => [
257 + 'notice' => '<p>Hey, it\'s great to see you have <b>{product}</b> active for a few days now. How is everything going? If you can spare a few moments to rate it on WordPress.org it would help us a lot (and boost my motivation). Cheers! <br/> <br/>~ {developer}, developer of {product}</p>',
258 + 'ctay' => 'Ok, I will gladly help.',
259 + 'ctan' => 'No, thanks.',
260 +
261 + ],
262 + 'rollback' => [
263 + 'cta' => 'Rollback to v%s',
264 + ],
265 + 'logger' => [
266 + 'notice' => 'Help improve <b>{product}</b> by sharing anonymous usage data about your setup. No personal data collected.',
267 + 'cta_y' => 'Count me in',
268 + 'cta_n' => 'No thanks',
269 + ],
270 + 'about_us' => [
271 + 'title' => 'About Us',
272 + 'heroHeader' => 'Our Story',
273 + 'heroTextFirst' => 'Themeisle was founded in 2012 by a group of passionate developers who wanted to create beautiful and functional WordPress themes and plugins. Since then, we have grown into a team of over 20 dedicated professionals who are committed to delivering the best possible products to our customers.',
274 + 'heroTextSecond' => 'At Themeisle, we offer a wide range of WordPress themes and plugins that are designed to meet the needs of both beginners and advanced users. Our products are feature-rich, easy to use, and are designed to help you create beautiful and functional websites.',
275 + 'teamImageCaption' => 'Our team in WCEU2022 in Portugal',
276 + 'newsHeading' => 'Stay connected for news & updates!',
277 + 'emailPlaceholder' => 'Your email address',
278 + 'signMeUp' => 'Sign me up',
279 + 'services' => [
280 + 'ariaLabel' => 'Themeisle services',
281 + 'trustpilotLabel' => 'Rated excellent on Trustpilot',
282 + 'trustpilotRated' => 'Rated',
283 + 'trustpilotOn' => 'on',
284 + 'trustpilotBrand' => 'Trustpilot',
285 + 'heading' => 'Expert WordPress services from the Themeisle team',
286 + 'description' => 'Done for you by the same people who build your plugins and themes.',
287 + 'cta' => 'Explore all services',
288 + 'items' => [
289 + 'websiteDesign' => [
290 + 'title' => 'Website Design',
291 + 'subtitle' => 'Built for your business',
292 + ],
293 + 'support' => [
294 + 'title' => 'Support',
295 + 'subtitle' => 'On-demand expert help',
296 + ],
297 + 'speed' => [
298 + 'title' => 'Speed Optimization',
299 + 'subtitle' => 'Core Web Vitals boost',
300 + ],
301 + 'seo' => [
302 + 'title' => 'SEO Foundation',
303 + 'subtitle' => 'Rank & get found',
304 + ],
305 + 'maintenance' => [
306 + 'title' => 'Maintenance',
307 + 'subtitle' => 'Updates, backups, security',
308 + ],
309 + 'hackedSite' => [
310 + 'title' => 'Hacked Site Repair',
311 + 'subtitle' => 'Malware removed fast',
312 + ],
313 + ],
314 + ],
315 + 'installNow' => 'Install Now',
316 + 'activate' => 'Activate',
317 + 'learnMore' => 'Learn More',
318 + 'installed' => 'Installed',
319 + 'notInstalled' => 'Not Installed',
320 + 'active' => 'Active',
321 + 'others' => [
322 + 'optimole_desc' => 'Optimole is an image optimization service that automatically optimizes your images and serves them to your visitors via a global CDN, making your website lighter, faster and helping you reduce your bandwidth usage.',
323 + 'neve_desc' => 'A fast, lightweight, customizable WordPress theme offering responsive design, speed, and flexibility for various website types.',
324 + 'landingkit_desc' => 'Turn WordPress into a landing page powerhouse with Landing Kit, map domains to pages or any other published resource.',
325 + 'sparks_desc' => 'Extend your store functionality with 8 ultra-performant features like product comparisons, variation swatches, wishlist, and more.',
326 + 'tpc_desc' => 'Design, save, and revisit your templates anytime with your personal vault on Templates Cloud.',
327 + ],
328 + 'otter-page' => [
329 + 'heading' => 'Build innovative layouts with Otter Blocks and Gutenberg',
330 + 'text' => 'Otter is a lightweight, dynamic collection of page building blocks and templates for the WordPress block editor.',
331 + 'buttons' => [
332 + 'install_otter_free' => "Install Otter - It's free!",
333 + 'install_now' => 'Install Now',
334 + 'learn_more' => 'Learn More',
335 + ],
336 + 'features' => [
337 + 'advancedTitle' => 'Advanced Features',
338 + 'advancedDesc' => 'Add features such as Custom CSS, Animations & Visibility Conditions to all blocks.',
339 + 'fastTitle' => 'Lightweight and Fast',
340 + 'fastDesc' => 'Otter enhances WordPress site building experience without impacting site speed.',
341 + 'mobileTitle' => 'Mobile-Friendly',
342 + 'mobileDesc' => 'Each block can be tweaked to provide a consistent experience across all devices.',
343 + ],
344 + 'details' => [
345 + 's1Title' => 'A Better Page Building Experience',
346 + 's1Text' => 'Otter can be used to build everything from a personal blog to an e-commerce site without losing the personal touch. Otter’s ease of use transforms basic blocks into expressive layouts in seconds.',
347 + 's2Title' => 'A New Collection of Patterns',
348 + 's2Text' => 'A New Patterns Library, containing a range of different elements in a variety of styles to help you build great pages. All of your website’s most important areas are covered: headers, testimonials, pricing tables, sections and more.',
349 + 's3Title' => 'Advanced Blocks',
350 + 's3Text' => 'Enhance your website’s design with powerful blocks, like the Add to Cart, Business Hours, Review Comparison, and dozens of WooCommerce blocks.',
351 + ],
352 + 'testimonials' => [
353 + 'heading' => 'Trusted by more than 300K website owners',
354 + 'users' => [
355 + 'user_1' => 'Loved the collection of blocks. If you want to create nice Gutenberg Pages, this plugin will be very handy and useful.',
356 + 'user_2' => 'I am very satisfied with Otter – a fantastic collection of blocks. And the plugin is perfectly integrated with Gutenberg and complete enough for my needs.',
357 + 'user_3' => 'Otter Blocks work really well and I like the customization options. Easy to use and format to fit in with my site theme – and I’ve not encountered any compatibility or speed issues.',
358 + ],
359 + ],
360 + ],
361 + ],
362 + 'float_widget' => [
363 + 'button' => 'Toggle Help Widget for %s',
364 + 'panel' => [
365 + 'greeting' => 'Thank you for using %s',
366 + 'title' => 'How can we help you?',
367 + 'close' => 'Close Toggle Help Widget',
368 + ],
369 + 'links' => [
370 + 'documentation' => 'Documentation',
371 + 'support' => 'Get Support',
372 + 'wizard' => 'Run Setup Wizard',
373 + 'upgrade' => 'Upgrade to Pro',
374 + 'feature_request' => 'Suggest a Feature',
375 + 'rate' => 'Rate Us',
376 + ],
377 + ],
59 378 ];
60 379
61 380 /**
62 381 * Initialize the sdk logic.
@@ -61,8 +380,9 @@
61 380 /**
62 381 * Initialize the sdk logic.
63 382 */
64 383 public static function init() {
384 + self::localize_labels();
65 385 if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Loader ) ) {
66 386 self::$instance = new Loader();
67 387 $modules = array_merge( self::$available_modules, apply_filters( 'themeisle_sdk_modules', [] ) );
68 388 foreach ( $modules as $key => $module ) {
@@ -70,12 +390,96 @@
70 390 unset( $modules[ $key ] );
71 391 }
72 392 }
73 393 self::$available_modules = $modules;
394 +
395 + add_action( 'themeisle_sdk_first_activation', array( __CLASS__, 'activate' ) );
396 +
74 397 }
75 398 }
399 +
400 + /**
401 + * Localize the labels.
402 + */
403 + public static function localize_labels() {
404 + $originals = self::$labels;
405 + $all_translations = [];
76 406
407 + global $wp_filter;
408 + if ( isset( $wp_filter['themeisle_sdk_labels'] ) ) {
409 + foreach ( $wp_filter['themeisle_sdk_labels']->callbacks as $priority => $hooks ) {
410 + foreach ( $hooks as $hook ) {
411 + // Each callback gets fresh originals, not previous callback's output
412 + $result = call_user_func( $hook['function'], $originals );
413 + $all_translations[] = $result;
414 + }
415 + }
416 +
417 + // Remove the filter so it doesn't run again via apply_filters
418 + remove_all_filters( 'themeisle_sdk_labels' );
419 + }
420 +
421 + // Merge all results, first real translation wins
422 + self::$labels = self::merge_all_translations( $originals, $all_translations );
423 + }
77 424 /**
425 + * Merge all translations.
426 + *
427 + * @param array $originals The original labels.
428 + * @param array $all_translations The all translations.
429 + *
430 + * @return array The merged labels.
431 + */
432 + private static function merge_all_translations( $originals, $all_translations ) {
433 + $result = $originals;
434 +
435 + foreach ( $all_translations as $translations ) {
436 + $result = self::merge_if_translated( $result, $translations, $originals );
437 + }
438 +
439 + return $result;
440 + }
441 + /**
442 + * Merge if translated.
443 + *
444 + * @param array $current The current labels.
445 + * @param array $new The new labels.
446 + * @param array $originals The original labels.
447 + * @return array The merged labels.
448 + */
449 + private static function merge_if_translated( $current, $new, $originals ) {
450 + foreach ( $new as $key => $value ) {
451 + if ( ! isset( $originals[ $key ] ) ) {
452 + // New key, accept it
453 + if ( ! isset( $current[ $key ] ) ) {
454 + $current[ $key ] = $value;
455 + }
456 + continue;
457 + }
458 +
459 + if ( is_array( $value ) && is_array( $originals[ $key ] ) ) {
460 + $current[ $key ] = self::merge_if_translated(
461 + $current[ $key ],
462 + $value,
463 + $originals[ $key ]
464 + );
465 + } else {
466 + // Only accept if:
467 + // 1. New value is actually translated (differs from original)
468 + // 2. Current value is NOT already translated
469 + $is_new_translated = ( $value !== $originals[ $key ] );
470 + $is_current_untranslated = ( $current[ $key ] === $originals[ $key ] );
471 +
472 + if ( $is_new_translated && $is_current_untranslated ) {
473 + $current[ $key ] = $value;
474 + }
475 + }
476 + }
477 +
478 + return $current;
479 + }
480 +
481 + /**
78 482 * Get cache token used in API requests.
79 483 *
80 484 * @return string Cache token.
81 485 */
@@ -117,8 +521,30 @@
117 521 return self::$instance;
118 522 }
119 523
120 524 /**
525 + * Activate the product routine.
526 + *
527 + * @param string $file The base file of the product.
528 + *
529 + * @return void
530 + */
531 + public static function activate( $file ) {
532 +
533 + $dirname = trailingslashit( dirname( ( $file ) ) );
534 + if ( ! file_exists( $dirname . '_reference.php' ) ) {
535 + return;
536 + }
537 + $reference_data = require_once $dirname . '_reference.php';
538 + if ( ! is_array( $reference_data ) ||
539 + ! isset( $reference_data['key'] ) ||
540 + ! isset( $reference_data['value'] ) ||
541 + ! preg_match( '/^[a-zA-Z0-9_]+_reference_key$/', $reference_data['key'] ) ) {
542 + return;
543 + }
544 + add_option( $reference_data['key'], sanitize_key( $reference_data['value'] ) );
545 + }
546 + /**
121 547 * Get all registered modules by the SDK.
122 548 *
123 549 * @return array Modules available.
124 550 */
@@ -128,9 +554,9 @@
128 554
129 555 /**
130 556 * Get all products using the SDK.
131 557 *
132 - * @return array Products available.
558 + * @return array<Product> Products available.
133 559 */
134 560 public static function get_products() {
135 561 return self::$products;
136 562 }
@@ -142,6 +568,5 @@
142 568 */
143 569 public static function get_version() {
144 570 return self::$version;
145 571 }
146 -
147 572 }