Changeset 3272387
- Timestamp:
- 04/14/2025 12:25:05 PM (11 months ago)
- Location:
- auto-translator-polylang
- Files:
-
- 12 edited
- 1 copied
-
tags/1.1.0 (copied) (copied from auto-translator-polylang/trunk)
-
tags/1.1.0/assets/js/tableFilters.min.js (modified) (1 diff)
-
tags/1.1.0/auto-translator-for-polylang.php (modified) (2 diffs)
-
tags/1.1.0/includes/Api/Callbacks/ATFP_SettingsPageCallbacks.php (modified) (1 diff)
-
tags/1.1.0/includes/Api/Settings/ATFP_SettingsPageSettings.php (modified) (2 diffs)
-
tags/1.1.0/includes/Base/ATFP_Translation.php (modified) (4 diffs)
-
tags/1.1.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/Api/Callbacks/ATFP_SettingsPageCallbacks.php (modified) (1 diff)
-
trunk/includes/Api/Settings/ATFP_SettingsPageSettings.php (modified) (2 diffs)
-
trunk/includes/Base/ATFP_Translation.php (modified) (4 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
auto-translator-polylang/tags/1.1.0/assets/js/tableFilters.min.js
r3269769 r3272387 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";console.log(atfp.admin_url),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.1.0/auto-translator-for-polylang.php
r3269769 r3272387 5 5 * Plugin Name: Auto Translator for Polylang 6 6 * Description: Plugin to translate your pages and posts working with Polylang 7 * Version: 1. 0.67 * Version: 1.1.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. 0.6';28 const ATFP_VERSION = '1.1.0'; 29 29 30 30 const ATFP_TEMPLATES = ATFP_PLUGIN_DIR . "/templates"; -
auto-translator-polylang/tags/1.1.0/includes/Api/Callbacks/ATFP_SettingsPageCallbacks.php
r3115417 r3272387 7 7 8 8 9 if (!defined('ABSPATH')) {10 exit; // Don't access directly.9 if (!defined('ABSPATH')) { 10 exit; // Don't access directly. 11 11 } 12 12 13 13 class ATFP_SettingsPageCallbacks implements ATFP_Callbacks { 14 public static function pageOptionGroup($input) {15 return $input;16 }14 public static function pageOptionGroup ($input) { 15 return $input; 16 } 17 17 18 public static function pageSection() {19 }18 public static function pageSection () { 19 } 20 20 21 public static function pageField($options) {22 $output = '';21 public static function pageField($options) { 22 $output = ''; 23 23 24 if($options['type']== 'textarea') {25 $output .= "<textarea ";26 } else {27 $output .= "<input ";28 $output .= "type='{$options['type']}' ";29 }24 if ($options['type'] === 'textarea') { 25 $output .= "<textarea "; 26 } else { 27 $output .= "<input "; 28 $output .= "type='{$options['type']}' "; 29 } 30 30 31 if($options['name'] != '') {32 $output .= "name='{$options['name']}' ";33 }31 if (!empty($options['name'])) { 32 $output .= "name='{$options['name']}' "; 33 } 34 34 35 if($options['id'] != '') {36 $output .= "id='{$options['id']}' ";37 }35 if (!empty($options['id'])) { 36 $output .= "id='{$options['id']}' "; 37 } 38 38 39 if($options['class']) {40 $output .= "class='{$options['class']}' ";41 }39 if (!empty($options['class'])) { 40 $output .= "class='{$options['class']}' "; 41 } 42 42 43 if($options['placeholder']) {44 $output .= "placeholder='{$options['placeholder']}' ";45 }43 if (!empty($options['placeholder'])) { 44 $output .= "placeholder='{$options['placeholder']}' "; 45 } 46 46 47 if($options['value']) { 48 $output .= "value='{$options['value']}' "; 49 } 47 if ($options['type'] === 'checkbox') { 48 $option_value = get_option($options['name']); 49 if ($option_value === 'on') { 50 $output .= "checked "; 51 } 52 $output .= "value='on' "; 53 } else { 54 if (isset($options['value'])) { 55 $output .= "value='{$options['value']}' "; 56 } 57 } 50 58 51 if($options['type']== 'textarea') {52 $output .= "></textarea>";53 } else {54 $output .= "> ";55 }; 59 if ($options['type'] === 'textarea') { 60 $output .= "></textarea>"; 61 } else { 62 $output .= "/> "; 63 } 56 64 57 echo wp_kses($output, [ 58 'input' => [ 59 'type' => true, 60 'name' => true, 61 'value' => true, 62 'placeholder' => true, 63 'class' => true, 64 'id' => true, 65 ], 66 'textarea' => [ 67 'type' => true, 68 'name' => true, 69 'value' => true, 70 'placeholder' => true, 71 'class' => true, 72 'id' => true, 73 ], 74 ]); 75 } 65 echo wp_kses($output, [ 66 'input' => [ 67 'type' => true, 68 'name' => true, 69 'value' => true, 70 'placeholder' => true, 71 'class' => true, 72 'id' => true, 73 'checked' => true, 74 ], 75 'textarea' => [ 76 'type' => true, 77 'name' => true, 78 'value' => true, 79 'placeholder' => true, 80 'class' => true, 81 'id' => true, 82 ], 83 ]); 84 } 76 85 } -
auto-translator-polylang/tags/1.1.0/includes/Api/Settings/ATFP_SettingsPageSettings.php
r3115417 r3272387 21 21 'args' => '', 22 22 ], 23 [ 24 'option_group' => 'pl_option_group', 25 'option_name' => 'atfp_translate_shortcodes', 26 'args' => '', 27 ] 23 28 ]; 24 29 … … 46 51 'label_for' => 'atfp_api_key', 47 52 'class' => 'regular-text', 48 'value' => get_option( "atfp_api_key") ?? "",49 'placeholder' => "Enter your API key",53 'value' => get_option('atfp_api_key') ?? '', 54 'placeholder' => 'Enter your API key', 50 55 ], 51 56 ], 57 [ 58 'id' => 'translate_shortcodes', 59 'title' => esc_html__('Translate shortcodes', 'auto-translator-polylang'), 60 'callback' => [ATFP_SettingsPageCallbacks::class, 'pageField'], 61 'page' => 'auto-translator-for-polylang', 62 'section' => 'pl_admin_section', 63 'args' => [ 64 'type' => 'checkbox', 65 'name' => 'atfp_translate_shortcodes', 66 'id' => 'atfp_translate_shortcodes', 67 'label_for' => 'atfp_translate_shortcodes', 68 'class' => 'regular-text', 69 'value' => get_option('atfp_translate_shortcodes'), 70 ], 71 ] 52 72 ]; 53 73 } -
auto-translator-polylang/tags/1.1.0/includes/Base/ATFP_Translation.php
r3115417 r3272387 402 402 } 403 403 404 405 404 public function add_custom_select_to_posts_page () { 406 405 $languages = pll_the_languages([ … … 421 420 } 422 421 423 private function get_text_from_html ($html, $target_language) {422 private function get_text_from_html($html, $target_language) { 424 423 include_once('simplehtmldom/simple_html_dom.php'); 424 425 $translate_shortcodes = get_option('atfp_translate_shortcodes') === 'on'; 426 427 $shortcodes = []; 428 429 if (!$translate_shortcodes) { 430 $html = $this->replace_shortcodes_with_placeholders($html, $shortcodes); 431 } 432 425 433 $dom = new ATFP_simple_html_dom(); 426 434 $dom->load(wp_kses_post($html)); … … 439 447 } 440 448 441 return $dom->save(); 449 $translated_html = $dom->save(); 450 451 if (!$translate_shortcodes) { 452 $translated_html = $this->restore_shortcodes_from_placeholders($translated_html, $shortcodes); 453 } 454 455 return $translated_html; 442 456 } 443 457 … … 505 519 } 506 520 521 private function replace_shortcodes_with_placeholders ($content, &$shortcodes) { 522 $index = 0; 523 $shortcodes = []; 524 525 return preg_replace_callback('/\[(\[?)([^\[\]]+)(\]?)\]/', function ($matches) use (&$shortcodes, &$index) { 526 $placeholder = '<!--SHORTCODE_' . $index . '-->'; 527 $shortcodes[$placeholder] = $matches[0]; // Store original shortcode 528 $index++; 529 return $placeholder; 530 }, $content); 531 } 532 533 private function restore_shortcodes_from_placeholders($content, $shortcodes) { 534 return str_replace(array_keys($shortcodes), array_values($shortcodes), $content); 535 } 536 507 537 public function add_bulk_action ($bulk_actions) { 508 538 $bulk_actions['translate'] = 'Translate'; -
auto-translator-polylang/tags/1.1.0/readme.txt
r3269769 r3272387 5 5 Requires at least: 5.8 6 6 Tested up to: 6.7.2 7 Stable tag: 1. 0.67 Stable tag: 1.1.0 8 8 License: GPLv3 9 9 License URI: https://opensource.org/licenses/GPL-3.0 … … 51 51 == Changelog == 52 52 53 = 1.1.0 = 54 - Feature: add shortcode translation option 55 53 56 = 1.0.6 = 54 57 - Fix: Add activation check for PRO version -
auto-translator-polylang/trunk/assets/js/tableFilters.min.js
r3269769 r3272387 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";console.log(atfp.admin_url),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
r3269769 r3272387 5 5 * Plugin Name: Auto Translator for Polylang 6 6 * Description: Plugin to translate your pages and posts working with Polylang 7 * Version: 1. 0.67 * Version: 1.1.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. 0.6';28 const ATFP_VERSION = '1.1.0'; 29 29 30 30 const ATFP_TEMPLATES = ATFP_PLUGIN_DIR . "/templates"; -
auto-translator-polylang/trunk/includes/Api/Callbacks/ATFP_SettingsPageCallbacks.php
r3115417 r3272387 7 7 8 8 9 if (!defined('ABSPATH')) {10 exit; // Don't access directly.9 if (!defined('ABSPATH')) { 10 exit; // Don't access directly. 11 11 } 12 12 13 13 class ATFP_SettingsPageCallbacks implements ATFP_Callbacks { 14 public static function pageOptionGroup($input) {15 return $input;16 }14 public static function pageOptionGroup ($input) { 15 return $input; 16 } 17 17 18 public static function pageSection() {19 }18 public static function pageSection () { 19 } 20 20 21 public static function pageField($options) {22 $output = '';21 public static function pageField($options) { 22 $output = ''; 23 23 24 if($options['type']== 'textarea') {25 $output .= "<textarea ";26 } else {27 $output .= "<input ";28 $output .= "type='{$options['type']}' ";29 }24 if ($options['type'] === 'textarea') { 25 $output .= "<textarea "; 26 } else { 27 $output .= "<input "; 28 $output .= "type='{$options['type']}' "; 29 } 30 30 31 if($options['name'] != '') {32 $output .= "name='{$options['name']}' ";33 }31 if (!empty($options['name'])) { 32 $output .= "name='{$options['name']}' "; 33 } 34 34 35 if($options['id'] != '') {36 $output .= "id='{$options['id']}' ";37 }35 if (!empty($options['id'])) { 36 $output .= "id='{$options['id']}' "; 37 } 38 38 39 if($options['class']) {40 $output .= "class='{$options['class']}' ";41 }39 if (!empty($options['class'])) { 40 $output .= "class='{$options['class']}' "; 41 } 42 42 43 if($options['placeholder']) {44 $output .= "placeholder='{$options['placeholder']}' ";45 }43 if (!empty($options['placeholder'])) { 44 $output .= "placeholder='{$options['placeholder']}' "; 45 } 46 46 47 if($options['value']) { 48 $output .= "value='{$options['value']}' "; 49 } 47 if ($options['type'] === 'checkbox') { 48 $option_value = get_option($options['name']); 49 if ($option_value === 'on') { 50 $output .= "checked "; 51 } 52 $output .= "value='on' "; 53 } else { 54 if (isset($options['value'])) { 55 $output .= "value='{$options['value']}' "; 56 } 57 } 50 58 51 if($options['type']== 'textarea') {52 $output .= "></textarea>";53 } else {54 $output .= "> ";55 }; 59 if ($options['type'] === 'textarea') { 60 $output .= "></textarea>"; 61 } else { 62 $output .= "/> "; 63 } 56 64 57 echo wp_kses($output, [ 58 'input' => [ 59 'type' => true, 60 'name' => true, 61 'value' => true, 62 'placeholder' => true, 63 'class' => true, 64 'id' => true, 65 ], 66 'textarea' => [ 67 'type' => true, 68 'name' => true, 69 'value' => true, 70 'placeholder' => true, 71 'class' => true, 72 'id' => true, 73 ], 74 ]); 75 } 65 echo wp_kses($output, [ 66 'input' => [ 67 'type' => true, 68 'name' => true, 69 'value' => true, 70 'placeholder' => true, 71 'class' => true, 72 'id' => true, 73 'checked' => true, 74 ], 75 'textarea' => [ 76 'type' => true, 77 'name' => true, 78 'value' => true, 79 'placeholder' => true, 80 'class' => true, 81 'id' => true, 82 ], 83 ]); 84 } 76 85 } -
auto-translator-polylang/trunk/includes/Api/Settings/ATFP_SettingsPageSettings.php
r3115417 r3272387 21 21 'args' => '', 22 22 ], 23 [ 24 'option_group' => 'pl_option_group', 25 'option_name' => 'atfp_translate_shortcodes', 26 'args' => '', 27 ] 23 28 ]; 24 29 … … 46 51 'label_for' => 'atfp_api_key', 47 52 'class' => 'regular-text', 48 'value' => get_option( "atfp_api_key") ?? "",49 'placeholder' => "Enter your API key",53 'value' => get_option('atfp_api_key') ?? '', 54 'placeholder' => 'Enter your API key', 50 55 ], 51 56 ], 57 [ 58 'id' => 'translate_shortcodes', 59 'title' => esc_html__('Translate shortcodes', 'auto-translator-polylang'), 60 'callback' => [ATFP_SettingsPageCallbacks::class, 'pageField'], 61 'page' => 'auto-translator-for-polylang', 62 'section' => 'pl_admin_section', 63 'args' => [ 64 'type' => 'checkbox', 65 'name' => 'atfp_translate_shortcodes', 66 'id' => 'atfp_translate_shortcodes', 67 'label_for' => 'atfp_translate_shortcodes', 68 'class' => 'regular-text', 69 'value' => get_option('atfp_translate_shortcodes'), 70 ], 71 ] 52 72 ]; 53 73 } -
auto-translator-polylang/trunk/includes/Base/ATFP_Translation.php
r3115417 r3272387 402 402 } 403 403 404 405 404 public function add_custom_select_to_posts_page () { 406 405 $languages = pll_the_languages([ … … 421 420 } 422 421 423 private function get_text_from_html ($html, $target_language) {422 private function get_text_from_html($html, $target_language) { 424 423 include_once('simplehtmldom/simple_html_dom.php'); 424 425 $translate_shortcodes = get_option('atfp_translate_shortcodes') === 'on'; 426 427 $shortcodes = []; 428 429 if (!$translate_shortcodes) { 430 $html = $this->replace_shortcodes_with_placeholders($html, $shortcodes); 431 } 432 425 433 $dom = new ATFP_simple_html_dom(); 426 434 $dom->load(wp_kses_post($html)); … … 439 447 } 440 448 441 return $dom->save(); 449 $translated_html = $dom->save(); 450 451 if (!$translate_shortcodes) { 452 $translated_html = $this->restore_shortcodes_from_placeholders($translated_html, $shortcodes); 453 } 454 455 return $translated_html; 442 456 } 443 457 … … 505 519 } 506 520 521 private function replace_shortcodes_with_placeholders ($content, &$shortcodes) { 522 $index = 0; 523 $shortcodes = []; 524 525 return preg_replace_callback('/\[(\[?)([^\[\]]+)(\]?)\]/', function ($matches) use (&$shortcodes, &$index) { 526 $placeholder = '<!--SHORTCODE_' . $index . '-->'; 527 $shortcodes[$placeholder] = $matches[0]; // Store original shortcode 528 $index++; 529 return $placeholder; 530 }, $content); 531 } 532 533 private function restore_shortcodes_from_placeholders($content, $shortcodes) { 534 return str_replace(array_keys($shortcodes), array_values($shortcodes), $content); 535 } 536 507 537 public function add_bulk_action ($bulk_actions) { 508 538 $bulk_actions['translate'] = 'Translate'; -
auto-translator-polylang/trunk/readme.txt
r3269769 r3272387 5 5 Requires at least: 5.8 6 6 Tested up to: 6.7.2 7 Stable tag: 1. 0.67 Stable tag: 1.1.0 8 8 License: GPLv3 9 9 License URI: https://opensource.org/licenses/GPL-3.0 … … 51 51 == Changelog == 52 52 53 = 1.1.0 = 54 - Feature: add shortcode translation option 55 53 56 = 1.0.6 = 54 57 - Fix: Add activation check for PRO version
Note: See TracChangeset
for help on using the changeset viewer.