Changeset 3148988
- Timestamp:
- 09/10/2024 05:07:54 AM (7 months ago)
- Location:
- fluentc-translation
- Files:
-
- 365 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
fluentc-translation/trunk/bootstrap.php
r3135855 r3148988 62 62 'FluentC\Actions\Wordpress', 63 63 'FluentC\Actions\Admin', 64 'FluentC\Actions\Siteorigin', 64 65 'FluentC\Actions\Translationstatus', 65 66 ); -
fluentc-translation/trunk/fluentc_settings.php
r3135855 r3148988 30 30 <p><?php _e( 'To use FluentC, you need an active subscription.', 'fluentc-translation' ); ?></p> 31 31 <?php if ( $this->fluentc_get_settings() ) { ?> 32 <a href="https://dashboard.fluentc.ai/manage/<?php echo esc_attr( $this->fluentc_get_settings() ); ?>?redirect=<?php echo esc_url( admin_url( 'admin.php?page=fluentc-settings' ) ); ?>" class="button button-primary"><?php _e( 'Manage FluentC Account and Languages', 'fluentc-translation' ); ?></a>32 <a href="https://dashboard.fluentc.ai/manage/<?php echo esc_attr( $this->fluentc_get_settings() ); ?>?redirect=<?php echo esc_url( admin_url( 'admin.php?page=fluentc-settings' ) ); ?>" class="button button-primary"><?php _e( 'Manage FluentC Account and Add Languages', 'fluentc-translation' ); ?></a> 33 33 <?php } else { ?> 34 34 <a href="https://dashboard.fluentc.ai/sites?instruction=connect&redirect=<?php echo esc_url( admin_url( 'admin.php?page=fluentc-settings' ) ); ?>" class="button button-primary"><?php _e( 'Sign Up and Connect to FluentC', 'fluentc-translation' ); ?></a> … … 44 44 <div id="tab-2" class="tab-content"> 45 45 <?php do_action( 'fluentc_admin_settings_page' ); ?> 46 <div class="fluentc-header-button"> 47 <?php if ( $this->fluentc_get_settings() ) { ?> 48 <a href="https://dashboard.fluentc.ai/manage/<?php echo esc_attr( $this->fluentc_get_settings() ); ?>?redirect=<?php echo esc_url( admin_url( 'admin.php?page=fluentc-settings' ) ); ?>" class="button button-primary"><?php _e( 'Add Languages in FluentC Dashboard', 'fluentc-translation' ); ?></a> 49 <?php } else { ?> 50 <a href="https://dashboard.fluentc.ai/sites?instruction=connect&redirect=<?php echo esc_url( admin_url( 'admin.php?page=fluentc-settings' ) ); ?>" class="button button-primary"><?php _e( 'Add Languages in FluentC Dashboard', 'fluentc-translation' ); ?></a> 51 <?php } ?> 52 </div> 46 53 </div> 47 54 -
fluentc-translation/trunk/fluentc_wordpress_plugin.php
r3148368 r3148988 7 7 * Plugin URI: https://github.com/fluentc/wordpress-plugin 8 8 * Description: A plugin that enables website owners to easily install the FluentC Translation on their WordPress site. 9 * Version: 1. 7.49 * Version: 1.8 10 10 * Author: FluentC 11 11 * Author URI: https://www.fluentc.ai … … 17 17 define( 'FLUENTC_DIR', __DIR__ ); 18 18 define( 'FLUENTC_SLUG', 'fluentc_translation' ); 19 define( 'FLUENTC_TRANSLATION_VERSION', "1. 7.4" );19 define( 'FLUENTC_TRANSLATION_VERSION', "1.8" ); 20 20 define( 'FLUENTC_TRANSLATION_PLUGIN_DIR', plugin_dir_path(__FILE__) ); 21 21 define( 'FLUENTC_TRANSLATION_PLUGIN_URL', plugin_dir_url(__FILE__) ); -
fluentc-translation/trunk/readme.txt
r3148368 r3148988 5 5 Requires at least: 4.6 6 6 Tested up to: 6.6.1 7 Stable tag: 1. 7.47 Stable tag: 1.8 8 8 Requires PHP: 7.3 9 9 License: GPLv2 or later -
fluentc-translation/trunk/src/actions/class-admin.php
r3135855 r3148988 116 116 */ 117 117 public function fluentc_sub_menu() { 118 add_submenu_page('fluentc-settings', ' Manage Translations', 'ManageTranslations', 'manage_options', 'fluentc-manage-translations', array($this->translations, 'display_translations_page'));118 add_submenu_page('fluentc-settings', 'Edit Translations', 'Edit Translations', 'manage_options', 'fluentc-manage-translations', array($this->translations, 'display_translations_page')); 119 119 } 120 120 … … 136 136 $this->fluentc_cache->clean(); 137 137 wp_safe_redirect( admin_url( 'admin.php?page=fluentc-settings' ) ); 138 exit; 138 139 } 139 140 } … … 169 170 try { 170 171 $this->fluentc_cache->clean(); 172 do_action( 'fluentc_admin_clean_cache' ); 171 173 wp_safe_redirect( admin_url( 'admin.php?page=fluentc-settings' ) ); 172 do_action( 'fluentc_admin_clean_cache' );173 174 exit; 174 175 } catch ( \Exception $e ) { … … 368 369 if ( $languages ) { 369 370 wp_safe_redirect( admin_url( 'admin.php?page=fluentc-settings' ) ); 371 exit; 370 372 } else { 371 373 echo esc_html( '<strong>Widget has no languages setup, please visit FluentC and enable a language to translate</strong>' ); -
fluentc-translation/trunk/src/actions/class-translationstatus.php
r3135855 r3148988 65 65 */ 66 66 public function hooks() { 67 add_action('admin_menu', [$this, 'addTranslationStatusSubMenu']);67 //add_action('admin_menu', [$this, 'addTranslationStatusSubMenu']); 68 68 add_action('admin_enqueue_scripts', [$this, 'enqueueAssets']); 69 69 add_action('wp_ajax_fluentc_scan_site', [$this, 'ajaxScanSite']); -
fluentc-translation/trunk/src/actions/class-wordpress.php
r3147335 r3148988 162 162 $entry_skip_map = []; 163 163 164 $elements = $dom->find('*:not(script):not(style):not( code):not(figure):not(pre):not(noscript):not(iframe):not(object):not(embed):not(svg):not(math):not(canvas)');164 $elements = $dom->find('*:not(script):not(style):not(doctype):not(code):not(figure):not(pre):not(noscript):not(iframe):not(object):not(embed):not(svg):not(math):not(canvas)'); 165 165 foreach ($elements as $element) { 166 166 $nodes = ($element instanceof \PHPHtmlParser\Dom\Node\HtmlNode) ? $element->getChildren() : [$element]; … … 270 270 return; 271 271 } 272 if ( in_array($text, $this->fluentc_htmltags->forbidden_selectors) ) { 273 // Skip or delete the DOCTYPE node 274 $node->setText(''); 275 return; 276 } 272 277 273 278 $key = hash('md5', $text); … … 340 345 $entry_skip_map = []; 341 346 342 $elements = $dom->find('*:not(script):not(style):not(code):not( figure):not(pre):not(noscript):not(iframe):not(object):not(embed):not(svg):not(math):not(canvas)');347 $elements = $dom->find('*:not(script):not(style):not(code):not(doctype):not(figure):not(pre):not(noscript):not(iframe):not(object):not(embed):not(svg):not(math):not(canvas)'); 343 348 foreach ($elements as $element) { 344 349 $nodes = ($element instanceof \PHPHtmlParser\Dom\Node\HtmlNode) ? $element->getChildren() : [$element]; … … 482 487 $widgetapikey = get_option( 'fluentc_api_key' ); 483 488 484 if ( $language_code ) { 485 // If language code is set, modify the output accordingly. 486 $html = $this->fluentc_connenct->get_translation_content( $widgetapikey, $this->site_language, $language_code, $text ); 487 return $this->fluentc_html->find_and_replace( $text, $html, $language_code, $this->fluentc_connenct->get_language_list_string( $widgetapikey ) ); 489 if ( !$widgetapikey ) { 490 return $text; 491 } 492 493 if (!$language_code || is_null($text) || $text === '') { 494 return $text; 495 } 496 497 if ( function_exists( 'wc_get_page_id' ) ) { 498 if ( is_page( wc_get_page_id( 'checkout' ) ) || is_page( wc_get_page_id( 'cart' ) ) ) { 499 return $text; 500 } 501 } 502 503 $html = html_entity_decode($text, ENT_QUOTES | ENT_XML1, 'UTF-8'); 504 505 if (empty($html)) { 506 return $text; 507 } 508 509 $options = new Options(); 510 $options->setCleanupInput(false); 511 $options->setWhitespaceTextNode(false); 512 513 $dom = new Dom; 514 $dom->loadStr($html, $options); 515 516 $texts_to_translate = []; 517 $entry_map = []; 518 $entry_skip_map = []; 519 520 $elements = $dom->find('*:not(script):not(style):not(code):not(doctype):not(figure):not(pre):not(noscript):not(iframe):not(object):not(embed):not(svg):not(math):not(canvas)'); 521 foreach ($elements as $element) { 522 $nodes = ($element instanceof \PHPHtmlParser\Dom\Node\HtmlNode) ? $element->getChildren() : [$element]; 523 foreach ($nodes as $node) { 524 $this->processNode($node, $texts_to_translate, $entry_map, $entry_skip_map); 525 } 526 } 527 528 if (!empty($texts_to_translate)) { 529 $uncached_texts = []; 530 $cached_translations = []; 531 532 foreach ($texts_to_translate as $node_text) { 533 $key = hash('md5', $node_text); 534 $cache_key = $this->site_language . $language_code . $key; 535 $cached_translation = $this->fluentc_cache->get($cache_key); 536 537 if ($cached_translation) { 538 $json_cache = json_decode($cached_translation); 539 if (isset($json_cache->data->translateSite->body)) { 540 $cached_translations[] = $json_cache->data->translateSite->body; 541 } 542 } else { 543 $uncached_texts[] = $node_text; 544 } 545 } 546 547 if (!empty($uncached_texts)) { 548 $text_labels = $this->process_text_labels($uncached_texts); 549 550 $translated_texts = $this->fluentc_connenct->get_translation_content( 551 $this->widgetapikey, 552 $this->site_language, 553 $language_code, 554 $text_labels 555 ); 556 557 if (isset($translated_texts->data->translateSite->body) && !empty($translated_texts->data->translateSite->body)) { 558 $cached_translations = array_merge($cached_translations, $translated_texts->data->translateSite->body); 559 } else { 560 do_action('qm/debug', 'Translation error: Data not found in response.'); 561 } 562 } 563 564 $this->applyTranslations($entry_map, $cached_translations, $language_code); 488 565 } else { 489 // If no language code, return the default output. 490 return $text; 491 } 566 // do_action('qm/info', 'No translation needed.'); 567 } 568 569 $this->applySkippedTranslations($entry_skip_map); 570 571 $html = $dom->root->innerHtml(); 572 $html = $this->fluentc_html->find_and_replace($html, null, $language_code, $this->fluentc_connenct->get_language_list_string($this->widgetapikey)); 573 return $html; 492 574 } 493 575 -
fluentc-translation/trunk/src/models/class-htmltags.php
r3122693 r3148988 32 32 */ 33 33 public $forbidden_selectors = array( 34 'link', 35 'script', 36 'style', 37 'kbd', 38 '._fluentc_widget-language-dropdown', 34 'W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> ', 39 35 '._fluentc_widget-language-manager', 40 36 '._fluentc_widget-language-list', 41 37 '._fluentc_widget_float_dropdown_wrapper', 42 'noscript',43 38 ); 44 39 -
fluentc-translation/trunk/src/services/class-connect.php
r3148368 r3148988 132 132 $widgetapikey = get_option( 'fluentc_api_key' ); 133 133 if ( !$widgetapikey ) { 134 return array(); // Return nothing if the API key is not set134 return; // Return nothing if the API key is not set 135 135 } 136 136 -
fluentc-translation/trunk/vendor/paquettg/string-encode/src/stringEncode/Encode.php
r3129167 r3148988 91 91 * @return string 92 92 */ 93 public 94 95 if ($this->from != $this->to) 96 97 $str = iconv($this->from, $this->to, $str);98 93 public function convert($str) 94 { 95 // Ensure $str is not null or false before processing 96 if (!is_string($str) || $str === null) { 97 throw new Exception('Input string is null or invalid.'); 98 } 99 99 100 if ($str === false) 101 { 102 // the convertion was a failure 103 throw new Exception('The convertion from "'.$this->from.'" to "'.$this->to.'" was a failure.'); 104 } 100 if ($this->from != $this->to) { 101 $str = iconv($this->from, $this->to, $str); 102 } 105 103 106 // deal with BOM issue for utf-8 text 107 if ($this->to == 'UTF-8') 108 { 109 if (substr($str, 0, 3) == "\xef\xbb\xbf") 110 { 111 $str = substr($str, 3); 112 } 113 if (substr($str, -3, 3) == "\xef\xbb\xbf") 114 { 115 $str = substr($str, 0, -3); 116 } 117 } 104 if ($str === false) { 105 // The conversion was a failure 106 throw new Exception('The conversion from "' . $this->from . '" to "' . $this->to . '" was a failure.'); 107 } 118 108 119 return $str; 120 } 109 // Deal with BOM issue for utf-8 text 110 if ($this->to == 'UTF-8' && is_string($str)) { 111 if (substr($str, 0, 3) == "\xef\xbb\xbf") { 112 $str = substr($str, 3); 113 } 114 if (substr($str, -3, 3) == "\xef\xbb\xbf") { 115 $str = substr($str, 0, -3); 116 } 117 } 118 119 return $str; 121 120 } 121 }
Note: See TracChangeset
for help on using the changeset viewer.