Changeset 3408432
- Timestamp:
- 12/02/2025 08:01:56 PM (4 months ago)
- Location:
- conveythis-translate/trunk
- Files:
-
- 8 edited
-
app/class/ConveyThis.php (modified) (2 diffs)
-
app/class/Variables.php (modified) (1 diff)
-
app/views/page/widget-style.php (modified) (1 diff)
-
app/widget/js/settings.js (modified) (12 diffs)
-
changelog.txt (modified) (1 diff)
-
config.php (modified) (1 diff)
-
index.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
conveythis-translate/trunk/app/class/ConveyThis.php
r3408258 r3408432 338 338 } 339 339 340 341 340 $exclusions = $incoming['exclusions'] ?? null; 342 341 $glossary = $incoming['glossary'] ?? null; … … 362 361 update_option($field, $value); 363 362 } 364 }365 366 if (!array_key_exists('style_change_language', $incoming)) {367 update_option('style_change_language', []);368 }369 370 if (!array_key_exists('style_change_flag', $incoming)) {371 update_option('style_change_flag', []);372 363 } 373 364 -
conveythis-translate/trunk/app/class/Variables.php
r3408258 r3408432 321 321 322 322 public $matchingLanguages = array( 323 703 => array( 324 'language_id' => 703, 325 'title_en' => 'English', 326 'title' => 'English', 327 'code2' => 'en', 328 'code3' => 'eng', 329 'flag' => 'us', 330 'flag_ids' => [498, 497, 342], 331 ), 332 333 719 => array( 334 'language_id' => 719, 335 'title_en' => 'Chinese (Simplified)', 336 'title' => '简体', 337 'code2' => 'zh', 338 'code3' => 'zho-sim', 339 'flag' => 'cn', 340 'flag_ids' => [347, 466, 415], // China, Singapore, Malaysia 341 ), 342 343 796 => array( 344 'language_id' => 796, 345 'title_en' => 'Chinese (Traditional)', 346 'title' => '繁體', 347 'code2' => 'zh-tw', 348 'code3' => 'zho-tra', 349 'flag' => 'tw', 350 'flag_ids' => [347, 482, 508], // China, Taiwan, Hong Kong 351 ), 352 353 707 => array( 354 'language_id' => 707, 355 'title_en' => 'Arabic', 356 'title' => 'العربية', 357 'code2' => 'ar', 358 'code3' => 'ara', 359 'flag' => 'sa', 360 'flag_ids' => [ 361 324, 390, 396, 401, 405, 441, 451, 461, 481, 496, 505, 362 314, 345, 349, 359, 363, 408, 420, 428, 470, 476, 490, 363 ], 364 ), 365 366 768 => array( 367 'language_id' => 768, 368 'title_en' => 'Portuguese', 369 'title' => 'Português', 370 'code2' => 'pt', 371 'code3' => 'por', 372 'flag' => 'br', 373 'flag_ids' => [336, 450], 374 ), 375 376 777 => array( 377 'language_id' => 777, 378 'title_en' => 'Spanish', 379 'title' => 'Español', 380 'code2' => 'es', 381 'code3' => 'spa', 382 'flag' => 'es', 383 'flag_ids' => [422, 318, 348, 474], //Mexico, Argentina, Colombia, Spain 384 ), 385 727 => array( 386 'language_id' => 727, 387 'title_en' => 'French', 388 'title' => 'Français', 389 'code2' => 'fr', 390 'code3' => 'fre', 391 'flag' => 'fr', 392 'flag_ids' => [371, 342], // France, Canada 393 ), 323 703 => array('language_id' => 703, 'title_en' => 'English', 'title' => 'English', 'code2' => 'en', 'code3' => 'eng', 'flag' => 'us', 'flag_ids' => [498, 497, 342]), 324 768 => array('language_id' => 768, 'title_en' => 'Portuguese', 'title' => 'Português', 'code2' => 'pt', 'code3' => 'por', 'flag' => 'br', 'flag_ids' => [422, 318, 348]), 325 777 => array('language_id' => 777, 'title_en' => 'Spanish', 'title' => 'Español', 'code2' => 'es', 'code3' => 'spa', 'flag' => 'es', 'flag_ids' => [336]), 394 326 ); 395 327 396 328 public $matchingLanguageToFlag = array( 397 // English: US / GB / CA398 329 703 => array(498, 497, 342), 399 400 // Chinese (Simplified): Mainland China, Singapore, Malaysia401 719 => array(347, 466, 415),402 403 // Chinese (Traditional): Taiwan, Hong Kong404 796 => array(482, 508),405 406 // Arabic: Middle East + North Africa407 707 => array(408 // Middle East409 324, // Bahrain (bh)410 390, // Iraq (iq)411 396, // Jordan (jo)412 401, // Kuwait (kw)413 405, // Lebanon (lb)414 441, // Oman (om)415 451, // Qatar (qa)416 461, // Saudi Arabia (sa)417 481, // Syria (sy)418 496, // United Arab Emirates (ae)419 505, // Yemen (ye)420 421 // North Africa422 314, // Algeria (dz)423 345, // Chad (td)424 349, // Comoros (km)425 359, // Djibouti (dj)426 363, // Egypt (eg)427 408, // Libya (ly)428 420, // Mauritania (mr)429 428, // Morocco (ma)430 470, // Somalia (so)431 476, // Sudan (sd)432 490, // Tunisia (tn)433 ),434 435 // Portuguese: Brazil, Portugal436 330 768 => array(336, 450), 437 438 // Spanish: Mexico, Argentina, Colombia, Spain 439 777 => array(422, 318, 348, 474), 440 727 => array(371, 342), 331 777 => array(422, 318, 348, 474) 441 332 ); 442 333 -
conveythis-translate/trunk/app/views/page/widget-style.php
r3408258 r3408432 71 71 <div class="col-md-6"> 72 72 <div class="ui fluid search selection dropdown change_language"> 73 <input type="hidden" class="style_change_flag" name="style_change_flag[]" value="">74 73 <i class="dropdown icon"></i> 75 <div class="default text"> 76 <?php echo esc_html(__( 'Select language', 'conveythis-translate' )); ?> 77 </div> 74 <div class="default text"><?php echo esc_html(__( 'Select language', 'conveythis-translate' )); ?></div> 78 75 <div class="menu"> 76 79 77 <?php foreach( $this->variables->matchingLanguages as $id => $language ): ?> 80 <div class="item" data-value="<?php echo esc_attr($id); ?>"> 78 79 <div class="item" data-value="<?php echo esc_attr($id); ?>"> 81 80 <?php echo esc_html( $language['title_en'], 'conveythis-translate' ); ?> 82 81 </div> 82 83 83 <?php endforeach; ?> 84 84 85 </div> 85 86 </div> 86 87 </div> 87 88 88 <div class="col-md-6"> 89 89 <div class="ui fluid search selection dropdown change_flag"> 90 <input type="hidden" class="style_change_flag" name="style_change_flag[]" value="">91 90 <i class="dropdown icon"></i> 92 <div class="default text"> 93 <?php echo esc_html(__( 'Select Flag', 'conveythis-translate' )); ?> 94 </div> 91 <div class="default text"><?php echo esc_html(__( 'Select Flag', 'conveythis-translate' )); ?></div> 95 92 <div class="menu"> 93 96 94 <?php foreach( $this->variables->matchingFlags as $flag ): ?> 97 <div class="item" data-value="<?php echo esc_attr( $flag['code'] ); ?>"> 98 <div class="ui image" style="height:28px;width:30px;background-position:50% 50%;background-size:contain;background-repeat:no-repeat;background-image:url('//cdn.conveythis.com/images/flags/svg/<?php echo esc_attr($flag['code']); ?>.svg')"></div> 95 96 <div class="item" data-value="<?php echo esc_attr( $flag['code'] ); ?>"> 97 <div class="ui image" style="height: 28px; width: 30px; background-position: 50% 50%; background-size: contain; background-repeat: no-repeat; background-image: url('//cdn.conveythis.com/images/flags/svg/<?php echo esc_attr($flag['code']); ?>.svg')"></div> 99 98 <?php echo esc_html( $flag['title'], 'conveythis-translate' ); ?> 100 99 </div> 100 101 101 <?php endforeach; ?> 102 102 103 </div> 103 104 </div> -
conveythis-translate/trunk/app/widget/js/settings.js
r3408258 r3408432 13 13 $('.ui.dropdown').dropdown({ 14 14 onChange: function () { 15 if (typeof conveythisSettings !== 'undefined' && conveythisSettings.view) { 16 conveythisSettings.view(); 17 } 15 conveythisSettings.view(); 18 16 } 19 17 }); … … 126 124 prepareSettingsBeforeSave(); 127 125 128 //const data = Object.fromEntries(new FormData(form[0])); 129 130 const raw = form.serializeArray(); 131 const data = {}; 132 133 raw.forEach(function (item) { 134 const name = item.name; 135 const value = item.value; 136 137 if (name.endsWith('[]')) { 138 // style_change_flag[] -> style_change_flag 139 const key = name.slice(0, -2); 140 if (!Array.isArray(data[key])) { 141 data[key] = []; 142 } 143 data[key].push(value); 144 } else { 145 if (!(name in data)) { 146 data[name] = value; 147 } 148 } 149 }); 150 151 const langs = []; 152 const flags = []; 153 154 $('#flag-style_wrapper .style-language:not(.cloned)').each(function () { 155 const lang = $(this) 156 .find('.change_language input[name="style_change_language[]"]') 157 .val(); 158 const flag = $(this) 159 .find('.change_flag input[name="style_change_flag[]"]') 160 .val(); 161 162 163 if (lang && flag) { 164 langs.push(lang); 165 flags.push(flag); 166 } 167 }); 168 169 data.style_change_language = langs; 170 data.style_change_flag = flags; 171 172 console.log('CLEAN DATA:', data); 173 126 const data = Object.fromEntries(new FormData(form[0])); 174 127 console.log(data); 175 128 console.log(conveythis_plugin_ajax.ajax_url); … … 367 320 'code3': 'eng', 368 321 'flag': 'R04', 369 'flag_codes': {' gb': ' United Kingdom', 'ca': 'Canada', 'au': 'Australia'}322 'flag_codes': {'us': 'United States of America', 'gb': ' United Kingdom', 'ca': 'Canada'} 370 323 }, 371 324 704: {'title_en': 'Afrikaans', 'title': 'Afrikaans', 'code2': 'af', 'code3': 'afr', 'flag': '7xS'}, 372 325 705: {'title_en': 'Albanian', 'title': 'Shqip', 'code2': 'sq', 'code3': 'sqi', 'flag': '5iM'}, 373 326 706: {'title_en': 'Amharic', 'title': 'አማርኛ', 'code2': 'am', 'code3': 'amh', 'flag': 'ZH1'}, 374 707: { 375 'title_en': 'Arabic', 376 'title': 'العربية', 377 'code2': 'ar', 378 'code3': 'ara', 379 'flag': 'J06', 380 'flag_codes': { 381 'bh': 'Bahrain', 382 'iq': 'Iraq', 383 'jo': 'Jordan', 384 'kw': 'Kuwait', 385 'lb': 'Lebanon', 386 'om': 'Oman', 387 'ps': 'Palestine', 388 'qa': 'Qatar', 389 'sy': 'Syria', 390 'ae': 'United Arab Emirates', 391 'ye': 'Yemen', 392 393 394 'dz': 'Algeria', 395 'td': 'Chad', 396 'km': 'Comoros', 397 'dj': 'Djibouti', 398 'eg': 'Egypt', 399 'ly': 'Libya', 400 'mr': 'Mauritania', 401 'ma': 'Morocco', 402 'so': 'Somalia', 403 'sd': 'Sudan', 404 'tn': 'Tunisia' 405 } 406 }, 327 707: {'title_en': 'Arabic', 'title': 'العربية', 'code2': 'ar', 'code3': 'ara', 'flag': 'J06'}, 407 328 708: {'title_en': 'Armenian', 'title': 'Հայերեն', 'code2': 'hy', 'code3': 'hye', 'flag': 'q9U'}, 408 329 709: {'title_en': 'Azerbaijan', 'title': 'Azərbaycanca', 'code2': 'az', 'code3': 'aze', 'flag': 'Wg1'}, … … 416 337 717: {'title_en': 'Catalan', 'title': 'Català', 'code2': 'ca', 'code3': 'cat', 'flag': 'Pw6'}, 417 338 718: {'title_en': 'Cebuano', 'title': 'Cebuano', 'code2': 'ceb', 'code3': 'ceb', 'flag': ''}, 418 719: { 419 'title_en': 'Chinese (Simplified)', 420 'title': '简体', 421 'code2': 'zh', 422 'code3': 'zh-sim', 423 'flag': 'Z1v', 424 'flag_codes': { 425 'sg': 'Singapore', 426 'my': 'Malaysia' 427 } 428 }, 429 796: { 430 'title_en': 'Chinese (Traditional)', 431 'title': '繁體', 432 'code2': 'zh-tw', 433 'code3': 'zh-tra', 434 'flag': 'Z1v', 435 'flag_codes': { 436 'tw': 'Taiwan', 437 'hk': 'Hong Kong', 438 'mo': 'Macau' 439 } 440 }, 339 719: {'title_en': 'Chinese (Simplified)', 'title': '简体', 'code2': 'zh', 'code3': 'zh-sim', 'flag': 'Z1v'}, 340 796: {'title_en': 'Chinese (Traditional)', 'title': '繁體', 'code2': 'zh-tw', 'code3': 'zh-tra', 'flag': 'Z1v'}, 441 341 720: {'title_en': 'Croatian', 'title': 'Hrvatski', 'code2': 'hr', 'code3': 'hrv', 'flag': '7KQ'}, 442 342 721: {'title_en': 'Czech', 'title': 'Čeština', 'code2': 'cs', 'code3': 'cze', 'flag': '1ZY'}, … … 453 353 'flag': 'nM4' 454 354 }, 455 727: {'title_en': 'French', 'title': 'Français', 'code2': 'fr', 'code3': 'fre', 'flag': 'E77', 456 'flag_codes': { 457 'ca': 'Canada' 458 } 459 }, 355 727: {'title_en': 'French', 'title': 'Français', 'code2': 'fr', 'code3': 'fre', 'flag': 'E77'}, 460 356 728: {'title_en': 'Galician', 'title': 'Galego', 'code2': 'gl', 'code3': 'glg', 'flag': 'A5d'}, 461 357 729: {'title_en': 'Georgian', 'title': 'ქართული', 'code2': 'ka', 'code3': 'kat', 'flag': '8Ou'}, … … 520 416 'code3': 'spa', 521 417 'flag': 'A5d', 522 'flag_codes': {'mx': 'Mexico', 'ar': 'Argentina', 'co': 'Colombia' }418 'flag_codes': {'mx': 'Mexico', 'ar': 'Argentina', 'co': 'Colombia', 'es': 'Spain'} 523 419 }, 524 420 778: {'title_en': 'Sundanese', 'title': 'Basa Sunda', 'code2': 'su', 'code3': 'sun', 'flag': 'Wh1'}, … … 611 507 // 612 508 613 $('.ui.dropdown').dropdown({ 614 onChange: function (value) { 615 616 if ($(this).hasClass('widget-trigger')) { 617 hideTargetLanguage(); 618 } 619 620 if (typeof conveythisSettings !== 'undefined' && conveythisSettings.view) { 621 conveythisSettings.view(); 622 } 623 624 showDnsRecords(); 625 } 626 }); 509 $('.ui.dropdown').dropdown( 510 { 511 onChange: function (e) { 512 if ($(this).hasClass('widget-trigger')) { 513 hideTargetLanguage(); 514 conveythisSettings.view(); 515 } 516 showDnsRecords(); 517 } 518 } 519 ); 627 520 628 521 conveythisSettings.effect(function () { … … 670 563 $(document).find('.conveythis-delete-page').on('click', function (e) { 671 564 e.preventDefault(); 672 const $parent = $(this).parent(); 673 $parent.remove(); 674 updateStyleLanguageDropdowns(); 565 $(this).parent().remove(); 675 566 }); 676 567 … … 698 589 e.preventDefault(); 699 590 $(this).parent().remove(); 700 updateStyleLanguageDropdowns();701 591 }); 702 592 … … 707 597 e.preventDefault(); 708 598 709 if ($(".style-language").length == 8) {599 if ($(".style-language").length == 4) { 710 600 $('#add_flag_style').prop("disable", true); 711 601 return; 712 602 } 713 603 714 $rule_style = $('.cloned').clone(); 715 $rule_style.removeClass('cloned'); 716 717 $rule_style.find('.change_language input[type="hidden"]').remove(); 718 $rule_style.find('.change_flag input[type="hidden"]').remove(); 719 720 $rule_style.find('.change_language') 721 .prepend('<input type="hidden" name="style_change_language[]" value="">'); 722 $rule_style.find('.change_flag') 723 .prepend('<input type="hidden" name="style_change_flag[]" value="">'); 724 604 let $rule_style = $('.cloned').clone() 605 606 $rule_style.removeClass('cloned') 607 $rule_style.find('.change_language').prepend('<input type="hidden" name="style_change_language[]" value="">') 608 $rule_style.find('.change_flag').prepend('<input type="hidden" name="style_change_flag[]" value="">') 725 609 $("#flag-style_wrapper").append($rule_style); 726 sortFlagsByLanguage();727 610 728 611 $(document).find('.conveythis-delete-page').on('click', function (e) { … … 733 616 $('.ui.dropdown').dropdown(); 734 617 sortFlagsByLanguage(); 735 updateStyleLanguageDropdowns();736 618 }); 737 619 … … 1345 1227 1346 1228 }); 1347 updateStyleLanguageDropdowns();1348 1229 }, 1349 });1350 }1351 1352 // Prevents the user from selecting same language twice1353 function updateStyleLanguageDropdowns() {1354 1355 const used = [];1356 1357 $('#flag-style_wrapper .style-language:not(.cloned) .ui.dropdown.change_language').each(function () {1358 const val = $(this).dropdown('get value');1359 if (val) {1360 used.push(String(val));1361 }1362 });1363 1364 1365 $('#flag-style_wrapper .style-language:not(.cloned) .ui.dropdown.change_language').each(function () {1366 const current = String($(this).dropdown('get value') || '');1367 const $items = $(this).find('.menu .item');1368 1369 $items.each(function () {1370 const val = String($(this).data('value') || '');1371 1372 if (used.includes(val) && val !== current) {1373 1374 $(this)1375 .addClass('disabled')1376 .css({ 'pointer-events': 'none', opacity: 0.4 });1377 } else {1378 1379 $(this)1380 .removeClass('disabled')1381 .css({ 'pointer-events': '', opacity: '' });1382 }1383 });1384 1230 }); 1385 1231 } -
conveythis-translate/trunk/changelog.txt
r3408258 r3408432 1 1 == Changelog == 2 = 268.9 =3 * Enhanced Change Flag feature with broader functionality.4 5 2 = 268.8 = 6 3 * Now elements can be excluded using their class attribute. -
conveythis-translate/trunk/config.php
r3408258 r3408432 7 7 $dev_server = 'default'; 8 8 9 //$dev_server = 4;9 //$dev_server = 3; 10 10 11 11 $allowed_app_servers = array( -
conveythis-translate/trunk/index.php
r3408258 r3408432 4 4 Plugin URI: https://www.conveythis.com/?utm_source=widget&utm_medium=wordpress 5 5 Description: Translate your WordPress site into over 100 languages using professional and instant machine translation technology. ConveyThis will help provide you with an SEO-friendy, multilingual website in minutes with no coding required. 6 Version: 268. 96 Version: 268.8 7 7 8 8 Author: ConveyThis Translate Team -
conveythis-translate/trunk/readme.txt
r3408316 r3408432 6 6 Tested up to: 6.8.2 7 7 8 Stable tag: 268. 98 Stable tag: 268.8 9 9 10 10 License: GPLv2 … … 218 218 219 219 == Changelog == 220 = 268.9 =221 * Enhanced Change Flag feature with broader functionality.222 223 220 = 268.8 = 224 221 * Now elements can be excluded using their class attribute.
Note: See TracChangeset
for help on using the changeset viewer.