PluginProbe ʕ •ᴥ•ʔ
Robin Image Optimizer – Unlimited Image Optimization, WebP & AVIF / 2.0.6
Robin Image Optimizer – Unlimited Image Optimization, WebP & AVIF v2.0.6
2.0.6 2.0.5 trunk 1.3.7 1.4.0 1.4.1 1.4.2 1.4.6 1.5.0 1.5.3 1.5.6 1.5.8 1.6.5 1.6.6 1.6.9 1.7.0 1.7.4 1.8.1 1.8.2 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4
robin-image-optimizer / vendor / codeinwp / themeisle-sdk / src / Loader.php
robin-image-optimizer / vendor / codeinwp / themeisle-sdk / src Last commit date
Common 1 month ago Modules 1 month ago Loader.php 1 month ago Product.php 1 month ago
Loader.php
567 lines
1 <?php
2 /**
3 * The main loader class for ThemeIsle SDK
4 *
5 * @package ThemeIsleSDK
6 * @subpackage Loader
7 * @copyright Copyright (c) 2017, Marius Cristea
8 * @license http://opensource.org/licenses/gpl-3.0.php GNU Public License
9 * @since 1.0.0
10 */
11
12 namespace ThemeisleSDK;
13
14 use ThemeisleSDK\Common\Module_Factory;
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit;
18 }
19
20
21 /**
22 * Singleton loader for ThemeIsle SDK.
23 */
24 final class Loader {
25 /**
26 * Singleton instance.
27 *
28 * @var Loader instance The singleton instance
29 */
30 private static $instance;
31 /**
32 * Current loader version.
33 *
34 * @var string $version The class version.
35 */
36 private static $version = '2.0.0';
37 /**
38 * Holds registered products.
39 *
40 * @var array<Product> The products which use the SDK.
41 */
42 private static $products = [];
43 /**
44 * Holds available modules to load.
45 *
46 * @var array The modules which SDK will be using.
47 */
48 private static $available_modules = [
49 'crash_reporter',
50 'script_loader',
51 'dashboard_widget',
52 'rollback',
53 'uninstall_feedback',
54 'licenser',
55 'logger',
56 'translate',
57 'translations',
58 'review',
59 'recommendation',
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.',
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 ],
189 'welcome' => [
190 'ctan' => 'No, thanks.',
191 'ctay' => 'Upgrade Now!',
192 '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>',
193 ],
194 'uninstall' => [
195 'heading_plugin' => 'What\'s wrong?',
196 'heading_theme' => 'What does not work for you in {theme}?',
197 'submit' => 'Submit',
198 'cta_info' => 'What info do we collect?',
199 'button_submit' => 'Submit &amp; Deactivate',
200 'button_cancel' => 'Skip &amp; Deactivate',
201 'disclosure' => [
202 '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.',
203 'version' => '%s %s version %s %s %s %s',
204 'website' => '%sCurrent website:%s %s %s %s',
205 'usage' => '%sUsage time:%s %s %s%s',
206 'reason' => '%s Uninstall reason %s %s Selected reason from the above survey %s ',
207 'diagnostics' => '%sCrash diagnostics:%s Anonymized technical details of errors recorded for this product, if any.',
208 ],
209
210 'options' => [
211 'id3' => [
212 'title' => 'I found a better plugin',
213 'placeholder' => 'What\'s the plugin\'s name?',
214 ],
215 'id4' => [
216
217 'title' => 'I could not get the plugin to work',
218 'placeholder' => 'What problem are you experiencing?',
219 ],
220 'id5' => [
221
222 'title' => 'I no longer need the plugin',
223 'placeholder' => 'If you could improve one thing about our product, what would it be?',
224 ],
225 'id6' => [
226 'title' => 'It\'s a temporary deactivation. I\'m just debugging an issue.',
227 'placeholder' => 'What problem are you experiencing?',
228 ],
229 'id7' => [
230 'title' => 'I don\'t know how to make it look like demo',
231 ],
232 'id8' => [
233
234 'placeholder' => 'What option is missing?',
235 'title' => 'It lacks options',
236 ],
237 'id9' => [
238 'title' => 'Is not working with a plugin that I need',
239 'placeholder' => 'What is the name of the plugin',
240 ],
241 'id10' => [
242 'title' => 'I want to try a new design, I don\'t like {theme} style',
243 ],
244 'id999' => [
245 'title' => 'Other',
246 'placeholder' => 'What can we do better?',
247 ],
248 ],
249 ],
250 'review' => [
251 '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>',
252 'ctay' => 'Ok, I will gladly help.',
253 'ctan' => 'No, thanks.',
254
255 ],
256 'rollback' => [
257 'cta' => 'Rollback to v%s',
258 ],
259 'logger' => [
260 'notice' => 'Help improve <b>{product}</b> by sharing anonymous usage data about your setup. No personal data collected.',
261 'cta_y' => 'Count me in',
262 'cta_n' => 'No thanks',
263 ],
264 'about_us' => [
265 'title' => 'About Us',
266 'heroHeader' => 'Our Story',
267 '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.',
268 '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.',
269 'teamImageCaption' => 'Our team in WCEU2022 in Portugal',
270 'newsHeading' => 'Stay connected for news & updates!',
271 'emailPlaceholder' => 'Your email address',
272 'signMeUp' => 'Sign me up',
273 'services' => [
274 'ariaLabel' => 'Themeisle services',
275 'trustpilotLabel' => 'Rated excellent on Trustpilot',
276 'trustpilotRated' => 'Rated',
277 'trustpilotOn' => 'on',
278 'trustpilotBrand' => 'Trustpilot',
279 'heading' => 'Expert WordPress services from the Themeisle team',
280 'description' => 'Done for you by the same people who build your plugins and themes.',
281 'cta' => 'Explore all services',
282 'items' => [
283 'websiteDesign' => [
284 'title' => 'Website Design',
285 'subtitle' => 'Built for your business',
286 ],
287 'support' => [
288 'title' => 'Support',
289 'subtitle' => 'On-demand expert help',
290 ],
291 'speed' => [
292 'title' => 'Speed Optimization',
293 'subtitle' => 'Core Web Vitals boost',
294 ],
295 'seo' => [
296 'title' => 'SEO Foundation',
297 'subtitle' => 'Rank & get found',
298 ],
299 'maintenance' => [
300 'title' => 'Maintenance',
301 'subtitle' => 'Updates, backups, security',
302 ],
303 'hackedSite' => [
304 'title' => 'Hacked Site Repair',
305 'subtitle' => 'Malware removed fast',
306 ],
307 ],
308 ],
309 'installNow' => 'Install Now',
310 'activate' => 'Activate',
311 'learnMore' => 'Learn More',
312 'installed' => 'Installed',
313 'notInstalled' => 'Not Installed',
314 'active' => 'Active',
315 'others' => [
316 '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.',
317 'neve_desc' => 'A fast, lightweight, customizable WordPress theme offering responsive design, speed, and flexibility for various website types.',
318 'landingkit_desc' => 'Turn WordPress into a landing page powerhouse with Landing Kit, map domains to pages or any other published resource.',
319 'sparks_desc' => 'Extend your store functionality with 8 ultra-performant features like product comparisons, variation swatches, wishlist, and more.',
320 'tpc_desc' => 'Design, save, and revisit your templates anytime with your personal vault on Templates Cloud.',
321 ],
322 'otter-page' => [
323 'heading' => 'Build innovative layouts with Otter Blocks and Gutenberg',
324 'text' => 'Otter is a lightweight, dynamic collection of page building blocks and templates for the WordPress block editor.',
325 'buttons' => [
326 'install_otter_free' => "Install Otter - It's free!",
327 'install_now' => 'Install Now',
328 'learn_more' => 'Learn More',
329 ],
330 'features' => [
331 'advancedTitle' => 'Advanced Features',
332 'advancedDesc' => 'Add features such as Custom CSS, Animations & Visibility Conditions to all blocks.',
333 'fastTitle' => 'Lightweight and Fast',
334 'fastDesc' => 'Otter enhances WordPress site building experience without impacting site speed.',
335 'mobileTitle' => 'Mobile-Friendly',
336 'mobileDesc' => 'Each block can be tweaked to provide a consistent experience across all devices.',
337 ],
338 'details' => [
339 's1Title' => 'A Better Page Building Experience',
340 '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.',
341 's2Title' => 'A New Collection of Patterns',
342 '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.',
343 's3Title' => 'Advanced Blocks',
344 's3Text' => 'Enhance your website’s design with powerful blocks, like the Add to Cart, Business Hours, Review Comparison, and dozens of WooCommerce blocks.',
345 ],
346 'testimonials' => [
347 'heading' => 'Trusted by more than 300K website owners',
348 'users' => [
349 'user_1' => 'Loved the collection of blocks. If you want to create nice Gutenberg Pages, this plugin will be very handy and useful.',
350 '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.',
351 '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.',
352 ],
353 ],
354 ],
355 ],
356 'float_widget' => [
357 'button' => 'Toggle Help Widget for %s',
358 'panel' => [
359 'greeting' => 'Thank you for using %s',
360 'title' => 'How can we help you?',
361 'close' => 'Close Toggle Help Widget',
362 ],
363 'links' => [
364 'documentation' => 'Documentation',
365 'support' => 'Get Support',
366 'wizard' => 'Run Setup Wizard',
367 'upgrade' => 'Upgrade to Pro',
368 'feature_request' => 'Suggest a Feature',
369 'rate' => 'Rate Us',
370 ],
371 ],
372 ];
373
374 /**
375 * Initialize the sdk logic.
376 */
377 public static function init() {
378 self::localize_labels();
379 if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Loader ) ) {
380 self::$instance = new Loader();
381 $modules = array_merge( self::$available_modules, apply_filters( 'themeisle_sdk_modules', [] ) );
382 foreach ( $modules as $key => $module ) {
383 if ( ! class_exists( 'ThemeisleSDK\\Modules\\' . ucwords( $module, '_' ) ) ) {
384 unset( $modules[ $key ] );
385 }
386 }
387 self::$available_modules = $modules;
388
389 add_action( 'themeisle_sdk_first_activation', array( __CLASS__, 'activate' ) );
390
391 }
392 }
393
394 /**
395 * Localize the labels.
396 */
397 public static function localize_labels() {
398 $originals = self::$labels;
399 $all_translations = [];
400
401 global $wp_filter;
402 if ( isset( $wp_filter['themeisle_sdk_labels'] ) ) {
403 foreach ( $wp_filter['themeisle_sdk_labels']->callbacks as $priority => $hooks ) {
404 foreach ( $hooks as $hook ) {
405 // Each callback gets fresh originals, not previous callback's output
406 $result = call_user_func( $hook['function'], $originals );
407 $all_translations[] = $result;
408 }
409 }
410
411 // Remove the filter so it doesn't run again via apply_filters
412 remove_all_filters( 'themeisle_sdk_labels' );
413 }
414
415 // Merge all results, first real translation wins
416 self::$labels = self::merge_all_translations( $originals, $all_translations );
417 }
418 /**
419 * Merge all translations.
420 *
421 * @param array $originals The original labels.
422 * @param array $all_translations The all translations.
423 *
424 * @return array The merged labels.
425 */
426 private static function merge_all_translations( $originals, $all_translations ) {
427 $result = $originals;
428
429 foreach ( $all_translations as $translations ) {
430 $result = self::merge_if_translated( $result, $translations, $originals );
431 }
432
433 return $result;
434 }
435 /**
436 * Merge if translated.
437 *
438 * @param array $current The current labels.
439 * @param array $new The new labels.
440 * @param array $originals The original labels.
441 * @return array The merged labels.
442 */
443 private static function merge_if_translated( $current, $new, $originals ) {
444 foreach ( $new as $key => $value ) {
445 if ( ! isset( $originals[ $key ] ) ) {
446 // New key, accept it
447 if ( ! isset( $current[ $key ] ) ) {
448 $current[ $key ] = $value;
449 }
450 continue;
451 }
452
453 if ( is_array( $value ) && is_array( $originals[ $key ] ) ) {
454 $current[ $key ] = self::merge_if_translated(
455 $current[ $key ],
456 $value,
457 $originals[ $key ]
458 );
459 } else {
460 // Only accept if:
461 // 1. New value is actually translated (differs from original)
462 // 2. Current value is NOT already translated
463 $is_new_translated = ( $value !== $originals[ $key ] );
464 $is_current_untranslated = ( $current[ $key ] === $originals[ $key ] );
465
466 if ( $is_new_translated && $is_current_untranslated ) {
467 $current[ $key ] = $value;
468 }
469 }
470 }
471
472 return $current;
473 }
474
475 /**
476 * Get cache token used in API requests.
477 *
478 * @return string Cache token.
479 */
480 public static function get_cache_token() {
481 $cache_token = get_transient( 'themeisle_sdk_cache_token' );
482 if ( false === $cache_token ) {
483 $cache_token = wp_generate_password( 6, false );
484 set_transient( $cache_token, WEEK_IN_SECONDS );
485 }
486
487 return $cache_token;
488 }
489
490 /**
491 * Clear cache token.
492 */
493 public static function clear_cache_token() {
494 delete_transient( 'themeisle_sdk_cache_token' );
495 }
496
497 /**
498 * Register product into SDK.
499 *
500 * @param string $base_file The product base file.
501 *
502 * @return Loader The singleton object.
503 */
504 public static function add_product( $base_file ) {
505
506 if ( ! is_file( $base_file ) ) {
507 return self::$instance;
508 }
509 $product = new Product( $base_file );
510
511 Module_Factory::attach( $product, self::get_modules() );
512
513 self::$products[ $product->get_slug() ] = $product;
514
515 return self::$instance;
516 }
517
518 /**
519 * Activate the product routine.
520 *
521 * @param string $file The base file of the product.
522 *
523 * @return void
524 */
525 public static function activate( $file ) {
526
527 $dirname = trailingslashit( dirname( ( $file ) ) );
528 if ( ! file_exists( $dirname . '_reference.php' ) ) {
529 return;
530 }
531 $reference_data = require_once $dirname . '_reference.php';
532 if ( ! is_array( $reference_data ) ||
533 ! isset( $reference_data['key'] ) ||
534 ! isset( $reference_data['value'] ) ||
535 ! preg_match( '/^[a-zA-Z0-9_]+_reference_key$/', $reference_data['key'] ) ) {
536 return;
537 }
538 add_option( $reference_data['key'], sanitize_key( $reference_data['value'] ) );
539 }
540 /**
541 * Get all registered modules by the SDK.
542 *
543 * @return array Modules available.
544 */
545 public static function get_modules() {
546 return self::$available_modules;
547 }
548
549 /**
550 * Get all products using the SDK.
551 *
552 * @return array<Product> Products available.
553 */
554 public static function get_products() {
555 return self::$products;
556 }
557
558 /**
559 * Get the version of the SDK.
560 *
561 * @return string The version.
562 */
563 public static function get_version() {
564 return self::$version;
565 }
566 }
567