| @@ -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,9 @@ | ||
| 45 | 45 | * |
| 46 | 46 | * @var array The modules which SDK will be using. |
| 47 | 47 | */ |
| 48 | 48 | private static $available_modules = [ |
| 49 | + 'crash_reporter', | |
| 49 | 50 | 'script_loader', |
| 50 | 51 | 'dashboard_widget', |
| 51 | 52 | 'rollback', |
| 52 | 53 | 'uninstall_feedback', |
| @@ -52,8 +53,9 @@ | ||
| 52 | 53 | 'uninstall_feedback', |
| 53 | 54 | 'licenser', |
| 54 | 55 | 'logger', |
| 55 | 56 | 'translate', |
| 57 | + 'translations', | |
| 56 | 58 | 'review', |
| 57 | 59 | 'recommendation', |
| 58 | 60 | 'notification', |
| 59 | 61 | 'promotions', |
| @@ -61,8 +63,10 @@ | ||
| 61 | 63 | 'compatibilities', |
| 62 | 64 | 'about_us', |
| 63 | 65 | 'announcements', |
| 64 | 66 | 'featured_plugins', |
| 67 | + 'float_widget', | |
| 68 | + 'migrator', | |
| 65 | 69 | ]; |
| 66 | 70 | /** |
| 67 | 71 | * Holds the labels for the modules. |
| 68 | 72 | * |
| @@ -69,12 +73,13 @@ | ||
| 69 | 73 | * @var array The labels for the modules. |
| 70 | 74 | */ |
| 71 | 75 | public static $labels = [ |
| 72 | 76 | 'announcements' => [ |
| 73 | - 'hurry_up' => 'Hurry up! Only %s left.', | |
| 74 | - 'sale_live' => 'Themeisle Black Friday Sale is Live!', | |
| 75 | - 'learn_more' => 'Learn more', | |
| 76 | - 'max_savings' => 'Enjoy Maximum Savings on %s', | |
| 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', | |
| 77 | 82 | ], |
| 78 | 83 | 'compatibilities' => [ |
| 79 | 84 | 'notice' => '%s requires a newer version of %s. Please %supdate%s %s %s to the latest version.', |
| 80 | 85 | 'notice2' => '%s update requires a newer version of %s. Please %supdate%s %s %s.', |
| @@ -105,16 +110,28 @@ | ||
| 105 | 110 | 'autoactivate_notice' => '%s has been successfully activated using %s license !', |
| 106 | 111 | 'valid' => 'Valid', |
| 107 | 112 | 'invalid' => 'Invalid', |
| 108 | 113 | 'notice' => 'Enter your license from %s purchase history in order to get %s updates', |
| 109 | - 'expired' => 'Your %s\'s License Key has expired. In order to continue receiving support and software updates you must %srenew%s your license key.', | |
| 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.', | |
| 110 | 117 | |
| 111 | 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.', |
| 112 | 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', | |
| 113 | 122 | ], |
| 114 | 123 | 'promotions' => [ |
| 115 | - 'recommended' => 'Recommended by %s', | |
| 116 | - 'woo' => [ | |
| 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' => [ | |
| 117 | 134 | 'title' => 'More extensions from Themeisle', |
| 118 | 135 | 'title2' => 'Recommended extensions', |
| 119 | 136 | 'cta_install' => 'Install', |
| 120 | 137 | 'learn_more' => 'Learn More', |
| @@ -127,25 +144,48 @@ | ||
| 127 | 144 | 'spark_desc1' => 'Loyalize your customers by allowing them to save their favorite products.', |
| 128 | 145 | 'spark_desc2' => 'Add a top notification bar on your website to highlight the latest products, offers, or upcoming events.', |
| 129 | 146 | 'spark_desc3' => 'Enable an advanced review section, enlarging the basic review options with lots of capabilities.', |
| 130 | 147 | ], |
| 131 | - 'optimole' => [ | |
| 132 | - 'all_set' => 'Awesome! You are all set!', | |
| 133 | - 'gotodash' => 'Go to Optimole dashboard', | |
| 134 | - 'installing' => 'Installing', | |
| 135 | - 'activating' => 'Activating', | |
| 136 | - 'connecting' => 'Connecting to API', | |
| 137 | - 'start_cta' => 'Start using Optimole', | |
| 138 | - 'dismisscta' => 'Dismiss this notice.', | |
| 139 | - 'gst' => 'Get Started Free', | |
| 140 | - 'heading' => 'Get more with Optimole', | |
| 141 | - 'learnmore' => 'Learn more', | |
| 142 | - 'message1' => 'Increase this page speed and SEO ranking by optimizing images with Optimole.', | |
| 143 | - 'message3' => 'Save your server space by storing images to Optimole and deliver them optimized from 400 locations around the globe. Unlimited images, Unlimited traffic.', | |
| 144 | - 'message4' => 'This image looks to be too large and would affect your site speed, we recommend you to install Optimole to optimize your images.', | |
| 145 | - 'message2' => 'Leverage Optimole\'s full integration with Elementor to automatically lazyload, resize, compress to AVIF/WebP and deliver from 400 locations around the globe!', | |
| 146 | - 'email_placeholder' => 'Email address', | |
| 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.', | |
| 147 | 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 | + ], | |
| 148 | 188 | ], |
| 149 | 189 | 'welcome' => [ |
| 150 | 190 | 'ctan' => 'No, thanks.', |
| 151 | 191 | 'ctay' => 'Upgrade Now!', |
| @@ -158,13 +198,14 @@ | ||
| 158 | 198 | 'cta_info' => 'What info do we collect?', |
| 159 | 199 | 'button_submit' => 'Submit & Deactivate', |
| 160 | 200 | 'button_cancel' => 'Skip & Deactivate', |
| 161 | 201 | 'disclosure' => [ |
| 162 | - '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.', | |
| 163 | - 'version' => '%s %s version %s %s %s %s', | |
| 164 | - 'website' => '%sCurrent website:%s %s %s %s', | |
| 165 | - 'usage' => '%sUsage time:%s %s %s%s', | |
| 166 | - 'reason' => '%s Uninstall reason %s %s Selected reason from the above survey %s ', | |
| 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.', | |
| 167 | 208 | ], |
| 168 | 209 | |
| 169 | 210 | 'options' => [ |
| 170 | 211 | 'id3' => [ |
| @@ -215,11 +256,11 @@ | ||
| 215 | 256 | 'rollback' => [ |
| 216 | 257 | 'cta' => 'Rollback to v%s', |
| 217 | 258 | ], |
| 218 | 259 | 'logger' => [ |
| 219 | - 'notice' => 'Do you enjoy <b>{product}</b>? Become a contributor by opting in to our anonymous data tracking. We guarantee no sensitive data is collected.', | |
| 220 | - 'cta_y' => 'Sure, I would love to help.', | |
| 221 | - 'cta_n' => 'No, thanks.', | |
| 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', | |
| 222 | 263 | ], |
| 223 | 264 | 'about_us' => [ |
| 224 | 265 | 'title' => 'About Us', |
| 225 | 266 | 'heroHeader' => 'Our Story', |
| @@ -228,8 +269,44 @@ | ||
| 228 | 269 | 'teamImageCaption' => 'Our team in WCEU2022 in Portugal', |
| 229 | 270 | 'newsHeading' => 'Stay connected for news & updates!', |
| 230 | 271 | 'emailPlaceholder' => 'Your email address', |
| 231 | 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 | + ], | |
| 232 | 309 | 'installNow' => 'Install Now', |
| 233 | 310 | 'activate' => 'Activate', |
| 234 | 311 | 'learnMore' => 'Learn More', |
| 235 | 312 | 'installed' => 'Installed', |
| @@ -275,8 +352,24 @@ | ||
| 275 | 352 | ], |
| 276 | 353 | ], |
| 277 | 354 | ], |
| 278 | 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 | + ], | |
| 279 | 372 | ]; |
| 280 | 373 | |
| 281 | 374 | /** |
| 282 | 375 | * Initialize the sdk logic. |
| @@ -281,12 +374,9 @@ | ||
| 281 | 374 | /** |
| 282 | 375 | * Initialize the sdk logic. |
| 283 | 376 | */ |
| 284 | 377 | public static function init() { |
| 285 | - /** | |
| 286 | - * This filter can be used to localize the labels inside each product. | |
| 287 | - */ | |
| 288 | - self::$labels = apply_filters( 'themeisle_sdk_labels', self::$labels ); | |
| 378 | + self::localize_labels(); | |
| 289 | 379 | if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Loader ) ) { |
| 290 | 380 | self::$instance = new Loader(); |
| 291 | 381 | $modules = array_merge( self::$available_modules, apply_filters( 'themeisle_sdk_modules', [] ) ); |
| 292 | 382 | foreach ( $modules as $key => $module ) { |
| @@ -294,12 +384,96 @@ | ||
| 294 | 384 | unset( $modules[ $key ] ); |
| 295 | 385 | } |
| 296 | 386 | } |
| 297 | 387 | self::$available_modules = $modules; |
| 388 | + | |
| 389 | + add_action( 'themeisle_sdk_first_activation', array( __CLASS__, 'activate' ) ); | |
| 390 | + | |
| 298 | 391 | } |
| 299 | 392 | } |
| 393 | + | |
| 394 | + /** | |
| 395 | + * Localize the labels. | |
| 396 | + */ | |
| 397 | + public static function localize_labels() { | |
| 398 | + $originals = self::$labels; | |
| 399 | + $all_translations = []; | |
| 300 | 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 | + } | |
| 301 | 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 | + /** | |
| 302 | 476 | * Get cache token used in API requests. |
| 303 | 477 | * |
| 304 | 478 | * @return string Cache token. |
| 305 | 479 | */ |
| @@ -341,8 +515,30 @@ | ||
| 341 | 515 | return self::$instance; |
| 342 | 516 | } |
| 343 | 517 | |
| 344 | 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 | + /** | |
| 345 | 541 | * Get all registered modules by the SDK. |
| 346 | 542 | * |
| 347 | 543 | * @return array Modules available. |
| 348 | 544 | */ |
| @@ -352,9 +548,9 @@ | ||
| 352 | 548 | |
| 353 | 549 | /** |
| 354 | 550 | * Get all products using the SDK. |
| 355 | 551 | * |
| 356 | - * @return array Products available. | |
| 552 | + * @return array<Product> Products available. | |
| 357 | 553 | */ |
| 358 | 554 | public static function get_products() { |
| 359 | 555 | return self::$products; |
| 360 | 556 | } |