Changeset 3300741
- Timestamp:
- 05/26/2025 01:16:46 PM (10 months ago)
- Location:
- auto-translator-polylang
- Files:
-
- 8 edited
- 1 copied
-
tags/1.2.0 (copied) (copied from auto-translator-polylang/trunk)
-
tags/1.2.0/assets/js/tableFilters.min.js (modified) (1 diff)
-
tags/1.2.0/auto-translator-for-polylang.php (modified) (2 diffs)
-
tags/1.2.0/includes/Base/ATFP_Translation.php (modified) (12 diffs)
-
tags/1.2.0/readme.txt (modified) (2 diffs)
-
trunk/assets/js/tableFilters.min.js (modified) (1 diff)
-
trunk/auto-translator-for-polylang.php (modified) (2 diffs)
-
trunk/includes/Base/ATFP_Translation.php (modified) (12 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
auto-translator-polylang/tags/1.2.0/assets/js/tableFilters.min.js
r3272387 r3300741 1 "use strict";function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,r){var t;if(e)return"string"==typeof e?_arrayLikeToArray(e,r):"Map"===(t="Object"===(t=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:t)||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,r):void 0}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,a=new Array(r);t<r;t++)a[t]=e[t];return a}window.addEventListener("DOMContentLoaded",function(){var i=document.querySelector("#filter");i.addEventListener("submit",function(e){e.preventDefault();var e=i.querySelector("#post-type").value,r=i.querySelector("#language").value,t=i.querySelector("#status").value,a=_toConsumableArray(i.querySelectorAll('input[name="element[]"]:checked')),n=(null==(n=i.querySelector("#bulk-action-selector-top"))?void 0:n.value)||"",o=(null==(o=i.querySelector("#search_id-search-input"))?void 0:o.value)||"",l=a.map(function(e){return"element[]="+e.value}).join("&"),u=atfp.admin_url+" /admin.php?page=auto-translated-for-polylang";e&&(u+="&post-type="+e),r&&(u+="&language="+r),t&&(u+="&status="+t),o&&(u+="&s="+o),a.length&&"-1"!==n&&(u+="&action="+n+"&"+l),window.location.href=u})});1 "use strict";function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,r){var t;if(e)return"string"==typeof e?_arrayLikeToArray(e,r):"Map"===(t="Object"===(t=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:t)||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,r):void 0}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,a=new Array(r);t<r;t++)a[t]=e[t];return a}window.addEventListener("DOMContentLoaded",function(){var i=document.querySelector("#filter");i.addEventListener("submit",function(e){e.preventDefault();var e=i.querySelector("#post-type").value,r=i.querySelector("#language").value,t=i.querySelector("#status").value,a=_toConsumableArray(i.querySelectorAll('input[name="element[]"]:checked')),n=(null==(n=i.querySelector("#bulk-action-selector-top"))?void 0:n.value)||"",o=(null==(o=i.querySelector("#search_id-search-input"))?void 0:o.value)||"",l=a.map(function(e){return"element[]="+e.value}).join("&"),u=atfp.admin_url+"admin.php?page=auto-translated-for-polylang";e&&(u+="&post-type="+e),r&&(u+="&language="+r),t&&(u+="&status="+t),o&&(u+="&s="+o),a.length&&"-1"!==n&&(u+="&action="+n+"&"+l),window.location.href=u})}); -
auto-translator-polylang/tags/1.2.0/auto-translator-for-polylang.php
r3288431 r3300741 5 5 * Plugin Name: Auto Translator for Polylang 6 6 * Description: Plugin to translate your pages and posts working with Polylang 7 * Version: 1. 1.27 * Version: 1.2.0 8 8 * Author: UAPP GROUP 9 9 * Author URI: https://uapp.group/ … … 26 26 define('ATFP_PLUGIN_NAME', trim(dirname(ATFP_PLUGIN_BASENAME), '/')); 27 27 28 const ATFP_VERSION = '1. 1.2';28 const ATFP_VERSION = '1.2.0'; 29 29 30 30 const ATFP_TEMPLATES = ATFP_PLUGIN_DIR . "/templates"; -
auto-translator-polylang/tags/1.2.0/includes/Base/ATFP_Translation.php
r3288431 r3300741 113 113 if (is_plugin_active('wordpress-seo/wp-seo.php')) { 114 114 $this->translate_yoast_fields($post_id, $new_post_id, $target_language); 115 } 116 if (is_plugin_active('all-in-one-seo-pack/all_in_one_seo_pack.php')) { 117 $this->translate_aioseo_fields($post_id, $new_post_id, $target_language); 115 118 } 116 119 } … … 259 262 ); 260 263 } 264 } 265 266 private function translate_aioseo_fields ($post_id, $new_post_id, $target_language) { 267 global $wpdb; 268 269 if (!is_numeric($post_id) || !is_numeric($new_post_id) || empty($target_language)) { 270 return; 271 } 272 273 $pref = $wpdb->prefix; 274 $table = "{$pref}aioseo_posts"; 275 276 $original_fields = $wpdb->get_row( 277 $wpdb->prepare("SELECT * FROM $table WHERE post_id = %d", $post_id), 278 ARRAY_A 279 ); 280 281 if (empty($original_fields)) { 282 return; 283 } 284 285 unset($original_fields['id']); 286 287 $original_fields['post_id'] = (int)$new_post_id; 288 289 $translatable_fields = [ 290 'title', 291 'description', 292 'og_title', 293 'og_description', 294 'twitter_title', 295 'twitter_description', 296 'facebook_title', 297 'facebook_description', 298 'seo_title', 299 ]; 300 301 $replace_placeholders = static function ($string) { 302 $pattern = '/#\w+/'; 303 $matches = []; 304 305 $callback = function ($match) use (&$matches) { 306 $matches[] = $match[0]; 307 return '@@@'; 308 }; 309 310 $safe_string = preg_replace_callback($pattern, $callback, $string); 311 return [$safe_string, $matches]; 312 }; 313 314 $restore_placeholders = static function ($string, $placeholders) { 315 $index = 0; 316 317 return preg_replace_callback('/@@@/', function () use (&$placeholders, &$index) { 318 return $placeholders[$index++] ?? '@@@'; 319 }, $string); 320 }; 321 322 foreach ($translatable_fields as $field) { 323 if (!empty($original_fields[$field])) { 324 [$safe_string, $placeholders] = $replace_placeholders($original_fields[$field]); 325 $translated = $this->translate_text($safe_string, $target_language); 326 $original_fields[$field] = $restore_placeholders($translated, $placeholders); 327 } 328 } 329 330 $wpdb->insert($table, $original_fields); 261 331 } 262 332 … … 420 490 } 421 491 422 private function get_text_from_html ($html, $target_language) {492 private function get_text_from_html ($html, $target_language) { 423 493 include_once('simplehtmldom/simple_html_dom.php'); 424 494 … … 438 508 foreach ($dom->find('p, div, span, li') as $block) { 439 509 if (!empty(trim($block->innertext))) { 440 list($text_with_placeholders, $tag_map)= $this->replace_inline_tags_with_placeholders($block->innertext);510 [$text_with_placeholders, $tag_map] = $this->replace_inline_tags_with_placeholders($block->innertext); 441 511 442 512 $translated = $this->translate_text($text_with_placeholders, $target_language); 443 513 444 514 if ($translated) { 445 $restored = $this->restore_placeholders_with_tags($translated, $tag_map);515 $restored = $this->restore_placeholders_with_tags($translated, $tag_map); 446 516 $block->innertext = $restored; 447 517 } … … 460 530 } 461 531 462 private function translate_text ($text, $targetLanguage) {463 $api_key = get_option('atfp_api_key');464 $url = 'https://translation.googleapis.com/language/translate/v2';532 private function translate_text ($text, $targetLanguage) { 533 $api_key = get_option('atfp_api_key'); 534 $url = 'https://translation.googleapis.com/language/translate/v2'; 465 535 $query_params = "?q=" . esc_html(urlencode($text)) . "&target=" . esc_html($targetLanguage) . "&format=html&key=" . esc_html($api_key); 466 536 … … 523 593 } 524 594 525 private function replace_shortcodes_with_placeholders ($content, &$shortcodes) {526 $index = 0;595 private function replace_shortcodes_with_placeholders ($content, &$shortcodes) { 596 $index = 0; 527 597 $shortcodes = []; 528 598 529 599 $content = preg_replace_callback('/\[(html_block|raw)](.*?)\[\/\1]/is', function ($matches) use (&$shortcodes, &$index) { 530 $placeholder = "<!--RAWHTML_{$index}-->";600 $placeholder = "<!--RAWHTML_{$index}-->"; 531 601 $shortcodes[$placeholder] = $matches[0]; 532 602 $index++; … … 541 611 } 542 612 543 $placeholder = "<!--SHORTCODE_{$index}-->";613 $placeholder = "<!--SHORTCODE_{$index}-->"; 544 614 $shortcodes[$placeholder] = $full_shortcode; 545 615 $index++; … … 548 618 } 549 619 550 private function restore_shortcodes_from_placeholders ($content, $shortcodes) {620 private function restore_shortcodes_from_placeholders ($content, $shortcodes) { 551 621 return str_replace(array_keys($shortcodes), array_values($shortcodes), $content); 552 622 } 553 623 554 private function replace_inline_tags_with_placeholders ($html) {624 private function replace_inline_tags_with_placeholders ($html) { 555 625 $dom = new ATFP_simple_html_dom(); 556 626 $dom->load($html); 557 627 558 $index = 0;628 $index = 0; 559 629 $tag_map = []; 560 630 … … 562 632 if (in_array($node->tag, ['a', 'strong', 'em', 'b', 'i', 'u', 'span'])) { 563 633 $placeholder_start = "[tag{$index}]"; 564 $placeholder_end = "[/tag{$index}]";634 $placeholder_end = "[/tag{$index}]"; 565 635 566 636 $tag_map["tag{$index}"] = $node->outertext; 567 $inner = $node->innertext;637 $inner = $node->innertext; 568 638 569 639 $node->outertext = $placeholder_start . $inner . $placeholder_end; … … 576 646 } 577 647 578 private function restore_placeholders_with_tags ($text, $tag_map) {648 private function restore_placeholders_with_tags ($text, $tag_map) { 579 649 foreach ($tag_map as $key => $original_html) { 580 650 if (preg_match('/^<([a-z0-9]+)([^>]*)>(.*?)<\/\1>$/is', $original_html, $parts)) { 581 651 $tag_name = $parts[1]; 582 $attrs = $parts[2];652 $attrs = $parts[2]; 583 653 584 654 $pattern = "/\\[{$key}\\](.*?)\\[\\/{$key}\\]/s"; 585 655 586 $text = preg_replace_callback($pattern, function ($match) use ($tag_name, $attrs) {656 $text = preg_replace_callback($pattern, function ($match) use ($tag_name, $attrs) { 587 657 $translated_inner = $match[1]; 588 658 return "<{$tag_name}{$attrs}>{$translated_inner}</{$tag_name}>"; … … 594 664 } 595 665 596 private function replace_br_tags_with_placeholders ($html) {666 private function replace_br_tags_with_placeholders ($html) { 597 667 $index = 0; 598 return preg_replace_callback('/<br\s*\/?>/i', function () use (&$index) {668 return preg_replace_callback('/<br\s*\/?>/i', function () use (&$index) { 599 669 $placeholder = "<!--BR_{$index}-->"; 600 670 $index++; … … 603 673 } 604 674 605 private function restore_br_tags_from_placeholders ($text) {606 return preg_replace_callback('/<!--BR_(\d+)-->/', function ($matches) {675 private function restore_br_tags_from_placeholders ($text) { 676 return preg_replace_callback('/<!--BR_(\d+)-->/', function ($matches) { 607 677 return '<br />'; 608 678 }, $text); -
auto-translator-polylang/tags/1.2.0/readme.txt
r3288431 r3300741 5 5 Requires at least: 5.8 6 6 Tested up to: 6.8.1 7 Stable tag: 1. 1.27 Stable tag: 1.2.0 8 8 License: GPLv3 9 9 License URI: https://opensource.org/licenses/GPL-3.0 … … 51 51 == Changelog == 52 52 53 = 1.2.0 = 54 - Feature: Add translation support for All in One SEO Pack plugin 55 53 56 = 1.1.2 = 54 57 - Fix: Fixed inline tags handling -
auto-translator-polylang/trunk/assets/js/tableFilters.min.js
r3272387 r3300741 1 "use strict";function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,r){var t;if(e)return"string"==typeof e?_arrayLikeToArray(e,r):"Map"===(t="Object"===(t=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:t)||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,r):void 0}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,a=new Array(r);t<r;t++)a[t]=e[t];return a}window.addEventListener("DOMContentLoaded",function(){var i=document.querySelector("#filter");i.addEventListener("submit",function(e){e.preventDefault();var e=i.querySelector("#post-type").value,r=i.querySelector("#language").value,t=i.querySelector("#status").value,a=_toConsumableArray(i.querySelectorAll('input[name="element[]"]:checked')),n=(null==(n=i.querySelector("#bulk-action-selector-top"))?void 0:n.value)||"",o=(null==(o=i.querySelector("#search_id-search-input"))?void 0:o.value)||"",l=a.map(function(e){return"element[]="+e.value}).join("&"),u=atfp.admin_url+" /admin.php?page=auto-translated-for-polylang";e&&(u+="&post-type="+e),r&&(u+="&language="+r),t&&(u+="&status="+t),o&&(u+="&s="+o),a.length&&"-1"!==n&&(u+="&action="+n+"&"+l),window.location.href=u})});1 "use strict";function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,r){var t;if(e)return"string"==typeof e?_arrayLikeToArray(e,r):"Map"===(t="Object"===(t=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:t)||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,r):void 0}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,a=new Array(r);t<r;t++)a[t]=e[t];return a}window.addEventListener("DOMContentLoaded",function(){var i=document.querySelector("#filter");i.addEventListener("submit",function(e){e.preventDefault();var e=i.querySelector("#post-type").value,r=i.querySelector("#language").value,t=i.querySelector("#status").value,a=_toConsumableArray(i.querySelectorAll('input[name="element[]"]:checked')),n=(null==(n=i.querySelector("#bulk-action-selector-top"))?void 0:n.value)||"",o=(null==(o=i.querySelector("#search_id-search-input"))?void 0:o.value)||"",l=a.map(function(e){return"element[]="+e.value}).join("&"),u=atfp.admin_url+"admin.php?page=auto-translated-for-polylang";e&&(u+="&post-type="+e),r&&(u+="&language="+r),t&&(u+="&status="+t),o&&(u+="&s="+o),a.length&&"-1"!==n&&(u+="&action="+n+"&"+l),window.location.href=u})}); -
auto-translator-polylang/trunk/auto-translator-for-polylang.php
r3288431 r3300741 5 5 * Plugin Name: Auto Translator for Polylang 6 6 * Description: Plugin to translate your pages and posts working with Polylang 7 * Version: 1. 1.27 * Version: 1.2.0 8 8 * Author: UAPP GROUP 9 9 * Author URI: https://uapp.group/ … … 26 26 define('ATFP_PLUGIN_NAME', trim(dirname(ATFP_PLUGIN_BASENAME), '/')); 27 27 28 const ATFP_VERSION = '1. 1.2';28 const ATFP_VERSION = '1.2.0'; 29 29 30 30 const ATFP_TEMPLATES = ATFP_PLUGIN_DIR . "/templates"; -
auto-translator-polylang/trunk/includes/Base/ATFP_Translation.php
r3288431 r3300741 113 113 if (is_plugin_active('wordpress-seo/wp-seo.php')) { 114 114 $this->translate_yoast_fields($post_id, $new_post_id, $target_language); 115 } 116 if (is_plugin_active('all-in-one-seo-pack/all_in_one_seo_pack.php')) { 117 $this->translate_aioseo_fields($post_id, $new_post_id, $target_language); 115 118 } 116 119 } … … 259 262 ); 260 263 } 264 } 265 266 private function translate_aioseo_fields ($post_id, $new_post_id, $target_language) { 267 global $wpdb; 268 269 if (!is_numeric($post_id) || !is_numeric($new_post_id) || empty($target_language)) { 270 return; 271 } 272 273 $pref = $wpdb->prefix; 274 $table = "{$pref}aioseo_posts"; 275 276 $original_fields = $wpdb->get_row( 277 $wpdb->prepare("SELECT * FROM $table WHERE post_id = %d", $post_id), 278 ARRAY_A 279 ); 280 281 if (empty($original_fields)) { 282 return; 283 } 284 285 unset($original_fields['id']); 286 287 $original_fields['post_id'] = (int)$new_post_id; 288 289 $translatable_fields = [ 290 'title', 291 'description', 292 'og_title', 293 'og_description', 294 'twitter_title', 295 'twitter_description', 296 'facebook_title', 297 'facebook_description', 298 'seo_title', 299 ]; 300 301 $replace_placeholders = static function ($string) { 302 $pattern = '/#\w+/'; 303 $matches = []; 304 305 $callback = function ($match) use (&$matches) { 306 $matches[] = $match[0]; 307 return '@@@'; 308 }; 309 310 $safe_string = preg_replace_callback($pattern, $callback, $string); 311 return [$safe_string, $matches]; 312 }; 313 314 $restore_placeholders = static function ($string, $placeholders) { 315 $index = 0; 316 317 return preg_replace_callback('/@@@/', function () use (&$placeholders, &$index) { 318 return $placeholders[$index++] ?? '@@@'; 319 }, $string); 320 }; 321 322 foreach ($translatable_fields as $field) { 323 if (!empty($original_fields[$field])) { 324 [$safe_string, $placeholders] = $replace_placeholders($original_fields[$field]); 325 $translated = $this->translate_text($safe_string, $target_language); 326 $original_fields[$field] = $restore_placeholders($translated, $placeholders); 327 } 328 } 329 330 $wpdb->insert($table, $original_fields); 261 331 } 262 332 … … 420 490 } 421 491 422 private function get_text_from_html ($html, $target_language) {492 private function get_text_from_html ($html, $target_language) { 423 493 include_once('simplehtmldom/simple_html_dom.php'); 424 494 … … 438 508 foreach ($dom->find('p, div, span, li') as $block) { 439 509 if (!empty(trim($block->innertext))) { 440 list($text_with_placeholders, $tag_map)= $this->replace_inline_tags_with_placeholders($block->innertext);510 [$text_with_placeholders, $tag_map] = $this->replace_inline_tags_with_placeholders($block->innertext); 441 511 442 512 $translated = $this->translate_text($text_with_placeholders, $target_language); 443 513 444 514 if ($translated) { 445 $restored = $this->restore_placeholders_with_tags($translated, $tag_map);515 $restored = $this->restore_placeholders_with_tags($translated, $tag_map); 446 516 $block->innertext = $restored; 447 517 } … … 460 530 } 461 531 462 private function translate_text ($text, $targetLanguage) {463 $api_key = get_option('atfp_api_key');464 $url = 'https://translation.googleapis.com/language/translate/v2';532 private function translate_text ($text, $targetLanguage) { 533 $api_key = get_option('atfp_api_key'); 534 $url = 'https://translation.googleapis.com/language/translate/v2'; 465 535 $query_params = "?q=" . esc_html(urlencode($text)) . "&target=" . esc_html($targetLanguage) . "&format=html&key=" . esc_html($api_key); 466 536 … … 523 593 } 524 594 525 private function replace_shortcodes_with_placeholders ($content, &$shortcodes) {526 $index = 0;595 private function replace_shortcodes_with_placeholders ($content, &$shortcodes) { 596 $index = 0; 527 597 $shortcodes = []; 528 598 529 599 $content = preg_replace_callback('/\[(html_block|raw)](.*?)\[\/\1]/is', function ($matches) use (&$shortcodes, &$index) { 530 $placeholder = "<!--RAWHTML_{$index}-->";600 $placeholder = "<!--RAWHTML_{$index}-->"; 531 601 $shortcodes[$placeholder] = $matches[0]; 532 602 $index++; … … 541 611 } 542 612 543 $placeholder = "<!--SHORTCODE_{$index}-->";613 $placeholder = "<!--SHORTCODE_{$index}-->"; 544 614 $shortcodes[$placeholder] = $full_shortcode; 545 615 $index++; … … 548 618 } 549 619 550 private function restore_shortcodes_from_placeholders ($content, $shortcodes) {620 private function restore_shortcodes_from_placeholders ($content, $shortcodes) { 551 621 return str_replace(array_keys($shortcodes), array_values($shortcodes), $content); 552 622 } 553 623 554 private function replace_inline_tags_with_placeholders ($html) {624 private function replace_inline_tags_with_placeholders ($html) { 555 625 $dom = new ATFP_simple_html_dom(); 556 626 $dom->load($html); 557 627 558 $index = 0;628 $index = 0; 559 629 $tag_map = []; 560 630 … … 562 632 if (in_array($node->tag, ['a', 'strong', 'em', 'b', 'i', 'u', 'span'])) { 563 633 $placeholder_start = "[tag{$index}]"; 564 $placeholder_end = "[/tag{$index}]";634 $placeholder_end = "[/tag{$index}]"; 565 635 566 636 $tag_map["tag{$index}"] = $node->outertext; 567 $inner = $node->innertext;637 $inner = $node->innertext; 568 638 569 639 $node->outertext = $placeholder_start . $inner . $placeholder_end; … … 576 646 } 577 647 578 private function restore_placeholders_with_tags ($text, $tag_map) {648 private function restore_placeholders_with_tags ($text, $tag_map) { 579 649 foreach ($tag_map as $key => $original_html) { 580 650 if (preg_match('/^<([a-z0-9]+)([^>]*)>(.*?)<\/\1>$/is', $original_html, $parts)) { 581 651 $tag_name = $parts[1]; 582 $attrs = $parts[2];652 $attrs = $parts[2]; 583 653 584 654 $pattern = "/\\[{$key}\\](.*?)\\[\\/{$key}\\]/s"; 585 655 586 $text = preg_replace_callback($pattern, function ($match) use ($tag_name, $attrs) {656 $text = preg_replace_callback($pattern, function ($match) use ($tag_name, $attrs) { 587 657 $translated_inner = $match[1]; 588 658 return "<{$tag_name}{$attrs}>{$translated_inner}</{$tag_name}>"; … … 594 664 } 595 665 596 private function replace_br_tags_with_placeholders ($html) {666 private function replace_br_tags_with_placeholders ($html) { 597 667 $index = 0; 598 return preg_replace_callback('/<br\s*\/?>/i', function () use (&$index) {668 return preg_replace_callback('/<br\s*\/?>/i', function () use (&$index) { 599 669 $placeholder = "<!--BR_{$index}-->"; 600 670 $index++; … … 603 673 } 604 674 605 private function restore_br_tags_from_placeholders ($text) {606 return preg_replace_callback('/<!--BR_(\d+)-->/', function ($matches) {675 private function restore_br_tags_from_placeholders ($text) { 676 return preg_replace_callback('/<!--BR_(\d+)-->/', function ($matches) { 607 677 return '<br />'; 608 678 }, $text); -
auto-translator-polylang/trunk/readme.txt
r3288431 r3300741 5 5 Requires at least: 5.8 6 6 Tested up to: 6.8.1 7 Stable tag: 1. 1.27 Stable tag: 1.2.0 8 8 License: GPLv3 9 9 License URI: https://opensource.org/licenses/GPL-3.0 … … 51 51 == Changelog == 52 52 53 = 1.2.0 = 54 - Feature: Add translation support for All in One SEO Pack plugin 55 53 56 = 1.1.2 = 54 57 - Fix: Fixed inline tags handling
Note: See TracChangeset
for help on using the changeset viewer.