Changeset 3397694
- Timestamp:
- 11/18/2025 03:20:33 AM (4 months ago)
- Location:
- linguise
- Files:
-
- 46 edited
- 1 copied
-
tags/2.2.5 (copied) (copied from linguise/trunk)
-
tags/2.2.5/linguise.php (modified) (1 diff)
-
tags/2.2.5/readme.txt (modified) (2 diffs)
-
tags/2.2.5/src/AttributeHandler.php (modified) (3 diffs)
-
tags/2.2.5/src/FragmentBase.php (modified) (2 diffs)
-
tags/2.2.5/src/FragmentHandler.php (modified) (13 diffs)
-
tags/2.2.5/src/Helper.php (modified) (1 diff)
-
tags/2.2.5/src/constants.php (modified) (1 diff)
-
tags/2.2.5/src/rest-ajax.php (modified) (2 diffs)
-
tags/2.2.5/src/thirdparty/base-class.php (modified) (3 diffs)
-
tags/2.2.5/src/thirdparty/fluentcrm.php (modified) (7 diffs)
-
tags/2.2.5/src/thirdparty/kickflip-customizer.php (modified) (7 diffs)
-
tags/2.2.5/src/thirdparty/wc/woocommerce.php (modified) (3 diffs)
-
tags/2.2.5/vendor/composer/installed.json (modified) (2 diffs)
-
tags/2.2.5/vendor/composer/installed.php (modified) (3 diffs)
-
tags/2.2.5/vendor/linguise/script-php/.version (modified) (1 diff)
-
tags/2.2.5/vendor/linguise/script-php/src/Certificates.php (modified) (3 diffs)
-
tags/2.2.5/vendor/linguise/script-php/src/Debug.php (modified) (5 diffs)
-
tags/2.2.5/vendor/linguise/script-php/src/JsonWalker.php (modified) (1 diff)
-
tags/2.2.5/vendor/linguise/script-php/src/Management.php (modified) (3 diffs)
-
tags/2.2.5/vendor/linguise/script-php/src/Platforms/PrestaShop.php (modified) (1 diff)
-
tags/2.2.5/vendor/linguise/script-php/src/Processor.php (modified) (8 diffs)
-
tags/2.2.5/vendor/linguise/script-php/src/Translation.php (modified) (2 diffs)
-
tags/2.2.5/vendor/linguise/script-php/src/Updater.php (modified) (2 diffs)
-
trunk/linguise.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/src/AttributeHandler.php (modified) (3 diffs)
-
trunk/src/FragmentBase.php (modified) (2 diffs)
-
trunk/src/FragmentHandler.php (modified) (13 diffs)
-
trunk/src/Helper.php (modified) (1 diff)
-
trunk/src/constants.php (modified) (1 diff)
-
trunk/src/rest-ajax.php (modified) (2 diffs)
-
trunk/src/thirdparty/base-class.php (modified) (3 diffs)
-
trunk/src/thirdparty/fluentcrm.php (modified) (7 diffs)
-
trunk/src/thirdparty/kickflip-customizer.php (modified) (7 diffs)
-
trunk/src/thirdparty/wc/woocommerce.php (modified) (3 diffs)
-
trunk/vendor/composer/installed.json (modified) (2 diffs)
-
trunk/vendor/composer/installed.php (modified) (3 diffs)
-
trunk/vendor/linguise/script-php/.version (modified) (1 diff)
-
trunk/vendor/linguise/script-php/src/Certificates.php (modified) (3 diffs)
-
trunk/vendor/linguise/script-php/src/Debug.php (modified) (5 diffs)
-
trunk/vendor/linguise/script-php/src/JsonWalker.php (modified) (1 diff)
-
trunk/vendor/linguise/script-php/src/Management.php (modified) (3 diffs)
-
trunk/vendor/linguise/script-php/src/Platforms/PrestaShop.php (modified) (1 diff)
-
trunk/vendor/linguise/script-php/src/Processor.php (modified) (8 diffs)
-
trunk/vendor/linguise/script-php/src/Translation.php (modified) (2 diffs)
-
trunk/vendor/linguise/script-php/src/Updater.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
linguise/tags/2.2.5/linguise.php
r3393999 r3397694 5 5 * Plugin URI: https://www.linguise.com/ 6 6 * Description: Linguise translation plugin 7 * Version:2.2. 47 * Version:2.2.5 8 8 * Text Domain: linguise 9 9 * Domain Path: /languages -
linguise/tags/2.2.5/readme.txt
r3393999 r3397694 4 4 Requires at least: 4.0 5 5 Tested up to: 6.8 6 Stable tag: 2.2. 46 Stable tag: 2.2.5 7 7 Requires PHP: 7.0 8 8 License: GPLv2 or later … … 107 107 108 108 == Changelog == 109 = 2.2.5 = 110 - Fix: Issues with fragment i18n is not getting translated because of CDATA 111 - Feature: Try to capture and translate preloaded API request 112 - Fix: Some fragment data not captured in WooCommerce should be translated now 113 109 114 = 2.2.4 = 110 115 - Feature: Support kinyarwanda (rw) language -
linguise/tags/2.2.5/src/AttributeHandler.php
r3366846 r3397694 54 54 ], 55 55 ]; 56 57 $current_list[] = [ 58 'name' => 'linguise-demo-string-encoded', 59 'key' => 'data-label-encoded', 60 'mode' => 'string-encoded', 61 'matchers' => [ 62 [ 63 'key' => 'sc-linguise-demo-encoded', 64 'type' => 'tag' 65 ] 66 ], 67 ]; 56 68 } 57 69 … … 213 225 ] 214 226 ]; 227 } elseif (isset($matcher['mode']) && $matcher['mode'] === 'string-encoded') { 228 $cast_data = isset($matcher['cast']) ? $matcher['cast'] : 'html-main'; 229 230 $collected_temp = [ 231 [ 232 'key' => $matcher['key'], 233 'value' => html_entity_decode($key_data, ENT_QUOTES | ENT_SUBSTITUTE, 'utf-8'), 234 'format' => $cast_data, 235 ] 236 ]; 215 237 } else { 216 238 $json_data = json_decode($key_data, true); … … 349 371 350 372 $protected_json = HTMLHelper::protectEntity($replaced_text); 373 } elseif (isset($matched['mode']) && $matched['mode'] === 'string-encoded') { 374 // Get first item 375 $first_fragment = isset($fragment_list['fragments'][0]) ? $fragment_list['fragments'][0] : null; 376 if (empty($first_fragment)) { 377 continue; 378 } 379 380 $first_value = isset($first_fragment['value']) ? $first_fragment['value'] : null; 381 if (empty($first_value)) { 382 continue; 383 } 384 385 // Replace the data 386 $replaced_text = htmlspecialchars($first_value, ENT_QUOTES, 'UTF-8', false); 387 if ($should_encode) { 388 $replaced_text = rawurlencode($replaced_text); 389 } 390 391 $protected_json = HTMLHelper::protectEntity($replaced_text); 351 392 } else { 352 393 // JSON mode, we need to decode the JSON data -
linguise/tags/2.2.5/src/FragmentBase.php
r3381590 r3397694 249 249 250 250 if (empty($value) || !is_string($value)) { 251 return false; 252 } 253 254 if (is_string($value) && empty($value)) { 251 255 return false; 252 256 } … … 570 574 ]; 571 575 576 $current_list[] = [ 577 'name' => 'wc-settings-encoded-alt', 578 'match' => 'var wcSettings = JSON\.parse\( decodeURIComponent\( \'(.*?)\' \) \);', 579 'replacement' => 'var wcSettings = JSON.parse( decodeURIComponent( \'$$JSON_DATA$$\' ) );', 580 'encode' => true, 581 ]; 582 583 $current_list[] = [ 584 'name' => 'wc-settings-api-inject', 585 'match' => 'wp\.apiFetch\.createPreloadingMiddleware\(\s*JSON\.parse\(\s*decodeURIComponent\(\s*\'(.*?)\'\s*\)\s*\)\s*\)', 586 'replacement' => 'wp.apiFetch.createPreloadingMiddleware( JSON.parse( decodeURIComponent( \'$$JSON_DATA$$\' ) ) )', 587 'encode' => true, 588 ]; 589 572 590 if (defined('CFCORE_VER')) { 573 591 $current_list[] = [ -
linguise/tags/2.2.5/src/FragmentHandler.php
r3393354 r3397694 91 91 } 92 92 if ($tl_string || $tl_link || is_string($tl_dom) || $allowed_filters) { 93 $collected_fragments[] = [ 94 'key' => $use_key, 95 'value' => $value, 96 'format' => $format, 97 ]; 93 // Extra check 94 if (is_string($value) && !empty($value)) { 95 $collected_fragments[] = [ 96 'key' => $use_key, 97 'value' => $value, 98 'format' => $format, 99 ]; 100 } 98 101 } 99 102 } … … 125 128 } 126 129 return $collected_fragments; 130 } 131 132 /** 133 * Protect sprintf templates in the text by wrapping them in a span tag 134 * 135 * @param string $text The text to be protected 136 * 137 * @return string The protected text 138 */ 139 private static function protectSprintfTemplates($text) 140 { 141 $pattern = '/(%(?:\d+\$)?[+-]?(?:\d+)?(?:\.\d+)?[bcdeEfFgGosuxX])/'; 142 $replacement = '<span-ling translate="no">$1</span-ling>'; 143 $result = preg_replace($pattern, $replacement, $text); 144 if (!empty($result)) { 145 return $result; 146 } 147 return $text; 148 } 149 150 /** 151 * Restore sprintf templates in the text by unwrapping them from the span tag 152 * 153 * @param string $text The text to be restored 154 * 155 * @return string The restored text 156 */ 157 private static function restoreSprintfTemplates($text) 158 { 159 $pattern = '/<span-ling translate="no">(%(?:\d+\$)?[+-]?(?:\d+)?(?:\.\d+)?[bcdeEfFgGosuxX])<\/span-ling>/'; 160 $result = preg_replace($pattern, '$1', $text); 161 if (!empty($result)) { 162 return $result; 163 } 164 return $text; 127 165 } 128 166 … … 175 213 $html .= ' ' . $tag_select . '="' . $fragment['value'] . '">'; 176 214 } else { 177 $html .= '>' . $frag_value;215 $html .= '>' . self::protectSprintfTemplates($frag_value); 178 216 } 179 217 $html .= '</' . $tag . '>' . "\n"; … … 230 268 } 231 269 270 $fragment_value = self::restoreSprintfTemplates($fragment_value); 271 232 272 if (!isset($fragments[$fragment_name])) { 233 273 $fragments[$fragment_name] = []; … … 293 333 $override_list = self::getJSONOverrideMatcher($html_data); 294 334 335 $multi_matched = []; 295 336 foreach ($override_list as $override_item) { 296 337 $script_content = HTMLHelper::unclobberCdataInternal($script_content); … … 344 385 $collected_temp = self::collectFragmentFromJson($json_data, $is_strict); 345 386 if (!empty($collected_temp)) { 346 return[387 $multi_matched[] = [ 347 388 'name' => $override_item['name'], 348 389 'fragments' => $collected_temp, … … 351 392 } 352 393 353 return null; 394 if (empty($multi_matched)) { 395 return null; 396 } 397 398 return $multi_matched; 354 399 } 355 400 … … 442 487 $overridden_temp = self::tryMatchWithOverride($script, $html_data); 443 488 if (is_array($overridden_temp)) { 444 $all_fragments[$overridden_temp['name']][$overridden_temp['name']] = [ 445 'mode' => 'override', 446 'fragments' => $overridden_temp['fragments'], 447 ]; 489 foreach ($overridden_temp as $overridden_temp_item) { 490 $all_fragments[$overridden_temp_item['name']][$overridden_temp_item['name']] = [ 491 'mode' => 'override', 492 'fragments' => $overridden_temp_item['fragments'], 493 ]; 494 } 448 495 449 496 continue; … … 475 522 $overridden_temp = self::tryMatchWithOverride($script, $html_data); 476 523 if (is_array($overridden_temp)) { 477 $all_fragments[$frag_id][$overridden_temp['name']] = [ 478 'mode' => 'override', 479 'fragments' => $overridden_temp['fragments'], 480 ]; 524 foreach ($overridden_temp as $overridden_temp_item) { 525 $all_fragments[$frag_id][$overridden_temp_item['name']] = [ 526 'mode' => 'override', 527 'fragments' => $overridden_temp_item['fragments'], 528 ]; 529 } 481 530 } 482 531 continue; … … 567 616 } 568 617 $decoded_key = self::unwrapKey($fragment['key']); 618 $merged_key = strpos($decoded_key, '[') === 0 ? '$' . $decoded_key : '$.' . $decoded_key; 569 619 try { 570 $json_data->set( '$.' . $decoded_key, $fragment['value']);620 $json_data->set($merged_key, $fragment['value']); 571 621 } catch (\Linguise\Vendor\JsonPath\InvalidJsonPathException $e) { 572 Debug::log('Failed to set key in override: ' . $ decoded_key . ' -> ' . $e->getMessage());622 Debug::log('Failed to set key in override: ' . $merged_key . ' -> ' . $e->getMessage()); 573 623 } 574 624 } … … 601 651 } 602 652 $decoded_key = self::unwrapKey($fragment['key']); 653 $merged_key = strpos($decoded_key, '[') === 0 ? '$' . $decoded_key : '$.' . $decoded_key; 603 654 try { 604 $json_data->set( '$.' . $decoded_key, $fragment['value']);655 $json_data->set($merged_key, $fragment['value']); 605 656 } catch (\Linguise\Vendor\JsonPath\InvalidJsonPathException $e) { 606 Debug::log('Failed to set key in override: ' . $ decoded_key . ' -> ' . $e->getMessage());657 Debug::log('Failed to set key in override: ' . $merged_key . ' -> ' . $e->getMessage()); 607 658 } 608 659 } … … 676 727 { 677 728 $full_param_name = $param_name . '-js-translations'; 678 $overall_matchers = preg_match('/id=["\']' . preg_quote($full_param_name) . ' .*?>\s*\(\s*function\(\s*domain,\s*translations\s*\)\s*\{.*?\}\s*\)\s*\(\s*["\']([\w_\-]+)["\']\s*,\s*\{(.*?)\}\s*\)\s*;\s*<\/script>/si', $html_data, $html_matches);729 $overall_matchers = preg_match('/id=["\']' . preg_quote($full_param_name) . '["\'].*?>.*?\(\s*function\(\s*domain,\s*translations\s*\)\s*\{.*?\}\s*\)\s*\(\s*["\']([\w_\-]+)["\']\s*,\s*\{(.*?)\}\s*\)\s*;.*?<\/script>/si', $html_data, $html_matches); 679 730 if ($overall_matchers === false || $overall_matchers === 0) { 680 731 return $html_data; … … 732 783 // dump back to JSON 733 784 $replaced_json = json_encode($json_data); 734 $substr_ptrn = '/(id=["\']' . preg_quote($full_param_name) . '["\'].*?> \s*\(\s*function\(\s*domain,\s*translations\s*\)\s*\{.*?\}\s*\)\s*\(\s*["\']([\w_\-]+)["\']\s*,\s*)(.*?)(\s*\)\s*;\s*<\/script>)/si';785 $substr_ptrn = '/(id=["\']' . preg_quote($full_param_name) . '["\'].*?>.*?\(\s*function\(\s*domain,\s*translations\s*\)\s*\{.*?\}\s*\)\s*\(\s*["\']([\w_\-]+)["\']\s*,\s*)(.*?)(\s*\)\s*;.*?<\/script>)/si'; 735 786 736 787 $replacement = preg_replace($substr_ptrn, '$1' . $replaced_json . '$4', $html_data, 1, $count); -
linguise/tags/2.2.5/src/Helper.php
r3379190 r3397694 165 165 // If not set, we use the same as $language 166 166 // If set and NULL we should return null 167 if (isset($languages->$language->wp_code) && !empty($languages->$language->wp_code)) { 167 if (!array_key_exists('wp_code', (array)$languages->$language)) { 168 return $language; 169 } 170 if (!empty($languages->$language->wp_code)) { 168 171 return $languages->$language->wp_code; 169 } elseif (!isset($languages->$language->wp_code)) {170 return $language;171 172 } 172 173 -
linguise/tags/2.2.5/src/constants.php
r3393999 r3397694 1 1 <?php 2 2 if (!defined('LINGUISE_SCRIPT_TRANSLATION_VERSION')) { 3 define('LINGUISE_SCRIPT_TRANSLATION_VERSION', 'wordpress_plugin/2.2. 4');3 define('LINGUISE_SCRIPT_TRANSLATION_VERSION', 'wordpress_plugin/2.2.5'); 4 4 } 5 5 6 6 if (!defined('LINGUISE_VERSION')) { 7 define('LINGUISE_VERSION', '2.2. 4');7 define('LINGUISE_VERSION', '2.2.5'); 8 8 } -
linguise/tags/2.2.5/src/rest-ajax.php
r3291510 r3397694 120 120 $ch = curl_init(); 121 121 list($translated_content, $response_code) = Translation::getInstance()->_translate($ch, $boundary); 122 curl_close($ch); 122 if (PHP_VERSION_ID < 80000) { 123 // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.curl_closeDeprecated,Generic.PHP.DeprecatedFunctions.Deprecated -- Since PHP 8.0+, we guard it here 124 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 125 } 123 126 124 127 if (!$translated_content || $response_code !== 200) { … … 138 141 $req_reflect = new \ReflectionClass($req_object); 139 142 $reflect_lang = $req_reflect->getProperty('language'); 140 $reflect_lang->setAccessible(true); 143 if (PHP_VERSION_ID < 80100) { 144 // phpcs:ignore Generic.PHP.DeprecatedFunctions.Deprecated -- Since PHP 8.0+, we guard it here 145 $reflect_lang->setAccessible(true); // Since PHP 8.1+, this does not do anything anymore 146 } 141 147 // Get the old value first 142 148 $req_language = $req_object->getLanguage(); -
linguise/tags/2.2.5/src/thirdparty/base-class.php
r3339453 r3397694 241 241 $request = Request::getInstance(); 242 242 $language_reflection = new \ReflectionProperty(get_class($request), 'language'); 243 $language_reflection->setAccessible(true); 243 if (PHP_VERSION_ID < 80100) { 244 // phpcs:ignore Generic.PHP.DeprecatedFunctions.Deprecated -- Since PHP 8.0+, we guard it here 245 $language_reflection->setAccessible(true); // Since PHP 8.1+, this does not do anything anymore 246 } 244 247 $language_reflection->setValue($request, $linguise_language); 245 248 246 249 $hostname_reflection = new \ReflectionProperty(get_class($request), 'hostname'); 247 $hostname_reflection->setAccessible(true); 250 if (PHP_VERSION_ID < 80100) { 251 // phpcs:ignore Generic.PHP.DeprecatedFunctions.Deprecated -- Since PHP 8.0+, we guard it here 252 $hostname_reflection->setAccessible(true); // Since PHP 8.1+, this does not do anything anymore 253 } 248 254 $hostname_reflection->setValue($request, $hostname); 249 255 250 256 $protocol_reflection = new \ReflectionProperty(get_class($request), 'protocol'); 251 $protocol_reflection->setAccessible(true); 257 if (PHP_VERSION_ID < 80100) { 258 // phpcs:ignore Generic.PHP.DeprecatedFunctions.Deprecated -- Since PHP 8.0+, we guard it here 259 $protocol_reflection->setAccessible(true); // Since PHP 8.1+, this does not do anything anymore 260 } 252 261 $protocol_reflection->setValue($request, $protocol); 253 262 … … 326 335 $ch = curl_init(); 327 336 list($translated_content, $response_code) = Translation::getInstance()->_translate($ch, $boundary); 328 curl_close($ch); 337 if (PHP_VERSION_ID < 80000) { 338 // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.curl_closeDeprecated,Generic.PHP.DeprecatedFunctions.Deprecated -- Since PHP 8.0+, we guard it here 339 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 340 } 329 341 330 342 if (!$translated_content || $response_code !== 200) { … … 349 361 $req_reflect = new \ReflectionClass($request); 350 362 $reflect_lang = $req_reflect->getProperty('language'); 351 $reflect_lang->setAccessible(true); 363 if (PHP_VERSION_ID < 80100) { 364 // phpcs:ignore Generic.PHP.DeprecatedFunctions.Deprecated -- Since PHP 8.0+, we guard it here 365 $reflect_lang->setAccessible(true); // Since PHP 8.1+, this does not do anything anymore 366 } 352 367 // Get the old value first 353 368 $req_language = $request->getLanguage(); -
linguise/tags/2.2.5/src/thirdparty/fluentcrm.php
r3291510 r3397694 31 31 * Determines if the integration should be loaded. 32 32 * 33 * @codeCoverageIgnore 34 * 33 35 * @return boolean 34 36 */ … … 41 43 /** 42 44 * Load the integration 45 * 46 * @codeCoverageIgnore 43 47 * 44 48 * @return void … … 58 62 /** 59 63 * Unload the integration 64 * 65 * @codeCoverageIgnore 60 66 * 61 67 * @return void … … 117 123 * @param \FluentCrm\App\Models\Subscriber $subscriber The subscriber model itself 118 124 * 125 * @codeCoverageIgnore 126 * 119 127 * @return void 120 128 */ … … 155 163 * @param \FluentCrm\App\Models\Subscriber $subscriber The subscriber model itself 156 164 * 165 * @codeCoverageIgnore 166 * 157 167 * @return void 158 168 */ … … 172 182 * @param \FluentCrm\App\Models\Subscriber $subscriber FluentCRM Subscriber model 173 183 * 184 * @codeCoverageIgnore 185 * 174 186 * @return string|null Language code, null if missing 175 187 */ 176 188 protected function getLanguageFromSubscriber($subscriber) 177 189 { 190 // @codeCoverageIgnoreStart 178 191 if (!function_exists('fluentcrm_get_subscriber_meta')) { 179 192 // Try importing fluentcrm … … 182 195 include_once $fluentcrm_path; 183 196 } 197 // @codeCoverageIgnoreEnd 184 198 185 199 // Still check in case import still fails -
linguise/tags/2.2.5/src/thirdparty/kickflip-customizer.php
r3317948 r3397694 24 24 * Decides if the integration should be loaded. 25 25 * 26 * @codeCoverageIgnore 27 * 26 28 * @return boolean 27 29 */ … … 33 35 /** 34 36 * Load the integration 37 * 38 * @codeCoverageIgnore 35 39 * 36 40 * @return void … … 79 83 * Common initialization for the integration 80 84 * 85 * @codeCoverageIgnore 86 * 81 87 * @return void 82 88 */ … … 89 95 * Unload the integration 90 96 * 97 * @codeCoverageIgnore 98 * 91 99 * @return void 92 100 */ … … 98 106 /** 99 107 * Reload the integration 108 * 109 * @codeCoverageIgnore 100 110 * 101 111 * @return void … … 123 133 return $output; 124 134 } 125 135 126 136 // Map language to WordPress locale 127 137 $wp_locale = WPHelper::mapLanguageToWordPressLocale($language); … … 158 168 if (preg_match_all('/<iframe[^>]+src=["\']([^"]+)["\']/', $buffer, $full_matches, PREG_SET_ORDER, 0)) { 159 169 foreach ($full_matches as $matches) { 170 // @codeCoverageIgnoreStart 160 171 if (strpos($matches[0], 'mczrMainIframe') === false) { 161 172 // No Kickflip iframe found, return the buffer as is 162 173 continue; 163 174 } 175 // @codeCoverageIgnoreEnd 164 176 165 177 $iframeUrl = $matches[1]; -
linguise/tags/2.2.5/src/thirdparty/wc/woocommerce.php
r3382283 r3397694 32 32 'wc/store/v1/batch', 33 33 'wc/store/v1/checkout', 34 'wc/store/v1/select-shipping-rate', 34 35 ]; 35 36 … … 90 91 'key' => 'name', 91 92 'value' => 'payment_method' 93 ] 94 ] 95 ], 96 [ 97 'name' => 'wc-cart-order-summary-header', 98 'key' => 'data-content', 99 'mode' => 'string', 100 'matchers' => [ 101 [ 102 'type' => 'attribute', 103 'key' => 'data-block-name', 104 'value' => 'woocommerce/cart-order-summary-heading-block' 105 ] 106 ] 107 ], 108 [ 109 'name' => 'wc-checkout-terms', 110 'key' => 'data-text', 111 'mode' => 'string-encoded', 112 'matchers' => [ 113 [ 114 'type' => 'attribute', 115 'key' => 'data-block-name', 116 'value' => 'woocommerce/checkout-terms-block' 92 117 ] 93 118 ] … … 147 172 148 173 // Used in payment method 149 $merged_defaults[] = [ 150 'key' => 'currency', 151 'mode' => 'exact', 152 'kind' => 'deny', 174 $exact_disallowed = [ 175 'currency', 176 'srcset', 177 'rate_id', 178 'method_id', 179 'catalog_visibility', 180 'sku', 181 'Nonce', 182 'Cart-Hash', 183 'Cart-Token', 153 184 ]; 185 foreach ($exact_disallowed as $disallowed_key) { 186 $fragment_keys[] = [ 187 'key' => $disallowed_key, 188 'mode' => 'exact', 189 'kind' => 'deny', 190 ]; 191 } 192 193 $disallowed_extras = [ 194 '(shipping|billing)_address\..*', 195 'totals\..*', 196 'prices\..*', 197 'currency_(prefix|suffix|symbol|code|decimal_separator|thousand_separator|minor_unit)', 198 'meta_data\.\d+\.key', 199 'items\.\d+\.key', 200 'shipping_rates\.\d+\.destination\..*', 201 ]; 202 foreach ($disallowed_extras as $disallowed_key) { 203 $fragment_keys[] = [ 204 'key' => $disallowed_key, 205 'mode' => 'regex_full', 206 'kind' => 'deny', 207 ]; 208 } 209 210 /* More AJAX specific allowed matches */ 211 $allowed_matches = [ 212 'shipping_rates\.\d+\.name$', 213 'shipping_rates\.\d+\.items\.\d+\.name$', 214 'shipping_rates\.\d+\.shipping_rates\.\d+\.(name|description|delivery_time)$', 215 ]; 216 foreach ($allowed_matches as $allowed_key) { 217 $fragment_keys[] = [ 218 'key' => $allowed_key, 219 'mode' => 'regex_full', 220 'kind' => 'allow', 221 ]; 222 } 154 223 155 224 self::$fragment_keys = $fragment_keys; -
linguise/tags/2.2.5/vendor/composer/installed.json
r3393999 r3397694 57 57 { 58 58 "name": "linguise/script-php", 59 "version": "v1.3.4 0",60 "version_normalized": "1.3.4 0.0",59 "version": "v1.3.41", 60 "version_normalized": "1.3.41.0", 61 61 "source": { 62 62 "type": "git", 63 63 "url": "git@bitbucket.org:linguise/script-php.git", 64 "reference": " f6196c984ea70ec37b51f35c02598e9f0baaa918"64 "reference": "dd11ab02f87a02c275f1621254068f795f7046fb" 65 65 }, 66 66 "require": { … … 75 75 "vlucas/phpdotenv": "^5.6" 76 76 }, 77 "time": "2025-11-1 2T03:56:00+00:00",77 "time": "2025-11-18T03:16:07+00:00", 78 78 "type": "library", 79 79 "installation-source": "source", -
linguise/tags/2.2.5/vendor/composer/installed.php
r3393999 r3397694 4 4 'pretty_version' => 'dev-master', 5 5 'version' => 'dev-master', 6 'reference' => ' 4a1d79317c6c26de2d4c936d1b4cf94af231914f',6 'reference' => '8bdaaf1d32585b5280a4c2cc6ab9b9722d0e8b00', 7 7 'type' => 'library', 8 8 'install_path' => __DIR__ . '/../../', … … 21 21 ), 22 22 'linguise/script-php' => array( 23 'pretty_version' => 'v1.3.4 0',24 'version' => '1.3.4 0.0',25 'reference' => ' f6196c984ea70ec37b51f35c02598e9f0baaa918',23 'pretty_version' => 'v1.3.41', 24 'version' => '1.3.41.0', 25 'reference' => 'dd11ab02f87a02c275f1621254068f795f7046fb', 26 26 'type' => 'library', 27 27 'install_path' => __DIR__ . '/../linguise/script-php', … … 32 32 'pretty_version' => 'dev-master', 33 33 'version' => 'dev-master', 34 'reference' => ' 4a1d79317c6c26de2d4c936d1b4cf94af231914f',34 'reference' => '8bdaaf1d32585b5280a4c2cc6ab9b9722d0e8b00', 35 35 'type' => 'library', 36 36 'install_path' => __DIR__ . '/../../', -
linguise/tags/2.2.5/vendor/linguise/script-php/.version
r3393999 r3397694 1 1.3.4 01 1.3.41 -
linguise/tags/2.2.5/vendor/linguise/script-php/src/Certificates.php
r3300467 r3397694 106 106 $etag = $this->getEtag($headers); 107 107 108 curl_close($ch); 108 if (PHP_VERSION_ID < 80000) { 109 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 110 } 109 111 } 110 112 … … 130 132 131 133 if ($info['http_code'] !== 200 || $info['content_type'] !== 'application/x-pem-file') { 134 if (PHP_VERSION_ID < 80000) { 135 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 136 } 132 137 // Something went wrong 133 138 return; … … 139 144 $info = curl_getinfo($ch); 140 145 146 if (PHP_VERSION_ID < 80000) { 147 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 148 } 149 141 150 if ($info['http_code'] !== 200) { 142 151 // Something went wrong -
linguise/tags/2.2.5/vendor/linguise/script-php/src/Debug.php
r2747856 r3397694 3 3 namespace Linguise\Vendor\Linguise\Script\Core; 4 4 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore 6 6 7 7 class Debug … … 19 19 self::$error_file = dirname(__FILE__) . '/../debug.php'; 20 20 21 if (!file_exists(self::$error_file)) { 21 $is_testing = defined('LINGUISE_SCRIPT_TESTING') && LINGUISE_SCRIPT_TESTING; 22 23 if (!file_exists(self::$error_file) && !$is_testing) { 22 24 file_put_contents(self::$error_file, '<?php die(); ?>' . PHP_EOL); 23 25 } … … 41 43 } 42 44 45 if (defined('LINGUISE_SCRIPT_TESTING') && LINGUISE_SCRIPT_TESTING) { 46 // during testing, do not write to file 47 return; 48 } 49 43 50 if (!is_writable(self::$error_file)) { 44 51 return; … … 55 62 { 56 63 if (self::$enabled === false) { 64 return; 65 } 66 67 if (defined('LINGUISE_SCRIPT_TESTING') && LINGUISE_SCRIPT_TESTING) { 68 // during testing, do not write to file 57 69 return; 58 70 } … … 86 98 public static function saveError($error) 87 99 { 100 if (defined('LINGUISE_SCRIPT_TESTING') && LINGUISE_SCRIPT_TESTING) { 101 // during testing, do not write to file 102 return; 103 } 104 88 105 $file = dirname(__FILE__) . '/../errors.php'; 89 106 -
linguise/tags/2.2.5/vendor/linguise/script-php/src/JsonWalker.php
r3257498 r3397694 3 3 namespace Linguise\Vendor\Linguise\Script\Core; 4 4 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore 6 6 7 7 /** 8 8 * Check if the array is an actual object or not. 9 * 10 * @codeCoverageIgnore 9 11 * 10 12 * @param array|object $arr_or_object The array or object to be checked -
linguise/tags/2.2.5/vendor/linguise/script-php/src/Management.php
r3388557 r3397694 509 509 curl_exec($ch); 510 510 $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); 511 // log error to apache error 512 curl_close($ch); 511 if (PHP_VERSION_ID < 80000) { 512 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 513 } 513 514 514 515 if ($response_code !== 200) { … … 546 547 $response = curl_exec($ch); 547 548 $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); 548 curl_close($ch); 549 if (PHP_VERSION_ID < 80000) { 550 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 551 } 549 552 550 553 if ($response_code !== 200) { … … 603 606 $response = curl_exec($ch); 604 607 $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); 605 curl_close($ch); 608 if (PHP_VERSION_ID < 80000) { 609 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 610 } 606 611 607 612 if ($response_code !== 200) { -
linguise/tags/2.2.5/vendor/linguise/script-php/src/Platforms/PrestaShop.php
r3393999 r3397694 346 346 $ch = curl_init(); 347 347 list($translated_content, $response_code) = Translation::getInstance()->_translate($ch, $boundary); 348 curl_close($ch); 348 if (PHP_VERSION_ID < 80000) { 349 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 350 } 349 351 350 352 if (!$translated_content || $response_code !== 200) { -
linguise/tags/2.2.5/vendor/linguise/script-php/src/Processor.php
r3377801 r3397694 2 2 namespace Linguise\Vendor\Linguise\Script\Core; 3 3 4 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); 4 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore 5 5 6 6 class Processor { … … 27 27 28 28 // Finalize defer actions on shutdown 29 // @codeCoverageIgnoreStart 29 30 register_shutdown_function(function() { 30 31 Defer::getInstance()->finalize(); 31 32 Database::getInstance()->close(); 32 33 }); 34 // @codeCoverageIgnoreEnd 33 35 } 34 36 … … 39 41 { 40 42 if (!isset($_GET['linguise_language'])) { 41 die(); 43 if (defined('LINGUISE_SCRIPT_TESTING') && LINGUISE_SCRIPT_TESTING) { 44 // during testing, do not write to file 45 return; 46 } 47 die(); // @codeCoverageIgnore 42 48 } 43 49 44 50 // AI Translation Stuff 45 if ( $_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['live_editor_ai_translation']) ) {51 if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['live_editor_ai_translation']) ) { 46 52 $_SERVER['REQUEST_METHOD'] = 'GET'; 47 53 Translation::getInstance()->enableAiTranslation($_POST['live_editor_ai_translation']); … … 61 67 if (Response::getInstance()->getResponseCode() === 304) { 62 68 Debug::log('304 Not modified'); 63 Response::getInstance()->end();69 return Response::getInstance()->end(); 64 70 } 65 71 … … 87 93 } 88 94 95 /** 96 * Update the Linguise Script PHP to the latest version 97 * 98 * @codeCoverageIgnore 99 * 100 * @return void 101 */ 89 102 public function update() 90 103 { … … 100 113 echo '<p>It seems you were trying the Live Editor with the wrong domain configuration. </p> 101 114 <p>Please double-check on your configuration in your Linguise dashboard or reach out to our support team</p>'; 102 die(); 115 116 if (defined('LINGUISE_SCRIPT_TESTING') && LINGUISE_SCRIPT_TESTING) { 117 // stop execution for testing purposes 118 return; 119 } 120 die(); // @codeCoverageIgnore 103 121 } 104 122 … … 120 138 echo '<p>It seems you were trying the Live Editor with the wrong domain configuration. </p> 121 139 <p>Please double-check on your configuration in your Linguise dashboard or reach out to our support team</p>'; 122 die(); 140 141 if (defined('LINGUISE_SCRIPT_TESTING') && LINGUISE_SCRIPT_TESTING) { 142 // stop execution for testing purposes 143 return; 144 } 145 die(); // @codeCoverageIgnore 123 146 } 124 147 … … 152 175 Certificates::getInstance()->downloadCertificates(); 153 176 } 154 155 177 } -
linguise/tags/2.2.5/vendor/linguise/script-php/src/Translation.php
r3388557 r3397694 97 97 } 98 98 99 curl_close($ch); 99 if (PHP_VERSION_ID < 80000) { 100 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 101 } 100 102 101 103 $result = json_decode($translated_content); … … 223 225 Debug::log('Translated content: ' . PHP_EOL . '######################' . PHP_EOL . $translated_content . PHP_EOL . '######################', 5); 224 226 225 curl_close($ch); 227 if (PHP_VERSION_ID < 80000) { 228 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 229 } 226 230 227 231 if (!$translated_content || $response_code !== 200) { -
linguise/tags/2.2.5/vendor/linguise/script-php/src/Updater.php
r2652292 r3397694 57 57 } 58 58 $content = curl_exec($ch); 59 curl_close($ch); 59 if (PHP_VERSION_ID < 80000) { 60 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 61 } 60 62 61 63 if (!$content) { … … 93 95 } 94 96 $file_content = curl_exec($ch); 95 curl_close($ch); 97 if (PHP_VERSION_ID < 80000) { 98 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 99 } 96 100 97 101 if (!$file_content) { -
linguise/trunk/linguise.php
r3393999 r3397694 5 5 * Plugin URI: https://www.linguise.com/ 6 6 * Description: Linguise translation plugin 7 * Version:2.2. 47 * Version:2.2.5 8 8 * Text Domain: linguise 9 9 * Domain Path: /languages -
linguise/trunk/readme.txt
r3393999 r3397694 4 4 Requires at least: 4.0 5 5 Tested up to: 6.8 6 Stable tag: 2.2. 46 Stable tag: 2.2.5 7 7 Requires PHP: 7.0 8 8 License: GPLv2 or later … … 107 107 108 108 == Changelog == 109 = 2.2.5 = 110 - Fix: Issues with fragment i18n is not getting translated because of CDATA 111 - Feature: Try to capture and translate preloaded API request 112 - Fix: Some fragment data not captured in WooCommerce should be translated now 113 109 114 = 2.2.4 = 110 115 - Feature: Support kinyarwanda (rw) language -
linguise/trunk/src/AttributeHandler.php
r3366846 r3397694 54 54 ], 55 55 ]; 56 57 $current_list[] = [ 58 'name' => 'linguise-demo-string-encoded', 59 'key' => 'data-label-encoded', 60 'mode' => 'string-encoded', 61 'matchers' => [ 62 [ 63 'key' => 'sc-linguise-demo-encoded', 64 'type' => 'tag' 65 ] 66 ], 67 ]; 56 68 } 57 69 … … 213 225 ] 214 226 ]; 227 } elseif (isset($matcher['mode']) && $matcher['mode'] === 'string-encoded') { 228 $cast_data = isset($matcher['cast']) ? $matcher['cast'] : 'html-main'; 229 230 $collected_temp = [ 231 [ 232 'key' => $matcher['key'], 233 'value' => html_entity_decode($key_data, ENT_QUOTES | ENT_SUBSTITUTE, 'utf-8'), 234 'format' => $cast_data, 235 ] 236 ]; 215 237 } else { 216 238 $json_data = json_decode($key_data, true); … … 349 371 350 372 $protected_json = HTMLHelper::protectEntity($replaced_text); 373 } elseif (isset($matched['mode']) && $matched['mode'] === 'string-encoded') { 374 // Get first item 375 $first_fragment = isset($fragment_list['fragments'][0]) ? $fragment_list['fragments'][0] : null; 376 if (empty($first_fragment)) { 377 continue; 378 } 379 380 $first_value = isset($first_fragment['value']) ? $first_fragment['value'] : null; 381 if (empty($first_value)) { 382 continue; 383 } 384 385 // Replace the data 386 $replaced_text = htmlspecialchars($first_value, ENT_QUOTES, 'UTF-8', false); 387 if ($should_encode) { 388 $replaced_text = rawurlencode($replaced_text); 389 } 390 391 $protected_json = HTMLHelper::protectEntity($replaced_text); 351 392 } else { 352 393 // JSON mode, we need to decode the JSON data -
linguise/trunk/src/FragmentBase.php
r3381590 r3397694 249 249 250 250 if (empty($value) || !is_string($value)) { 251 return false; 252 } 253 254 if (is_string($value) && empty($value)) { 251 255 return false; 252 256 } … … 570 574 ]; 571 575 576 $current_list[] = [ 577 'name' => 'wc-settings-encoded-alt', 578 'match' => 'var wcSettings = JSON\.parse\( decodeURIComponent\( \'(.*?)\' \) \);', 579 'replacement' => 'var wcSettings = JSON.parse( decodeURIComponent( \'$$JSON_DATA$$\' ) );', 580 'encode' => true, 581 ]; 582 583 $current_list[] = [ 584 'name' => 'wc-settings-api-inject', 585 'match' => 'wp\.apiFetch\.createPreloadingMiddleware\(\s*JSON\.parse\(\s*decodeURIComponent\(\s*\'(.*?)\'\s*\)\s*\)\s*\)', 586 'replacement' => 'wp.apiFetch.createPreloadingMiddleware( JSON.parse( decodeURIComponent( \'$$JSON_DATA$$\' ) ) )', 587 'encode' => true, 588 ]; 589 572 590 if (defined('CFCORE_VER')) { 573 591 $current_list[] = [ -
linguise/trunk/src/FragmentHandler.php
r3393354 r3397694 91 91 } 92 92 if ($tl_string || $tl_link || is_string($tl_dom) || $allowed_filters) { 93 $collected_fragments[] = [ 94 'key' => $use_key, 95 'value' => $value, 96 'format' => $format, 97 ]; 93 // Extra check 94 if (is_string($value) && !empty($value)) { 95 $collected_fragments[] = [ 96 'key' => $use_key, 97 'value' => $value, 98 'format' => $format, 99 ]; 100 } 98 101 } 99 102 } … … 125 128 } 126 129 return $collected_fragments; 130 } 131 132 /** 133 * Protect sprintf templates in the text by wrapping them in a span tag 134 * 135 * @param string $text The text to be protected 136 * 137 * @return string The protected text 138 */ 139 private static function protectSprintfTemplates($text) 140 { 141 $pattern = '/(%(?:\d+\$)?[+-]?(?:\d+)?(?:\.\d+)?[bcdeEfFgGosuxX])/'; 142 $replacement = '<span-ling translate="no">$1</span-ling>'; 143 $result = preg_replace($pattern, $replacement, $text); 144 if (!empty($result)) { 145 return $result; 146 } 147 return $text; 148 } 149 150 /** 151 * Restore sprintf templates in the text by unwrapping them from the span tag 152 * 153 * @param string $text The text to be restored 154 * 155 * @return string The restored text 156 */ 157 private static function restoreSprintfTemplates($text) 158 { 159 $pattern = '/<span-ling translate="no">(%(?:\d+\$)?[+-]?(?:\d+)?(?:\.\d+)?[bcdeEfFgGosuxX])<\/span-ling>/'; 160 $result = preg_replace($pattern, '$1', $text); 161 if (!empty($result)) { 162 return $result; 163 } 164 return $text; 127 165 } 128 166 … … 175 213 $html .= ' ' . $tag_select . '="' . $fragment['value'] . '">'; 176 214 } else { 177 $html .= '>' . $frag_value;215 $html .= '>' . self::protectSprintfTemplates($frag_value); 178 216 } 179 217 $html .= '</' . $tag . '>' . "\n"; … … 230 268 } 231 269 270 $fragment_value = self::restoreSprintfTemplates($fragment_value); 271 232 272 if (!isset($fragments[$fragment_name])) { 233 273 $fragments[$fragment_name] = []; … … 293 333 $override_list = self::getJSONOverrideMatcher($html_data); 294 334 335 $multi_matched = []; 295 336 foreach ($override_list as $override_item) { 296 337 $script_content = HTMLHelper::unclobberCdataInternal($script_content); … … 344 385 $collected_temp = self::collectFragmentFromJson($json_data, $is_strict); 345 386 if (!empty($collected_temp)) { 346 return[387 $multi_matched[] = [ 347 388 'name' => $override_item['name'], 348 389 'fragments' => $collected_temp, … … 351 392 } 352 393 353 return null; 394 if (empty($multi_matched)) { 395 return null; 396 } 397 398 return $multi_matched; 354 399 } 355 400 … … 442 487 $overridden_temp = self::tryMatchWithOverride($script, $html_data); 443 488 if (is_array($overridden_temp)) { 444 $all_fragments[$overridden_temp['name']][$overridden_temp['name']] = [ 445 'mode' => 'override', 446 'fragments' => $overridden_temp['fragments'], 447 ]; 489 foreach ($overridden_temp as $overridden_temp_item) { 490 $all_fragments[$overridden_temp_item['name']][$overridden_temp_item['name']] = [ 491 'mode' => 'override', 492 'fragments' => $overridden_temp_item['fragments'], 493 ]; 494 } 448 495 449 496 continue; … … 475 522 $overridden_temp = self::tryMatchWithOverride($script, $html_data); 476 523 if (is_array($overridden_temp)) { 477 $all_fragments[$frag_id][$overridden_temp['name']] = [ 478 'mode' => 'override', 479 'fragments' => $overridden_temp['fragments'], 480 ]; 524 foreach ($overridden_temp as $overridden_temp_item) { 525 $all_fragments[$frag_id][$overridden_temp_item['name']] = [ 526 'mode' => 'override', 527 'fragments' => $overridden_temp_item['fragments'], 528 ]; 529 } 481 530 } 482 531 continue; … … 567 616 } 568 617 $decoded_key = self::unwrapKey($fragment['key']); 618 $merged_key = strpos($decoded_key, '[') === 0 ? '$' . $decoded_key : '$.' . $decoded_key; 569 619 try { 570 $json_data->set( '$.' . $decoded_key, $fragment['value']);620 $json_data->set($merged_key, $fragment['value']); 571 621 } catch (\Linguise\Vendor\JsonPath\InvalidJsonPathException $e) { 572 Debug::log('Failed to set key in override: ' . $ decoded_key . ' -> ' . $e->getMessage());622 Debug::log('Failed to set key in override: ' . $merged_key . ' -> ' . $e->getMessage()); 573 623 } 574 624 } … … 601 651 } 602 652 $decoded_key = self::unwrapKey($fragment['key']); 653 $merged_key = strpos($decoded_key, '[') === 0 ? '$' . $decoded_key : '$.' . $decoded_key; 603 654 try { 604 $json_data->set( '$.' . $decoded_key, $fragment['value']);655 $json_data->set($merged_key, $fragment['value']); 605 656 } catch (\Linguise\Vendor\JsonPath\InvalidJsonPathException $e) { 606 Debug::log('Failed to set key in override: ' . $ decoded_key . ' -> ' . $e->getMessage());657 Debug::log('Failed to set key in override: ' . $merged_key . ' -> ' . $e->getMessage()); 607 658 } 608 659 } … … 676 727 { 677 728 $full_param_name = $param_name . '-js-translations'; 678 $overall_matchers = preg_match('/id=["\']' . preg_quote($full_param_name) . ' .*?>\s*\(\s*function\(\s*domain,\s*translations\s*\)\s*\{.*?\}\s*\)\s*\(\s*["\']([\w_\-]+)["\']\s*,\s*\{(.*?)\}\s*\)\s*;\s*<\/script>/si', $html_data, $html_matches);729 $overall_matchers = preg_match('/id=["\']' . preg_quote($full_param_name) . '["\'].*?>.*?\(\s*function\(\s*domain,\s*translations\s*\)\s*\{.*?\}\s*\)\s*\(\s*["\']([\w_\-]+)["\']\s*,\s*\{(.*?)\}\s*\)\s*;.*?<\/script>/si', $html_data, $html_matches); 679 730 if ($overall_matchers === false || $overall_matchers === 0) { 680 731 return $html_data; … … 732 783 // dump back to JSON 733 784 $replaced_json = json_encode($json_data); 734 $substr_ptrn = '/(id=["\']' . preg_quote($full_param_name) . '["\'].*?> \s*\(\s*function\(\s*domain,\s*translations\s*\)\s*\{.*?\}\s*\)\s*\(\s*["\']([\w_\-]+)["\']\s*,\s*)(.*?)(\s*\)\s*;\s*<\/script>)/si';785 $substr_ptrn = '/(id=["\']' . preg_quote($full_param_name) . '["\'].*?>.*?\(\s*function\(\s*domain,\s*translations\s*\)\s*\{.*?\}\s*\)\s*\(\s*["\']([\w_\-]+)["\']\s*,\s*)(.*?)(\s*\)\s*;.*?<\/script>)/si'; 735 786 736 787 $replacement = preg_replace($substr_ptrn, '$1' . $replaced_json . '$4', $html_data, 1, $count); -
linguise/trunk/src/Helper.php
r3379190 r3397694 165 165 // If not set, we use the same as $language 166 166 // If set and NULL we should return null 167 if (isset($languages->$language->wp_code) && !empty($languages->$language->wp_code)) { 167 if (!array_key_exists('wp_code', (array)$languages->$language)) { 168 return $language; 169 } 170 if (!empty($languages->$language->wp_code)) { 168 171 return $languages->$language->wp_code; 169 } elseif (!isset($languages->$language->wp_code)) {170 return $language;171 172 } 172 173 -
linguise/trunk/src/constants.php
r3393999 r3397694 1 1 <?php 2 2 if (!defined('LINGUISE_SCRIPT_TRANSLATION_VERSION')) { 3 define('LINGUISE_SCRIPT_TRANSLATION_VERSION', 'wordpress_plugin/2.2. 4');3 define('LINGUISE_SCRIPT_TRANSLATION_VERSION', 'wordpress_plugin/2.2.5'); 4 4 } 5 5 6 6 if (!defined('LINGUISE_VERSION')) { 7 define('LINGUISE_VERSION', '2.2. 4');7 define('LINGUISE_VERSION', '2.2.5'); 8 8 } -
linguise/trunk/src/rest-ajax.php
r3291510 r3397694 120 120 $ch = curl_init(); 121 121 list($translated_content, $response_code) = Translation::getInstance()->_translate($ch, $boundary); 122 curl_close($ch); 122 if (PHP_VERSION_ID < 80000) { 123 // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.curl_closeDeprecated,Generic.PHP.DeprecatedFunctions.Deprecated -- Since PHP 8.0+, we guard it here 124 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 125 } 123 126 124 127 if (!$translated_content || $response_code !== 200) { … … 138 141 $req_reflect = new \ReflectionClass($req_object); 139 142 $reflect_lang = $req_reflect->getProperty('language'); 140 $reflect_lang->setAccessible(true); 143 if (PHP_VERSION_ID < 80100) { 144 // phpcs:ignore Generic.PHP.DeprecatedFunctions.Deprecated -- Since PHP 8.0+, we guard it here 145 $reflect_lang->setAccessible(true); // Since PHP 8.1+, this does not do anything anymore 146 } 141 147 // Get the old value first 142 148 $req_language = $req_object->getLanguage(); -
linguise/trunk/src/thirdparty/base-class.php
r3339453 r3397694 241 241 $request = Request::getInstance(); 242 242 $language_reflection = new \ReflectionProperty(get_class($request), 'language'); 243 $language_reflection->setAccessible(true); 243 if (PHP_VERSION_ID < 80100) { 244 // phpcs:ignore Generic.PHP.DeprecatedFunctions.Deprecated -- Since PHP 8.0+, we guard it here 245 $language_reflection->setAccessible(true); // Since PHP 8.1+, this does not do anything anymore 246 } 244 247 $language_reflection->setValue($request, $linguise_language); 245 248 246 249 $hostname_reflection = new \ReflectionProperty(get_class($request), 'hostname'); 247 $hostname_reflection->setAccessible(true); 250 if (PHP_VERSION_ID < 80100) { 251 // phpcs:ignore Generic.PHP.DeprecatedFunctions.Deprecated -- Since PHP 8.0+, we guard it here 252 $hostname_reflection->setAccessible(true); // Since PHP 8.1+, this does not do anything anymore 253 } 248 254 $hostname_reflection->setValue($request, $hostname); 249 255 250 256 $protocol_reflection = new \ReflectionProperty(get_class($request), 'protocol'); 251 $protocol_reflection->setAccessible(true); 257 if (PHP_VERSION_ID < 80100) { 258 // phpcs:ignore Generic.PHP.DeprecatedFunctions.Deprecated -- Since PHP 8.0+, we guard it here 259 $protocol_reflection->setAccessible(true); // Since PHP 8.1+, this does not do anything anymore 260 } 252 261 $protocol_reflection->setValue($request, $protocol); 253 262 … … 326 335 $ch = curl_init(); 327 336 list($translated_content, $response_code) = Translation::getInstance()->_translate($ch, $boundary); 328 curl_close($ch); 337 if (PHP_VERSION_ID < 80000) { 338 // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.curl_closeDeprecated,Generic.PHP.DeprecatedFunctions.Deprecated -- Since PHP 8.0+, we guard it here 339 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 340 } 329 341 330 342 if (!$translated_content || $response_code !== 200) { … … 349 361 $req_reflect = new \ReflectionClass($request); 350 362 $reflect_lang = $req_reflect->getProperty('language'); 351 $reflect_lang->setAccessible(true); 363 if (PHP_VERSION_ID < 80100) { 364 // phpcs:ignore Generic.PHP.DeprecatedFunctions.Deprecated -- Since PHP 8.0+, we guard it here 365 $reflect_lang->setAccessible(true); // Since PHP 8.1+, this does not do anything anymore 366 } 352 367 // Get the old value first 353 368 $req_language = $request->getLanguage(); -
linguise/trunk/src/thirdparty/fluentcrm.php
r3291510 r3397694 31 31 * Determines if the integration should be loaded. 32 32 * 33 * @codeCoverageIgnore 34 * 33 35 * @return boolean 34 36 */ … … 41 43 /** 42 44 * Load the integration 45 * 46 * @codeCoverageIgnore 43 47 * 44 48 * @return void … … 58 62 /** 59 63 * Unload the integration 64 * 65 * @codeCoverageIgnore 60 66 * 61 67 * @return void … … 117 123 * @param \FluentCrm\App\Models\Subscriber $subscriber The subscriber model itself 118 124 * 125 * @codeCoverageIgnore 126 * 119 127 * @return void 120 128 */ … … 155 163 * @param \FluentCrm\App\Models\Subscriber $subscriber The subscriber model itself 156 164 * 165 * @codeCoverageIgnore 166 * 157 167 * @return void 158 168 */ … … 172 182 * @param \FluentCrm\App\Models\Subscriber $subscriber FluentCRM Subscriber model 173 183 * 184 * @codeCoverageIgnore 185 * 174 186 * @return string|null Language code, null if missing 175 187 */ 176 188 protected function getLanguageFromSubscriber($subscriber) 177 189 { 190 // @codeCoverageIgnoreStart 178 191 if (!function_exists('fluentcrm_get_subscriber_meta')) { 179 192 // Try importing fluentcrm … … 182 195 include_once $fluentcrm_path; 183 196 } 197 // @codeCoverageIgnoreEnd 184 198 185 199 // Still check in case import still fails -
linguise/trunk/src/thirdparty/kickflip-customizer.php
r3317948 r3397694 24 24 * Decides if the integration should be loaded. 25 25 * 26 * @codeCoverageIgnore 27 * 26 28 * @return boolean 27 29 */ … … 33 35 /** 34 36 * Load the integration 37 * 38 * @codeCoverageIgnore 35 39 * 36 40 * @return void … … 79 83 * Common initialization for the integration 80 84 * 85 * @codeCoverageIgnore 86 * 81 87 * @return void 82 88 */ … … 89 95 * Unload the integration 90 96 * 97 * @codeCoverageIgnore 98 * 91 99 * @return void 92 100 */ … … 98 106 /** 99 107 * Reload the integration 108 * 109 * @codeCoverageIgnore 100 110 * 101 111 * @return void … … 123 133 return $output; 124 134 } 125 135 126 136 // Map language to WordPress locale 127 137 $wp_locale = WPHelper::mapLanguageToWordPressLocale($language); … … 158 168 if (preg_match_all('/<iframe[^>]+src=["\']([^"]+)["\']/', $buffer, $full_matches, PREG_SET_ORDER, 0)) { 159 169 foreach ($full_matches as $matches) { 170 // @codeCoverageIgnoreStart 160 171 if (strpos($matches[0], 'mczrMainIframe') === false) { 161 172 // No Kickflip iframe found, return the buffer as is 162 173 continue; 163 174 } 175 // @codeCoverageIgnoreEnd 164 176 165 177 $iframeUrl = $matches[1]; -
linguise/trunk/src/thirdparty/wc/woocommerce.php
r3382283 r3397694 32 32 'wc/store/v1/batch', 33 33 'wc/store/v1/checkout', 34 'wc/store/v1/select-shipping-rate', 34 35 ]; 35 36 … … 90 91 'key' => 'name', 91 92 'value' => 'payment_method' 93 ] 94 ] 95 ], 96 [ 97 'name' => 'wc-cart-order-summary-header', 98 'key' => 'data-content', 99 'mode' => 'string', 100 'matchers' => [ 101 [ 102 'type' => 'attribute', 103 'key' => 'data-block-name', 104 'value' => 'woocommerce/cart-order-summary-heading-block' 105 ] 106 ] 107 ], 108 [ 109 'name' => 'wc-checkout-terms', 110 'key' => 'data-text', 111 'mode' => 'string-encoded', 112 'matchers' => [ 113 [ 114 'type' => 'attribute', 115 'key' => 'data-block-name', 116 'value' => 'woocommerce/checkout-terms-block' 92 117 ] 93 118 ] … … 147 172 148 173 // Used in payment method 149 $merged_defaults[] = [ 150 'key' => 'currency', 151 'mode' => 'exact', 152 'kind' => 'deny', 174 $exact_disallowed = [ 175 'currency', 176 'srcset', 177 'rate_id', 178 'method_id', 179 'catalog_visibility', 180 'sku', 181 'Nonce', 182 'Cart-Hash', 183 'Cart-Token', 153 184 ]; 185 foreach ($exact_disallowed as $disallowed_key) { 186 $fragment_keys[] = [ 187 'key' => $disallowed_key, 188 'mode' => 'exact', 189 'kind' => 'deny', 190 ]; 191 } 192 193 $disallowed_extras = [ 194 '(shipping|billing)_address\..*', 195 'totals\..*', 196 'prices\..*', 197 'currency_(prefix|suffix|symbol|code|decimal_separator|thousand_separator|minor_unit)', 198 'meta_data\.\d+\.key', 199 'items\.\d+\.key', 200 'shipping_rates\.\d+\.destination\..*', 201 ]; 202 foreach ($disallowed_extras as $disallowed_key) { 203 $fragment_keys[] = [ 204 'key' => $disallowed_key, 205 'mode' => 'regex_full', 206 'kind' => 'deny', 207 ]; 208 } 209 210 /* More AJAX specific allowed matches */ 211 $allowed_matches = [ 212 'shipping_rates\.\d+\.name$', 213 'shipping_rates\.\d+\.items\.\d+\.name$', 214 'shipping_rates\.\d+\.shipping_rates\.\d+\.(name|description|delivery_time)$', 215 ]; 216 foreach ($allowed_matches as $allowed_key) { 217 $fragment_keys[] = [ 218 'key' => $allowed_key, 219 'mode' => 'regex_full', 220 'kind' => 'allow', 221 ]; 222 } 154 223 155 224 self::$fragment_keys = $fragment_keys; -
linguise/trunk/vendor/composer/installed.json
r3393999 r3397694 57 57 { 58 58 "name": "linguise/script-php", 59 "version": "v1.3.4 0",60 "version_normalized": "1.3.4 0.0",59 "version": "v1.3.41", 60 "version_normalized": "1.3.41.0", 61 61 "source": { 62 62 "type": "git", 63 63 "url": "git@bitbucket.org:linguise/script-php.git", 64 "reference": " f6196c984ea70ec37b51f35c02598e9f0baaa918"64 "reference": "dd11ab02f87a02c275f1621254068f795f7046fb" 65 65 }, 66 66 "require": { … … 75 75 "vlucas/phpdotenv": "^5.6" 76 76 }, 77 "time": "2025-11-1 2T03:56:00+00:00",77 "time": "2025-11-18T03:16:07+00:00", 78 78 "type": "library", 79 79 "installation-source": "source", -
linguise/trunk/vendor/composer/installed.php
r3393999 r3397694 4 4 'pretty_version' => 'dev-master', 5 5 'version' => 'dev-master', 6 'reference' => ' 4a1d79317c6c26de2d4c936d1b4cf94af231914f',6 'reference' => '8bdaaf1d32585b5280a4c2cc6ab9b9722d0e8b00', 7 7 'type' => 'library', 8 8 'install_path' => __DIR__ . '/../../', … … 21 21 ), 22 22 'linguise/script-php' => array( 23 'pretty_version' => 'v1.3.4 0',24 'version' => '1.3.4 0.0',25 'reference' => ' f6196c984ea70ec37b51f35c02598e9f0baaa918',23 'pretty_version' => 'v1.3.41', 24 'version' => '1.3.41.0', 25 'reference' => 'dd11ab02f87a02c275f1621254068f795f7046fb', 26 26 'type' => 'library', 27 27 'install_path' => __DIR__ . '/../linguise/script-php', … … 32 32 'pretty_version' => 'dev-master', 33 33 'version' => 'dev-master', 34 'reference' => ' 4a1d79317c6c26de2d4c936d1b4cf94af231914f',34 'reference' => '8bdaaf1d32585b5280a4c2cc6ab9b9722d0e8b00', 35 35 'type' => 'library', 36 36 'install_path' => __DIR__ . '/../../', -
linguise/trunk/vendor/linguise/script-php/.version
r3393999 r3397694 1 1.3.4 01 1.3.41 -
linguise/trunk/vendor/linguise/script-php/src/Certificates.php
r3300467 r3397694 106 106 $etag = $this->getEtag($headers); 107 107 108 curl_close($ch); 108 if (PHP_VERSION_ID < 80000) { 109 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 110 } 109 111 } 110 112 … … 130 132 131 133 if ($info['http_code'] !== 200 || $info['content_type'] !== 'application/x-pem-file') { 134 if (PHP_VERSION_ID < 80000) { 135 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 136 } 132 137 // Something went wrong 133 138 return; … … 139 144 $info = curl_getinfo($ch); 140 145 146 if (PHP_VERSION_ID < 80000) { 147 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 148 } 149 141 150 if ($info['http_code'] !== 200) { 142 151 // Something went wrong -
linguise/trunk/vendor/linguise/script-php/src/Debug.php
r2747856 r3397694 3 3 namespace Linguise\Vendor\Linguise\Script\Core; 4 4 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore 6 6 7 7 class Debug … … 19 19 self::$error_file = dirname(__FILE__) . '/../debug.php'; 20 20 21 if (!file_exists(self::$error_file)) { 21 $is_testing = defined('LINGUISE_SCRIPT_TESTING') && LINGUISE_SCRIPT_TESTING; 22 23 if (!file_exists(self::$error_file) && !$is_testing) { 22 24 file_put_contents(self::$error_file, '<?php die(); ?>' . PHP_EOL); 23 25 } … … 41 43 } 42 44 45 if (defined('LINGUISE_SCRIPT_TESTING') && LINGUISE_SCRIPT_TESTING) { 46 // during testing, do not write to file 47 return; 48 } 49 43 50 if (!is_writable(self::$error_file)) { 44 51 return; … … 55 62 { 56 63 if (self::$enabled === false) { 64 return; 65 } 66 67 if (defined('LINGUISE_SCRIPT_TESTING') && LINGUISE_SCRIPT_TESTING) { 68 // during testing, do not write to file 57 69 return; 58 70 } … … 86 98 public static function saveError($error) 87 99 { 100 if (defined('LINGUISE_SCRIPT_TESTING') && LINGUISE_SCRIPT_TESTING) { 101 // during testing, do not write to file 102 return; 103 } 104 88 105 $file = dirname(__FILE__) . '/../errors.php'; 89 106 -
linguise/trunk/vendor/linguise/script-php/src/JsonWalker.php
r3257498 r3397694 3 3 namespace Linguise\Vendor\Linguise\Script\Core; 4 4 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); 5 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore 6 6 7 7 /** 8 8 * Check if the array is an actual object or not. 9 * 10 * @codeCoverageIgnore 9 11 * 10 12 * @param array|object $arr_or_object The array or object to be checked -
linguise/trunk/vendor/linguise/script-php/src/Management.php
r3388557 r3397694 509 509 curl_exec($ch); 510 510 $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); 511 // log error to apache error 512 curl_close($ch); 511 if (PHP_VERSION_ID < 80000) { 512 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 513 } 513 514 514 515 if ($response_code !== 200) { … … 546 547 $response = curl_exec($ch); 547 548 $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); 548 curl_close($ch); 549 if (PHP_VERSION_ID < 80000) { 550 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 551 } 549 552 550 553 if ($response_code !== 200) { … … 603 606 $response = curl_exec($ch); 604 607 $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); 605 curl_close($ch); 608 if (PHP_VERSION_ID < 80000) { 609 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 610 } 606 611 607 612 if ($response_code !== 200) { -
linguise/trunk/vendor/linguise/script-php/src/Platforms/PrestaShop.php
r3393999 r3397694 346 346 $ch = curl_init(); 347 347 list($translated_content, $response_code) = Translation::getInstance()->_translate($ch, $boundary); 348 curl_close($ch); 348 if (PHP_VERSION_ID < 80000) { 349 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 350 } 349 351 350 352 if (!$translated_content || $response_code !== 200) { -
linguise/trunk/vendor/linguise/script-php/src/Processor.php
r3377801 r3397694 2 2 namespace Linguise\Vendor\Linguise\Script\Core; 3 3 4 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); 4 defined('LINGUISE_SCRIPT_TRANSLATION') or die(); // @codeCoverageIgnore 5 5 6 6 class Processor { … … 27 27 28 28 // Finalize defer actions on shutdown 29 // @codeCoverageIgnoreStart 29 30 register_shutdown_function(function() { 30 31 Defer::getInstance()->finalize(); 31 32 Database::getInstance()->close(); 32 33 }); 34 // @codeCoverageIgnoreEnd 33 35 } 34 36 … … 39 41 { 40 42 if (!isset($_GET['linguise_language'])) { 41 die(); 43 if (defined('LINGUISE_SCRIPT_TESTING') && LINGUISE_SCRIPT_TESTING) { 44 // during testing, do not write to file 45 return; 46 } 47 die(); // @codeCoverageIgnore 42 48 } 43 49 44 50 // AI Translation Stuff 45 if ( $_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['live_editor_ai_translation']) ) {51 if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['live_editor_ai_translation']) ) { 46 52 $_SERVER['REQUEST_METHOD'] = 'GET'; 47 53 Translation::getInstance()->enableAiTranslation($_POST['live_editor_ai_translation']); … … 61 67 if (Response::getInstance()->getResponseCode() === 304) { 62 68 Debug::log('304 Not modified'); 63 Response::getInstance()->end();69 return Response::getInstance()->end(); 64 70 } 65 71 … … 87 93 } 88 94 95 /** 96 * Update the Linguise Script PHP to the latest version 97 * 98 * @codeCoverageIgnore 99 * 100 * @return void 101 */ 89 102 public function update() 90 103 { … … 100 113 echo '<p>It seems you were trying the Live Editor with the wrong domain configuration. </p> 101 114 <p>Please double-check on your configuration in your Linguise dashboard or reach out to our support team</p>'; 102 die(); 115 116 if (defined('LINGUISE_SCRIPT_TESTING') && LINGUISE_SCRIPT_TESTING) { 117 // stop execution for testing purposes 118 return; 119 } 120 die(); // @codeCoverageIgnore 103 121 } 104 122 … … 120 138 echo '<p>It seems you were trying the Live Editor with the wrong domain configuration. </p> 121 139 <p>Please double-check on your configuration in your Linguise dashboard or reach out to our support team</p>'; 122 die(); 140 141 if (defined('LINGUISE_SCRIPT_TESTING') && LINGUISE_SCRIPT_TESTING) { 142 // stop execution for testing purposes 143 return; 144 } 145 die(); // @codeCoverageIgnore 123 146 } 124 147 … … 152 175 Certificates::getInstance()->downloadCertificates(); 153 176 } 154 155 177 } -
linguise/trunk/vendor/linguise/script-php/src/Translation.php
r3388557 r3397694 97 97 } 98 98 99 curl_close($ch); 99 if (PHP_VERSION_ID < 80000) { 100 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 101 } 100 102 101 103 $result = json_decode($translated_content); … … 223 225 Debug::log('Translated content: ' . PHP_EOL . '######################' . PHP_EOL . $translated_content . PHP_EOL . '######################', 5); 224 226 225 curl_close($ch); 227 if (PHP_VERSION_ID < 80000) { 228 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 229 } 226 230 227 231 if (!$translated_content || $response_code !== 200) { -
linguise/trunk/vendor/linguise/script-php/src/Updater.php
r2652292 r3397694 57 57 } 58 58 $content = curl_exec($ch); 59 curl_close($ch); 59 if (PHP_VERSION_ID < 80000) { 60 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 61 } 60 62 61 63 if (!$content) { … … 93 95 } 94 96 $file_content = curl_exec($ch); 95 curl_close($ch); 97 if (PHP_VERSION_ID < 80000) { 98 curl_close($ch); // Since, PHP 8+ this thing actually does not do anything (deprecated in PHP 8.5) 99 } 96 100 97 101 if (!$file_content) {
Note: See TracChangeset
for help on using the changeset viewer.