Changeset 3844084
- Timestamp:
- 12/04/2026 09:33:51 AM (less than one hour ago)
- Location:
- clonable
- Files:
-
- 186 added
- 15 edited
-
tags/2.16.0 (added)
-
tags/2.16.0/Bootstrap.php (added)
-
tags/2.16.0/assets (added)
-
tags/2.16.0/assets/css (added)
-
tags/2.16.0/assets/css/clonable-admin-bar.css (added)
-
tags/2.16.0/assets/css/clonable-extra-button.css (added)
-
tags/2.16.0/assets/css/clonable-global.css (added)
-
tags/2.16.0/assets/css/clonable-language-switcher.css (added)
-
tags/2.16.0/assets/css/clonable-language-switcher_mod.css (added)
-
tags/2.16.0/assets/css/clonable-search-expandable.css (added)
-
tags/2.16.0/assets/css/clonable-search-icon.css (added)
-
tags/2.16.0/assets/css/clonable-search.css (added)
-
tags/2.16.0/assets/css/clonable-support-chat.css (added)
-
tags/2.16.0/assets/css/clonable-thumbnails.css (added)
-
tags/2.16.0/assets/css/clonable-woocommerce.css (added)
-
tags/2.16.0/assets/css/clonable.css (added)
-
tags/2.16.0/assets/css/fomantic-dropdown.css (added)
-
tags/2.16.0/assets/css/fomantic-transition.css (added)
-
tags/2.16.0/assets/css/freakflags.css (added)
-
tags/2.16.0/assets/css/index.php (added)
-
tags/2.16.0/assets/js (added)
-
tags/2.16.0/assets/js/alpine.js (added)
-
tags/2.16.0/assets/js/clonable-search-expandable.js (added)
-
tags/2.16.0/assets/js/clonable-search.js (added)
-
tags/2.16.0/assets/js/clonable-support-chat.js (added)
-
tags/2.16.0/assets/js/dohjs.js (added)
-
tags/2.16.0/assets/js/email-translations.js (added)
-
tags/2.16.0/assets/js/fomantic-dropdown.js (added)
-
tags/2.16.0/assets/js/fomantic-transition.js (added)
-
tags/2.16.0/assets/js/fuse.js (added)
-
tags/2.16.0/assets/js/index.php (added)
-
tags/2.16.0/assets/js/language-switcher.js (added)
-
tags/2.16.0/assets/js/onload.js (added)
-
tags/2.16.0/assets/js/woocommerce-clone-field.js (added)
-
tags/2.16.0/clonable-wp.php (added)
-
tags/2.16.0/compat (added)
-
tags/2.16.0/compat/clone-cache-key.php (added)
-
tags/2.16.0/compat/index.php (added)
-
tags/2.16.0/controllers (added)
-
tags/2.16.0/controllers/Controller.php (added)
-
tags/2.16.0/controllers/DashboardController.php (added)
-
tags/2.16.0/controllers/EmailTranslationsController.php (added)
-
tags/2.16.0/controllers/ExclusionsController.php (added)
-
tags/2.16.0/controllers/LandingPageController.php (added)
-
tags/2.16.0/controllers/LanguageSwitcherController.php (added)
-
tags/2.16.0/controllers/LanguageTagController.php (added)
-
tags/2.16.0/controllers/MultiCurrencyController.php (added)
-
tags/2.16.0/controllers/SearchEngineController.php (added)
-
tags/2.16.0/controllers/SettingController.php (added)
-
tags/2.16.0/controllers/WoocommerceController.php (added)
-
tags/2.16.0/controllers/index.php (added)
-
tags/2.16.0/enums (added)
-
tags/2.16.0/enums/ContentType.php (added)
-
tags/2.16.0/enums/DeploymentType.php (added)
-
tags/2.16.0/enums/ExclusionMethod.php (added)
-
tags/2.16.0/enums/PageType.php (added)
-
tags/2.16.0/enums/Route.php (added)
-
tags/2.16.0/exceptions (added)
-
tags/2.16.0/exceptions/ApiException.php (added)
-
tags/2.16.0/exceptions/CurlException.php (added)
-
tags/2.16.0/exceptions/ValidationException.php (added)
-
tags/2.16.0/helpers (added)
-
tags/2.16.0/helpers/Functions.php (added)
-
tags/2.16.0/helpers/Html.php (added)
-
tags/2.16.0/helpers/Json.php (added)
-
tags/2.16.0/helpers/Locales.php (added)
-
tags/2.16.0/helpers/MultiCurrency.php (added)
-
tags/2.16.0/helpers/PriceRounding.php (added)
-
tags/2.16.0/helpers/Session.php (added)
-
tags/2.16.0/helpers/TextTranslator.php (added)
-
tags/2.16.0/helpers/UrlTranslator.php (added)
-
tags/2.16.0/helpers/clonable-locales-list.php (added)
-
tags/2.16.0/helpers/index.php (added)
-
tags/2.16.0/images (added)
-
tags/2.16.0/images/Logo_Icon_white.png (added)
-
tags/2.16.0/images/Logo_Icon_white.svg (added)
-
tags/2.16.0/images/clonable-full-logo.png (added)
-
tags/2.16.0/images/clonable.png (added)
-
tags/2.16.0/images/configure-wordpress-thumbnail.png (added)
-
tags/2.16.0/images/flags.png (added)
-
tags/2.16.0/images/index.php (added)
-
tags/2.16.0/images/language-switcher-thumbnail.png (added)
-
tags/2.16.0/index.php (added)
-
tags/2.16.0/middleware (added)
-
tags/2.16.0/middleware/Auth.php (added)
-
tags/2.16.0/middleware/ClonedSite.php (added)
-
tags/2.16.0/middleware/MiddlewareHandler.php (added)
-
tags/2.16.0/middleware/MiddlewareInterface.php (added)
-
tags/2.16.0/middleware/WooCommerce.php (added)
-
tags/2.16.0/middleware/index.php (added)
-
tags/2.16.0/models (added)
-
tags/2.16.0/models/ApiKey.php (added)
-
tags/2.16.0/models/ClonableWooCommerce.php (added)
-
tags/2.16.0/models/ClonedSite.php (added)
-
tags/2.16.0/models/EmailTranslations.php (added)
-
tags/2.16.0/models/Exclusions.php (added)
-
tags/2.16.0/models/LanguageSwitcher.php (added)
-
tags/2.16.0/models/LanguageTag.php (added)
-
tags/2.16.0/models/MultiCurrency.php (added)
-
tags/2.16.0/models/SearchEngine.php (added)
-
tags/2.16.0/models/Settings.php (added)
-
tags/2.16.0/models/Site.php (added)
-
tags/2.16.0/models/index.php (added)
-
tags/2.16.0/objects (added)
-
tags/2.16.0/objects/ApiResponse.php (added)
-
tags/2.16.0/objects/CircuitBreaker.php (added)
-
tags/2.16.0/objects/ClonableConfig.php (added)
-
tags/2.16.0/objects/ClonableResponse.php (added)
-
tags/2.16.0/objects/CurlBuilder.php (added)
-
tags/2.16.0/objects/ExcludedProductTerm.php (added)
-
tags/2.16.0/objects/MailHeaders.php (added)
-
tags/2.16.0/objects/Notification.php (added)
-
tags/2.16.0/objects/Searchable.php (added)
-
tags/2.16.0/objects/index.php (added)
-
tags/2.16.0/readme-da_DK.txt (added)
-
tags/2.16.0/readme-de_DE.txt (added)
-
tags/2.16.0/readme-es_ES.txt (added)
-
tags/2.16.0/readme-fr_FR.txt (added)
-
tags/2.16.0/readme-it_IT.txt (added)
-
tags/2.16.0/readme-nb_NO.txt (added)
-
tags/2.16.0/readme-nl_NL.txt (added)
-
tags/2.16.0/readme-sv_SE.txt (added)
-
tags/2.16.0/readme.txt (added)
-
tags/2.16.0/routes (added)
-
tags/2.16.0/routes/Router.php (added)
-
tags/2.16.0/routes/index.php (added)
-
tags/2.16.0/services (added)
-
tags/2.16.0/services/AdminUIService.php (added)
-
tags/2.16.0/services/AllowedHostsService.php (added)
-
tags/2.16.0/services/ApiService.php (added)
-
tags/2.16.0/services/CacheService.php (added)
-
tags/2.16.0/services/ClonableWooCommerceService.php (added)
-
tags/2.16.0/services/EmailTranslationsService.php (added)
-
tags/2.16.0/services/LanguageSwitcherService.php (added)
-
tags/2.16.0/services/LanguageTagService.php (added)
-
tags/2.16.0/services/LocaleService.php (added)
-
tags/2.16.0/services/MigrationService.php (added)
-
tags/2.16.0/services/MultiCurrencyService.php (added)
-
tags/2.16.0/services/SearchEngineService.php (added)
-
tags/2.16.0/services/SearchIndexAssembler.php (added)
-
tags/2.16.0/services/SearchIndexCache.php (added)
-
tags/2.16.0/services/SearchIndexMerger.php (added)
-
tags/2.16.0/services/SearchIndexPartWriter.php (added)
-
tags/2.16.0/services/SearchIndexResponder.php (added)
-
tags/2.16.0/services/ShortCodeService.php (added)
-
tags/2.16.0/services/SubfolderService.php (added)
-
tags/2.16.0/services/SupportChatService.php (added)
-
tags/2.16.0/services/SyncService.php (added)
-
tags/2.16.0/services/WpRocketCacheService.php (added)
-
tags/2.16.0/services/index.php (added)
-
tags/2.16.0/services/modules (added)
-
tags/2.16.0/services/modules/DataPanelModule.php (added)
-
tags/2.16.0/services/modules/ExclusionModule.php (added)
-
tags/2.16.0/services/modules/PriceAdjustmentModule.php (added)
-
tags/2.16.0/services/modules/ProductImporterModule.php (added)
-
tags/2.16.0/services/modules/TaxonomyModule.php (added)
-
tags/2.16.0/services/modules/index.php (added)
-
tags/2.16.0/traits (added)
-
tags/2.16.0/traits/Forms.php (added)
-
tags/2.16.0/traits/HasSections.php (added)
-
tags/2.16.0/traits/PluginCheck.php (added)
-
tags/2.16.0/traits/Validation.php (added)
-
tags/2.16.0/traits/index.php (added)
-
tags/2.16.0/uninstall.php (added)
-
tags/2.16.0/views (added)
-
tags/2.16.0/views/DashboardView.php (added)
-
tags/2.16.0/views/EmailTranslationsView.php (added)
-
tags/2.16.0/views/ExclusionsView.php (added)
-
tags/2.16.0/views/LanguageSwitcherView.php (added)
-
tags/2.16.0/views/LanguageTagView.php (added)
-
tags/2.16.0/views/Layout.php (added)
-
tags/2.16.0/views/MultiCurrencyView.php (added)
-
tags/2.16.0/views/OnboardingView.php (added)
-
tags/2.16.0/views/SearchEngineView.php (added)
-
tags/2.16.0/views/SectionedViewInterface.php (added)
-
tags/2.16.0/views/SettingsView.php (added)
-
tags/2.16.0/views/ViewInterface.php (added)
-
tags/2.16.0/views/WoocommerceView.php (added)
-
tags/2.16.0/views/css (added)
-
tags/2.16.0/views/css/index.php (added)
-
tags/2.16.0/views/index.php (added)
-
tags/2.16.0/views/scripts (added)
-
tags/2.16.0/views/scripts/index.php (added)
-
trunk/assets/css/clonable-support-chat.css (added)
-
trunk/assets/js/alpine.js (modified) (3 diffs)
-
trunk/assets/js/clonable-support-chat.js (added)
-
trunk/clonable-wp.php (modified) (5 diffs)
-
trunk/readme-da_DK.txt (modified) (2 diffs)
-
trunk/readme-de_DE.txt (modified) (2 diffs)
-
trunk/readme-es_ES.txt (modified) (2 diffs)
-
trunk/readme-fr_FR.txt (modified) (2 diffs)
-
trunk/readme-it_IT.txt (modified) (2 diffs)
-
trunk/readme-nb_NO.txt (modified) (2 diffs)
-
trunk/readme-nl_NL.txt (modified) (2 diffs)
-
trunk/readme-sv_SE.txt (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/services/LanguageSwitcherService.php (modified) (2 diffs)
-
trunk/services/SupportChatService.php (added)
-
trunk/services/SyncService.php (modified) (4 diffs)
-
trunk/views/LanguageSwitcherView.php (modified) (1 diff)
-
trunk/views/Layout.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
clonable/trunk/assets/js/alpine.js
r3770773 r3844084 1 /** 2 * Keep Fomantic dropdowns in Alpine x-for tables in sync with Alpine data. 3 */ 4 (function () { 5 const DROPDOWN_SETTINGS = { fullTextSearch: true }; 6 const watched = new WeakSet(); 7 8 // Get x-model expression of input 9 function modelExpression(input) { 10 const attribute = Array.from(input.attributes).find(function (attr) { 11 return attr.name === 'x-model' || attr.name.startsWith('x-model.'); 12 }); 13 return attribute ? attribute.value : null; 14 } 15 16 function syncDropdowns(container) { 17 if (!window.jQuery || !jQuery.fn.dropdown) return; 18 19 jQuery(container).find('.ui.dropdown').each(function () { 20 const input = Array.from(this.querySelectorAll('input[type="hidden"]')).find(modelExpression); 21 if (!input) return; // Not bound to Alpine data 22 23 const $dropdown = jQuery(this); 24 if (!$dropdown.data('module-dropdown')) { 25 $dropdown.dropdown(DROPDOWN_SETTINGS); 26 } 27 28 const value = Alpine.evaluate(input, modelExpression(input)); 29 const expected = value === null || value === undefined ? '' : String(value); 30 const shown = $dropdown.find('.menu .item.active').attr('data-value') || ''; 31 if (shown === expected) return; 32 33 const hasItem = $dropdown.find('.menu .item').filter(function () { 34 return this.getAttribute('data-value') === expected; 35 }).length > 0; 36 37 if (expected !== '' && hasItem) { 38 $dropdown.dropdown('set selected', expected); 39 } else { 40 $dropdown.dropdown('clear'); 41 } 42 }); 43 } 44 45 // Observe rows of x-for table, sync once after Alpine changed them. 46 function watchTable(template) { 47 const container = template.parentElement; 48 if (!container || watched.has(container)) return; 49 watched.add(container); 50 51 let pending = false; 52 new MutationObserver(function () { 53 if (pending) return; 54 pending = true; 55 // Wait until Alpine finished row scopes + bindings. 56 Alpine.nextTick(function () { 57 pending = false; 58 syncDropdowns(container); 59 }); 60 }).observe(container, { childList: true }); 61 62 if (window.jQuery) { 63 jQuery(function () { 64 syncDropdowns(container); 65 }); 66 } 67 } 68 69 document.addEventListener('alpine:initialized', function () { 70 document.querySelectorAll('template[x-for]').forEach(watchTable); 71 }); 72 })(); 73 1 74 document.addEventListener('alpine:init', () => { 2 75 Alpine.data('languageTags', (languageTags) => ({ … … 28 101 } 29 102 this.languageTagData.data.clones.push(data); 30 jQuery(document).ready(function ($) {31 $('.ui.dropdown')32 .dropdown({ fullTextSearch: true })33 ;34 })35 103 }, 36 104 removeRow(index) { … … 48 116 } 49 117 this.languages.push(data); 50 jQuery(document).ready(function ($) {51 $('.ui.dropdown')52 .dropdown({ fullTextSearch: true })53 ;54 })55 118 }, 56 119 removeRow(index) { -
clonable/trunk/clonable-wp.php
r3823289 r3844084 5 5 Description: Official plugin for improving your clones made with Clonable. 6 6 Plugin URI: https://kb.clonable.net/en/introduction/getting-started/wordpress#de-clonable-plug-in-downloaden 7 Version: 2.1 5.17 Version: 2.16.0 8 8 Author: Clonable BV 9 9 Author URI: https://www.clonable.net … … 36 36 use Clonable\Services\SearchEngineService; 37 37 use Clonable\Services\AdminUIService; // general admin UI service for additions, notices, etc. 38 use Clonable\Services\SupportChatService; 38 39 use Clonable\Services\Modules\ExclusionModule; 39 40 use Clonable\Services\Modules\TaxonomyModule; … … 134 135 require_once 'services/WpRocketCacheService.php'; 135 136 require_once 'services/AdminUIService.php'; // general admin UI service for additions, notices, etc. 137 require_once 'services/SupportChatService.php'; 136 138 require_once 'services/EmailTranslationsService.php'; 137 139 require_once 'services/MigrationService.php'; … … 168 170 define('CLONABLE_NAME', 'Clonable'); 169 171 define('CLONABLE_PLUGIN_BASE', plugin_basename(__FILE__)); 170 define('CLONABLE_VERSION', '2.1 5.1');172 define('CLONABLE_VERSION', '2.16.0'); 171 173 define('CLONABLE_URL', plugin_dir_url(__FILE__)); 172 174 … … 358 360 error_log("[Clonable] Error handling admin UI service: {$exception->getMessage()}"); 359 361 } 362 363 try { 364 $support_chat_service = new SupportChatService(); 365 } catch (\Throwable $exception) { 366 error_log("[Clonable] Error handling support chat service: {$exception->getMessage()}"); 367 } 360 368 } -
clonable/trunk/readme-da_DK.txt
r3823289 r3844084 5 5 Tested up to: 7.1 6 6 Requires PHP: 8.1 7 Stable tag: 2.1 5.17 Stable tag: 2.16.0 8 8 License: GPL v2 or later 9 9 … … 32 32 33 33 == Changelog == 34 v2.16.0 35 Support chatbox inclusion on the Clonable settings pages within WordPress admin 36 Syncing with Clonable no longer re-adds languages removed from the language switcher 37 Some small CMS area bugfixes 38 Language switcher bugfix 39 34 40 v2.15.1 35 41 Language switcher stylesheet modifications -
clonable/trunk/readme-de_DE.txt
r3823289 r3844084 5 5 Tested up to: 7.1 6 6 Requires PHP: 8.1 7 Stable tag: 2.1 5.17 Stable tag: 2.16.0 8 8 License: GPL v2 or later 9 9 … … 32 32 33 33 == Changelog == 34 v2.16.0 35 Support chatbox inclusion on the Clonable settings pages within WordPress admin 36 Syncing with Clonable no longer re-adds languages removed from the language switcher 37 38 Some small CMS area bugfixes 39 34 40 v2.15.1 35 41 Language switcher stylesheet modifications -
clonable/trunk/readme-es_ES.txt
r3823289 r3844084 5 5 Tested up to: 7.1 6 6 Requires PHP: 8.1 7 Stable tag: 2.1 5.17 Stable tag: 2.16.0 8 8 License: GPL v2 or later 9 9 … … 32 32 33 33 == Changelog == 34 v2.16.0 35 Support chatbox inclusion on the Clonable settings pages within WordPress admin 36 Syncing with Clonable no longer re-adds languages removed from the language switcher 37 Some small CMS area bugfixes 38 Language switcher bugfix 39 34 40 v2.15.1 35 41 Language switcher stylesheet modifications -
clonable/trunk/readme-fr_FR.txt
r3823289 r3844084 5 5 Tested up to: 7.1 6 6 Requires PHP: 8.1 7 Stable tag: 2.1 5.17 Stable tag: 2.16.0 8 8 License: GPL v2 or later 9 9 … … 32 32 33 33 == Changelog == 34 v2.16.0 35 Support chatbox inclusion on the Clonable settings pages within WordPress admin 36 Syncing with Clonable no longer re-adds languages removed from the language switcher 37 Some small CMS area bugfixes 38 Language switcher bugfix 39 34 40 v2.15.1 35 41 Language switcher stylesheet modifications -
clonable/trunk/readme-it_IT.txt
r3823289 r3844084 5 5 Tested up to: 7.1 6 6 Requires PHP: 8.1 7 Stable tag: 2.1 5.17 Stable tag: 2.16.0 8 8 License: GPL v2 or later 9 9 … … 32 32 33 33 == Changelog == 34 v2.16.0 35 Support chatbox inclusion on the Clonable settings pages within WordPress admin 36 Syncing with Clonable no longer re-adds languages removed from the language switcher 37 Some small CMS area bugfixes 38 Language switcher bugfix 39 34 40 v2.15.1 35 41 Language switcher stylesheet modifications -
clonable/trunk/readme-nb_NO.txt
r3823289 r3844084 5 5 Tested up to: 7.1 6 6 Requires PHP: 8.1 7 Stable tag: 2.1 5.17 Stable tag: 2.16.0 8 8 License: GPL v2 or later 9 9 … … 32 32 33 33 == Changelog == 34 v2.16.0 35 Support chatbox inclusion on the Clonable settings pages within WordPress admin 36 Syncing with Clonable no longer re-adds languages removed from the language switcher 37 Some small CMS area bugfixes 38 Language switcher bugfix 39 34 40 v2.15.1 35 41 Language switcher stylesheet modifications -
clonable/trunk/readme-nl_NL.txt
r3823289 r3844084 5 5 Tested up to: 7.1 6 6 Requires PHP: 8.1 7 Stable tag: 2.1 5.17 Stable tag: 2.16.0 8 8 License: GPL v2 or later 9 9 … … 32 32 33 33 == Changelog == 34 v2.16.0 35 Support chatbox inclusion on the Clonable settings pages within WordPress admin 36 Syncing with Clonable no longer re-adds languages removed from the language switcher 37 Some small CMS area bugfixes 38 Language switcher bugfix 39 34 40 v2.15.1 35 41 Language switcher stylesheet modifications -
clonable/trunk/readme-sv_SE.txt
r3823289 r3844084 5 5 Tested up to: 7.1 6 6 Requires PHP: 8.1 7 Stable tag: 2.1 5.17 Stable tag: 2.16.0 8 8 License: GPL v2 or later 9 9 … … 32 32 33 33 == Changelog == 34 v2.16.0 35 Support chatbox inclusion on the Clonable settings pages within WordPress admin 36 Syncing with Clonable no longer re-adds languages removed from the language switcher 37 Some small CMS area bugfixes 38 Language switcher bugfix 39 34 40 v2.15.1 35 41 Language switcher stylesheet modifications -
clonable/trunk/readme.txt
r3823289 r3844084 5 5 Tested up to: 7.1 6 6 Requires PHP: 8.1 7 Stable tag: 2.1 5.17 Stable tag: 2.16.0 8 8 License: GPL v2 or later 9 9 … … 32 32 33 33 == Changelog == 34 v2.16.0 35 Support chatbox inclusion on the Clonable settings pages within WordPress admin 36 Syncing with Clonable no longer re-adds languages removed from the language switcher 37 Some small CMS area bugfixes 38 Language switcher bugfix 39 34 40 v2.15.1 35 41 Language switcher stylesheet modifications -
clonable/trunk/services/LanguageSwitcherService.php
r3823289 r3844084 810 810 } 811 811 812 $clones = $site->get_clones();813 812 $locally_set_languages = $this->get_locally_set_languages(); 813 $clones = self::clones_in_table($site->get_clones(), $locally_set_languages); 814 814 815 815 // Source URL is never translated; keep it out of the batch. … … 925 925 926 926 /** 927 * Clones the language switcher shows. Language switcher CMS table leads: clone not in this table (by lang_code) is hidden. 928 * @param array $clones Clones from the site, keyed by clone index. 929 * @param array $locally_set_languages Switcher table rows (stdClass). 930 * @return array 931 */ 932 private static function clones_in_table(array $clones, array $locally_set_languages): array { 933 $table_codes = array_filter(array_map('strval', array_column($locally_set_languages, 'clonableLocaleCode')), 'strlen'); 934 if (!$table_codes) { 935 return $clones; 936 } 937 938 $visible = []; 939 foreach ($clones as $index => $clone) { 940 if (in_array( (string) ( $clone['lang_code'] ?? '' ), $table_codes, true)) { 941 $visible[$index] = $clone; 942 } 943 } 944 945 return $visible; 946 } 947 948 /** 927 949 * Normalise a URL for comparison: ignore the "www." prefix and a trailing slash. 928 950 */ -
clonable/trunk/services/SyncService.php
r3719175 r3844084 12 12 13 13 class SyncService { 14 private const SYNCED_SWITCHER_URLS = 'clonable_langswitch_synced_urls'; 15 14 16 public function sync_site() { 15 17 // Reset connectivity check … … 33 35 $this->sync_woocommerce($site->get_domain()); 34 36 37 $this->init_synced_switcher_urls($site); 35 38 $this->sync_language_switcher($site->get_locale(), Locales::get_display_name($site->get_locale()), $site->get_url()); 36 39 foreach ($site->get_clones() as $index => $clone) { … … 118 121 } 119 122 123 /** 124 * Add language to switcher once per URL. Languages removed by CMS user stay removed. 125 * No escapes: view esc_js() strips backslashes. 126 * 127 * @link https://developer.wordpress.org/reference/functions/get_option/ 128 * @link https://developer.wordpress.org/reference/functions/update_option/ 129 * @link https://developer.wordpress.org/reference/functions/wp_json_encode/ 130 * 131 * @param string $locale Locale code. 132 * @param string $display_name Language name. 133 * @param string $url Site or clone URL. 134 */ 120 135 public function sync_language_switcher($locale, $display_name, $url) { 121 $language_switcher_items = get_option('clonable_langswitch_data'); 122 if (empty($language_switcher_items)) { 123 $language_switcher_items = '[]'; 124 } 125 126 /* @var array $languages */ 127 $languages = Json::handle_input($language_switcher_items); 128 // if value is not yet in array, then you can put it in. 129 if (!in_array($url, array_column($languages, 'clonableUrl'))) { 136 $synced = get_option(self::SYNCED_SWITCHER_URLS, []); 137 $synced = is_array($synced) ? $synced : []; 138 if (in_array($url, $synced, true)) { 139 return; 140 } 141 142 $languages = Json::decode_array(get_option('clonable_langswitch_data', '[]')); 143 if (!in_array($url, array_column($languages, 'clonableUrl'), true)) { 130 144 $languages[] = [ 131 145 'clonableLocaleCode' => $locale, … … 133 147 'clonableUrl' => $url, 134 148 ]; 135 } 136 137 $languages = Json::handle_output(json_encode($languages)); 138 update_option('clonable_langswitch_data', $languages, true); 149 150 $encoded = wp_json_encode($languages, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); 151 if (!is_string($encoded)) { 152 return; 153 } 154 update_option('clonable_langswitch_data', $encoded, true); 155 } 156 157 $synced[] = $url; 158 update_option(self::SYNCED_SWITCHER_URLS, $synced, false); 159 } 160 161 /** 162 * Synced before this option existed: mark site + clone URLs as synced, add nothing. 163 * Languages removed before the update stay removed. 164 * 165 * @link https://developer.wordpress.org/reference/functions/get_option/ 166 * @link https://developer.wordpress.org/reference/functions/update_option/ 167 * 168 * @param Site $site Site from the API. 169 */ 170 public function init_synced_switcher_urls(Site $site) { 171 if (get_option(self::SYNCED_SWITCHER_URLS) !== false || get_option('clonable_last_sync') === false) { 172 return; 173 } 174 175 $urls = [$site->get_url()]; 176 foreach (array_keys($site->get_clones()) as $index) { 177 $urls[] = $site->get_clone_url($index); 178 } 179 180 update_option(self::SYNCED_SWITCHER_URLS, $urls, false); 139 181 } 140 182 -
clonable/trunk/views/LanguageSwitcherView.php
r3759957 r3844084 164 164 <li>3: The flag is the flag of the country you want the languge switcher to show.</li> 165 165 <li>4: The text is the text of the language you want to show. For example: "de" or "german".</li> 166 <li>5: Removing a clone language here also hides it from the shortcode and menu language switchers. When the table is empty, all clone languages are shown.</li> 166 167 </ul> 167 168 <div class="wrap"> -
clonable/trunk/views/Layout.php
r3719175 r3844084 11 11 use Clonable\Objects\Notification; 12 12 use Clonable\Routes\Router; 13 use Clonable\Services\SupportChatService; 13 14 use Throwable; 14 15 … … 148 149 <a target="_blank" href="https://www.youtube.com/@clonable">YouTube channel.</a> 149 150 </p> 151 <?php 152 try { 153 SupportChatService::render_button(); 154 } catch (Throwable $throwable) { 155 error_log("[Clonable] Error rendering support chat button: {$throwable->getMessage()}"); 156 } 157 ?> 150 158 </div> 151 159 <?php
Note:
See TracChangeset
for help on using the changeset viewer.