Changeset 3338869
- Timestamp:
- 08/04/2025 10:14:38 AM (8 months ago)
- Location:
- clonable
- Files:
-
- 124 added
- 15 edited
-
tags/2.6.0 (added)
-
tags/2.6.0/Bootstrap.php (added)
-
tags/2.6.0/clonable-wp.php (added)
-
tags/2.6.0/controllers (added)
-
tags/2.6.0/controllers/Controller.php (added)
-
tags/2.6.0/controllers/DashboardController.php (added)
-
tags/2.6.0/controllers/LandingPageController.php (added)
-
tags/2.6.0/controllers/LanguageSwitcherController.php (added)
-
tags/2.6.0/controllers/LanguageTagController.php (added)
-
tags/2.6.0/controllers/SettingController.php (added)
-
tags/2.6.0/controllers/WoocommerceController.php (added)
-
tags/2.6.0/controllers/index.php (added)
-
tags/2.6.0/exceptions (added)
-
tags/2.6.0/exceptions/ApiException.php (added)
-
tags/2.6.0/exceptions/CurlException.php (added)
-
tags/2.6.0/exceptions/ValidationException.php (added)
-
tags/2.6.0/helpers (added)
-
tags/2.6.0/helpers/Functions.php (added)
-
tags/2.6.0/helpers/Html.php (added)
-
tags/2.6.0/helpers/Json.php (added)
-
tags/2.6.0/helpers/Locales.php (added)
-
tags/2.6.0/helpers/MultiCurrency.php (added)
-
tags/2.6.0/helpers/Session.php (added)
-
tags/2.6.0/helpers/clonable-locales-list.php (added)
-
tags/2.6.0/helpers/index.php (added)
-
tags/2.6.0/images (added)
-
tags/2.6.0/images/clonable-full-logo.png (added)
-
tags/2.6.0/images/clonable.png (added)
-
tags/2.6.0/images/configure-wordpress-thumbnail.png (added)
-
tags/2.6.0/images/flags.png (added)
-
tags/2.6.0/images/index.php (added)
-
tags/2.6.0/images/language-switcher-thumbnail.png (added)
-
tags/2.6.0/index.php (added)
-
tags/2.6.0/middleware (added)
-
tags/2.6.0/middleware/Auth.php (added)
-
tags/2.6.0/middleware/ClonedSite.php (added)
-
tags/2.6.0/middleware/MiddlewareHandler.php (added)
-
tags/2.6.0/middleware/MiddlewareInterface.php (added)
-
tags/2.6.0/middleware/WooCommerce.php (added)
-
tags/2.6.0/middleware/index.php (added)
-
tags/2.6.0/models (added)
-
tags/2.6.0/models/ApiKey.php (added)
-
tags/2.6.0/models/ClonableWooCommerce.php (added)
-
tags/2.6.0/models/ClonedSite.php (added)
-
tags/2.6.0/models/LanguageSwitcher.php (added)
-
tags/2.6.0/models/LanguageTag.php (added)
-
tags/2.6.0/models/Settings.php (added)
-
tags/2.6.0/models/Site.php (added)
-
tags/2.6.0/models/index.php (added)
-
tags/2.6.0/objects (added)
-
tags/2.6.0/objects/ApiResponse.php (added)
-
tags/2.6.0/objects/CircuitBreaker.php (added)
-
tags/2.6.0/objects/ClonableConfig.php (added)
-
tags/2.6.0/objects/ClonableResponse.php (added)
-
tags/2.6.0/objects/CurlBuilder.php (added)
-
tags/2.6.0/objects/ExcludedProductTerm.php (added)
-
tags/2.6.0/objects/Notification.php (added)
-
tags/2.6.0/objects/index.php (added)
-
tags/2.6.0/readme-da_DK.txt (added)
-
tags/2.6.0/readme-de_DE.txt (added)
-
tags/2.6.0/readme-es_ES.txt (added)
-
tags/2.6.0/readme-fr_FR.txt (added)
-
tags/2.6.0/readme-it_IT.txt (added)
-
tags/2.6.0/readme-nb_NO.txt (added)
-
tags/2.6.0/readme-nl_NL.txt (added)
-
tags/2.6.0/readme-sv_SE.txt (added)
-
tags/2.6.0/readme.txt (added)
-
tags/2.6.0/routes (added)
-
tags/2.6.0/routes/Router.php (added)
-
tags/2.6.0/routes/index.php (added)
-
tags/2.6.0/services (added)
-
tags/2.6.0/services/AllowedHostsService.php (added)
-
tags/2.6.0/services/ApiService.php (added)
-
tags/2.6.0/services/CacheService.php (added)
-
tags/2.6.0/services/ClonableWooCommerceService.php (added)
-
tags/2.6.0/services/LanguageSwitcherService.php (added)
-
tags/2.6.0/services/LanguageTagService.php (added)
-
tags/2.6.0/services/LocaleService.php (added)
-
tags/2.6.0/services/MultiCurrencyService.php (added)
-
tags/2.6.0/services/ShortCodeService.php (added)
-
tags/2.6.0/services/SubfolderService.php (added)
-
tags/2.6.0/services/SyncService.php (added)
-
tags/2.6.0/services/index.php (added)
-
tags/2.6.0/services/modules (added)
-
tags/2.6.0/services/modules/DataPanelModule.php (added)
-
tags/2.6.0/services/modules/ExclusionModule.php (added)
-
tags/2.6.0/services/modules/ProductImporterModule.php (added)
-
tags/2.6.0/services/modules/TaxonomyModule.php (added)
-
tags/2.6.0/services/modules/index.php (added)
-
tags/2.6.0/traits (added)
-
tags/2.6.0/traits/Forms.php (added)
-
tags/2.6.0/traits/PluginCheck.php (added)
-
tags/2.6.0/traits/Validation.php (added)
-
tags/2.6.0/traits/index.php (added)
-
tags/2.6.0/uninstall.php (added)
-
tags/2.6.0/views (added)
-
tags/2.6.0/views/DashboardView.php (added)
-
tags/2.6.0/views/LanguageSwitcherView.php (added)
-
tags/2.6.0/views/LanguageTagView.php (added)
-
tags/2.6.0/views/Layout.php (added)
-
tags/2.6.0/views/OnboardingView.php (added)
-
tags/2.6.0/views/SettingsView.php (added)
-
tags/2.6.0/views/ViewInterface.php (added)
-
tags/2.6.0/views/WoocommerceView.php (added)
-
tags/2.6.0/views/css (added)
-
tags/2.6.0/views/css/clonable-extra-button.css (added)
-
tags/2.6.0/views/css/clonable-global.css (added)
-
tags/2.6.0/views/css/clonable-thumbnails.css (added)
-
tags/2.6.0/views/css/clonable-woocommerce.css (added)
-
tags/2.6.0/views/css/clonable.css (added)
-
tags/2.6.0/views/css/fomantic-dropdown.css (added)
-
tags/2.6.0/views/css/fomantic-transition.css (added)
-
tags/2.6.0/views/css/freakflags.css (added)
-
tags/2.6.0/views/css/index.php (added)
-
tags/2.6.0/views/index.php (added)
-
tags/2.6.0/views/scripts (added)
-
tags/2.6.0/views/scripts/alpine.js (added)
-
tags/2.6.0/views/scripts/dohjs.js (added)
-
tags/2.6.0/views/scripts/fomantic-dropdown.js (added)
-
tags/2.6.0/views/scripts/fomantic-transition.js (added)
-
tags/2.6.0/views/scripts/index.php (added)
-
tags/2.6.0/views/scripts/onload.js (added)
-
tags/2.6.0/views/scripts/woocommerce-clone-field.js (added)
-
trunk/clonable-wp.php (modified) (3 diffs)
-
trunk/controllers/WoocommerceController.php (modified) (2 diffs)
-
trunk/helpers/Locales.php (modified) (1 diff)
-
trunk/helpers/MultiCurrency.php (added)
-
trunk/models/ClonableWooCommerce.php (modified) (3 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/MultiCurrencyService.php (modified) (2 diffs)
-
trunk/views/WoocommerceView.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
clonable/trunk/clonable-wp.php
r3336393 r3338869 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. 5.67 Version: 2.6.0 8 8 Author: Clonable BV 9 9 Author URI: https://www.clonable.net … … 77 77 include_once "helpers/Html.php"; 78 78 include_once "helpers/Functions.php"; 79 include_once "helpers/MultiCurrency.php"; 79 80 80 81 // middleware … … 114 115 115 116 define('CLONABLE_NAME', 'Clonable'); 116 define('CLONABLE_VERSION', '2. 5.6');117 define('CLONABLE_VERSION', '2.6.0'); 117 118 118 119 if (defined('WP_CLI') && WP_CLI) { -
clonable/trunk/controllers/WoocommerceController.php
r3280987 r3338869 5 5 use Clonable\Helpers\Functions; 6 6 use Clonable\Helpers\Json; 7 use Clonable\Helpers\MultiCurrency; 7 8 use Clonable\Models\ClonableWooCommerce; 8 9 use Clonable\Traits\Validation; … … 80 81 return $this->validate_checkbox($input, ClonableWooCommerce::CURCY_SUPPORT_SETTING); 81 82 } 83 84 public function clonable_curcy_currency_override_validate($input) { 85 if (empty($input)) { 86 return $input; 87 } 88 $old_input = get_option(ClonableWooCommerce::CURCY_SUPPORT_SETTING); 89 $json_input = Json::handle_input($input); 90 $available_currencies = MultiCurrency::get_all_currencies(); 91 92 foreach ($json_input as $custom_currency) { 93 if (empty($custom_currency->currency) || !in_array($custom_currency->currency, $available_currencies)) { 94 add_settings_error(ClonableWooCommerce::CURCY_SUPPORT_SETTING, 'err_invalid_domain', "You've entered a currency that was not yet configured via CURCY."); 95 return $old_input; 96 } 97 } 98 99 if (empty($json_input)) { 100 return null; 101 } 102 return Json::handle_output(json_encode($json_input)); 103 } 82 104 } -
clonable/trunk/helpers/Locales.php
r3100441 r3338869 8 8 public static function get_display_name($locale) { 9 9 return self::get_locale_attribute($locale, 'display_name'); 10 } 11 12 public static function get_display_region($locale) { 13 $display_name = self::get_locale_attribute($locale, 'display_name'); 14 if (preg_match('/\(([^)]+)\)/', $display_name, $matches)) { 15 return $matches[1]; 16 } 17 return $display_name; 10 18 } 11 19 -
clonable/trunk/models/ClonableWooCommerce.php
r3280987 r3338869 2 2 3 3 namespace Clonable\Models; 4 5 use Clonable\Helpers\Locales; 6 use Clonable\Helpers\MultiCurrency; 7 use Clonable\Services\MultiCurrencyService; 4 8 5 9 class ClonableWooCommerce { … … 7 11 8 12 const CURCY_SUPPORT_SETTING = "clonable_enable_curcy_plugin_support"; 13 const CURCY_CURRENCY_OVERRIDES = "clonable_curcy_currency_override"; 9 14 10 15 public static $fields = [ … … 36 41 "name" => "Enable CURCY support", 37 42 "setting" => self::CURCY_SUPPORT_SETTING, 43 ], 44 self::CURCY_CURRENCY_OVERRIDES => [ 45 "render" => "clonable_curcy_currency_override_field", 46 "name" => "Override CURCY currencies", 47 "setting" => self::CURCY_CURRENCY_OVERRIDES, 48 "description" => "Override the default currencies that are assigned to a Clonable language." 38 49 ] 39 50 ]; 51 52 /** 53 * Get the default values that are used in the MultiCurrency module. 54 * These by default map the target region of a clone to the local currency. 55 * 56 * @return array 57 */ 58 public static function get_default_currencies(): array { 59 $response = get_option("clonable_site"); 60 if (empty($response)) { 61 return array(); 62 } 63 64 $site = new Site($response); 65 $currency_map = []; 66 foreach ($site->get_clones() as $clone) { 67 $split_locale = explode("_", $clone['lang_code']); 68 $currency_map[] = [ 69 'id' => $clone['id'], 70 'target_region' => mb_strtolower(end($split_locale)), 71 'display_region' => Locales::get_display_region($clone['lang_code']), 72 'currency' => MultiCurrency::get_currency_by_region(end($split_locale)), 73 ]; 74 } 75 return $currency_map; 76 } 40 77 } -
clonable/trunk/readme-da_DK.txt
r3336393 r3338869 5 5 Tested up to: 6.8.2 6 6 Requires PHP: 7.2 7 Stable tag: 2. 5.67 Stable tag: 2.6.0 8 8 License: GPL v2 or later 9 9 … … 32 32 33 33 == Changelog == 34 v2.6.0 35 Added ability to override currencies for specific target regions. 36 34 37 v2.5.6 35 38 Added extra null check for WooCommerce service to resolve issues with the WP-CLI -
clonable/trunk/readme-de_DE.txt
r3336393 r3338869 5 5 Tested up to: 6.8.2 6 6 Requires PHP: 7.2 7 Stable tag: 2. 5.67 Stable tag: 2.6.0 8 8 License: GPL v2 or later 9 9 … … 32 32 33 33 == Changelog == 34 v2.6.0 35 Added ability to override currencies for specific target regions. 36 34 37 v2.5.6 35 38 Added extra null check for WooCommerce service to resolve issues with the WP-CLI -
clonable/trunk/readme-es_ES.txt
r3336393 r3338869 5 5 Tested up to: 6.8.2 6 6 Requires PHP: 7.2 7 Stable tag: 2. 5.67 Stable tag: 2.6.0 8 8 License: GPL v2 or later 9 9 … … 32 32 33 33 == Changelog == 34 v2.6.0 35 Added ability to override currencies for specific target regions. 36 34 37 v2.5.6 35 38 Added extra null check for WooCommerce service to resolve issues with the WP-CLI -
clonable/trunk/readme-fr_FR.txt
r3336393 r3338869 5 5 Tested up to: 6.8.2 6 6 Requires PHP: 7.2 7 Stable tag: 2. 5.67 Stable tag: 2.6.0 8 8 License: GPL v2 or later 9 9 … … 32 32 33 33 == Changelog == 34 v2.6.0 35 Added ability to override currencies for specific target regions. 36 34 37 v2.5.6 35 38 Added extra null check for WooCommerce service to resolve issues with the WP-CLI -
clonable/trunk/readme-it_IT.txt
r3336393 r3338869 5 5 Tested up to: 6.8.2 6 6 Requires PHP: 7.2 7 Stable tag: 2. 5.67 Stable tag: 2.6.0 8 8 License: GPL v2 or later 9 9 … … 32 32 33 33 == Changelog == 34 v2.6.0 35 Added ability to override currencies for specific target regions. 36 34 37 v2.5.6 35 38 Added extra null check for WooCommerce service to resolve issues with the WP-CLI -
clonable/trunk/readme-nb_NO.txt
r3336393 r3338869 5 5 Tested up to: 6.8.2 6 6 Requires PHP: 7.2 7 Stable tag: 2. 5.67 Stable tag: 2.6.0 8 8 License: GPL v2 or later 9 9 … … 32 32 33 33 == Changelog == 34 v2.6.0 35 Added ability to override currencies for specific target regions. 36 34 37 v2.5.6 35 38 Added extra null check for WooCommerce service to resolve issues with the WP-CLI -
clonable/trunk/readme-nl_NL.txt
r3336393 r3338869 5 5 Tested up to: 6.8.2 6 6 Requires PHP: 7.2 7 Stable tag: 2. 5.67 Stable tag: 2.6.0 8 8 License: GPL v2 or later 9 9 … … 32 32 33 33 == Changelog == 34 v2.6.0 35 De mogelijkheid toegevoegd om valuta's te overschijven voor specifieke regio's. 36 34 37 v2.5.6 35 38 Added extra null check for WooCommerce service to resolve issues with the WP-CLI -
clonable/trunk/readme-sv_SE.txt
r3336393 r3338869 5 5 Tested up to: 6.8.2 6 6 Requires PHP: 7.2 7 Stable tag: 2. 5.67 Stable tag: 2.6.0 8 8 License: GPL v2 or later 9 9 … … 32 32 33 33 == Changelog == 34 v2.6.0 35 Added ability to override currencies for specific target regions. 36 34 37 v2.5.6 35 38 Added extra null check for WooCommerce service to resolve issues with the WP-CLI -
clonable/trunk/readme.txt
r3336393 r3338869 5 5 Tested up to: 6.8.2 6 6 Requires PHP: 7.2 7 Stable tag: 2. 5.67 Stable tag: 2.6.0 8 8 License: GPL v2 or later 9 9 … … 32 32 33 33 == Changelog == 34 v2.6.0 35 Added ability to override currencies for specific target regions. 36 34 37 v2.5.6 35 38 Added extra null check for WooCommerce service to resolve issues with the WP-CLI -
clonable/trunk/services/MultiCurrencyService.php
r3307078 r3338869 3 3 namespace Clonable\Services; 4 4 5 use Clonable\Helpers\MultiCurrency; 5 6 use Clonable\Models\ClonableWooCommerce; 6 7 use Clonable\Traits\PluginCheck; … … 54 55 55 56 private function get_currency() { 57 $custom_currencies = get_option(ClonableWooCommerce::CURCY_CURRENCY_OVERRIDES); 56 58 $server_data = $_SERVER; 57 59 $target_region = $server_data['HTTP_CLONABLE_TARGET_REGION'] ?? null; 58 60 59 if (class_exists('WOOMULTI_CURRENCY_Data')) { 60 $settings = \WOOMULTI_CURRENCY_Data::get_ins(); 61 if ($target_region !== null) { 62 $target_region_upper = strtoupper($target_region); 63 return $settings->get_currency_code($target_region_upper); 64 } else { 65 return $settings->get_default_currency(); 61 if (empty($custom_currencies)) { 62 return MultiCurrency::get_currency_by_region($target_region); 63 } else { 64 foreach ($custom_currencies as $currency) { 65 if ($currency['target_region'] === $target_region) { 66 // If a custom currency has been defined, return that one instead of the custom one 67 return $currency['currency']; 68 } 66 69 } 70 return MultiCurrency::get_currency_by_region($target_region); 67 71 } 68 69 // if the MultiCurrency class does not exist, then return null.70 return null;71 72 } 72 73 } -
clonable/trunk/views/WoocommerceView.php
r3280987 r3338869 3 3 namespace Clonable\Views; 4 4 5 use Clonable\Helpers\Functions; 5 6 use Clonable\Helpers\Html; 7 use Clonable\Helpers\Json; 8 use Clonable\Helpers\MultiCurrency; 9 use Clonable\Helpers\Session; 6 10 use Clonable\Models\ClonableWooCommerce; 7 11 use Clonable\Traits\Forms; … … 13 17 public function render() 14 18 { 19 Html::include_fomantic_dropdown(); 15 20 Html::include_alpine(); 16 21 $module_enabled = get_option('clonable_woocommerce_module_enabled', 'on') === 'on'; … … 131 136 <?php 132 137 } 138 139 public function clonable_curcy_currency_override_field() { 140 $option = Session::old(ClonableWooCommerce::CURCY_CURRENCY_OVERRIDES); 141 if (empty($option)) { 142 $default_currencies = ClonableWooCommerce::get_default_currencies(); 143 $option = Json::handle_output(json_encode($default_currencies)); 144 } 145 $currencies = MultiCurrency::get_all_currencies(); 146 147 ?> 148 <p style="max-width: 75%"> 149 By default, Clonable will do a smart selection of the currency based on the locale of your clone. 150 So let's say you've got the clone en_gb, Clonable by default will use GBP as its currency. 151 But if you want to use another currency for Great Britain, you can override it in the table below. 152 <br/> 153 <strong>Note: Only currencies that are configured in CURCY will be available to select.</strong> 154 </p> 155 <div class="wrap"> 156 <div x-data="{ currencies: <?php echo esc_js($option); ?> }"> 157 <!-- hidden input field for submitting the json value --> 158 <label for="clonable_curcy_currency_override"></label> 159 <input x-model="JSON.stringify(currencies)" name="clonable_curcy_currency_override" 160 id="clonable_curcy_currency_override" style="display: none"/> 161 <!-- Display data --> 162 <table class="wp-list-table fat striped" style="width: 75%"> 163 <thead> 164 <tr> 165 <th>Target Region</th> 166 <th>Currency</th> 167 </tr> 168 </thead> 169 <tbody> 170 <template x-for="(currency, index) in currencies" :key="index"> 171 <tr> 172 <input x-model="currencies[index].target_region" type="hidden"> 173 <td><input disabled x-model="currencies[index].display_region" style="width: 100%"/></td> 174 <td> 175 <div class="field"> 176 <div class="ui search selection dropdown" style="width: 75%"> 177 <input x-model="currencies[index].currency" type="hidden"> 178 <i class="dropdown icon"></i> 179 <div class="default text mt-0.5"></div> 180 <div class="menu"> 181 <?php 182 foreach ($currencies as $currency) { 183 $symbol = get_woocommerce_currency_symbol($currency); 184 echo "<div @click='currencies[index].currency = \"" . esc_attr($currency) . "\"' class='item' data-value='" . esc_attr($currency) . "'>" . esc_html($currency) . " ($symbol)</div>"; 185 } 186 ?> 187 </div> 188 </div> 189 </div> 190 </td> 191 </tr> 192 </template> 193 </tbody> 194 </table> 195 </div> 196 </div> 197 <?php 198 // phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped 199 $this->render_error('clonable_woocommerce_allowed_origins'); 200 } 133 201 }
Note: See TracChangeset
for help on using the changeset viewer.