Changeset 3408258
- Timestamp:
- 12/02/2025 04:33:41 PM (4 months ago)
- Location:
- conveythis-translate/trunk
- Files:
-
- 7 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)
Legend:
- Unmodified
- Added
- Removed
-
conveythis-translate/trunk/app/class/ConveyThis.php
r3394560 r3408258 338 338 } 339 339 340 340 341 $exclusions = $incoming['exclusions'] ?? null; 341 342 $glossary = $incoming['glossary'] ?? null; … … 361 362 update_option($field, $value); 362 363 } 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', []); 363 372 } 364 373 -
conveythis-translate/trunk/app/class/Variables.php
r3394560 r3408258 321 321 322 322 public $matchingLanguages = array( 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]), 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 ), 326 394 ); 327 395 328 396 public $matchingLanguageToFlag = array( 397 // English: US / GB / CA 329 398 703 => array(498, 497, 342), 399 400 // Chinese (Simplified): Mainland China, Singapore, Malaysia 401 719 => array(347, 466, 415), 402 403 // Chinese (Traditional): Taiwan, Hong Kong 404 796 => array(482, 508), 405 406 // Arabic: Middle East + North Africa 407 707 => array( 408 // Middle East 409 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 Africa 422 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, Portugal 330 436 768 => array(336, 450), 331 777 => array(422, 318, 348, 474) 437 438 // Spanish: Mexico, Argentina, Colombia, Spain 439 777 => array(422, 318, 348, 474), 440 727 => array(371, 342), 332 441 ); 333 442 -
conveythis-translate/trunk/app/views/page/widget-style.php
r3328452 r3408258 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=""> 73 74 <i class="dropdown icon"></i> 74 <div class="default text"><?php echo esc_html(__( 'Select language', 'conveythis-translate' )); ?></div> 75 <div class="default text"> 76 <?php echo esc_html(__( 'Select language', 'conveythis-translate' )); ?> 77 </div> 75 78 <div class="menu"> 76 77 79 <?php foreach( $this->variables->matchingLanguages as $id => $language ): ?> 78 79 <div class="item" data-value="<?php echo esc_attr($id); ?>"> 80 <div class="item" data-value="<?php echo esc_attr($id); ?>"> 80 81 <?php echo esc_html( $language['title_en'], 'conveythis-translate' ); ?> 81 82 </div> 82 83 83 <?php endforeach; ?> 84 85 84 </div> 86 85 </div> 87 86 </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=""> 90 91 <i class="dropdown icon"></i> 91 <div class="default text"><?php echo esc_html(__( 'Select Flag', 'conveythis-translate' )); ?></div> 92 <div class="default text"> 93 <?php echo esc_html(__( 'Select Flag', 'conveythis-translate' )); ?> 94 </div> 92 95 <div class="menu"> 93 94 96 <?php foreach( $this->variables->matchingFlags as $flag ): ?> 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> 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> 98 99 <?php echo esc_html( $flag['title'], 'conveythis-translate' ); ?> 99 100 </div> 100 101 101 <?php endforeach; ?> 102 103 102 </div> 104 103 </div> -
conveythis-translate/trunk/app/widget/js/settings.js
r3394560 r3408258 13 13 $('.ui.dropdown').dropdown({ 14 14 onChange: function () { 15 conveythisSettings.view(); 15 if (typeof conveythisSettings !== 'undefined' && conveythisSettings.view) { 16 conveythisSettings.view(); 17 } 16 18 } 17 19 }); … … 124 126 prepareSettingsBeforeSave(); 125 127 126 const data = Object.fromEntries(new FormData(form[0])); 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 127 174 console.log(data); 128 175 console.log(conveythis_plugin_ajax.ajax_url); … … 320 367 'code3': 'eng', 321 368 'flag': 'R04', 322 'flag_codes': {' us': 'United States of America', 'gb': ' United Kingdom', 'ca': 'Canada'}369 'flag_codes': {'gb': ' United Kingdom', 'ca': 'Canada', 'au': 'Australia'} 323 370 }, 324 371 704: {'title_en': 'Afrikaans', 'title': 'Afrikaans', 'code2': 'af', 'code3': 'afr', 'flag': '7xS'}, 325 372 705: {'title_en': 'Albanian', 'title': 'Shqip', 'code2': 'sq', 'code3': 'sqi', 'flag': '5iM'}, 326 373 706: {'title_en': 'Amharic', 'title': 'አማርኛ', 'code2': 'am', 'code3': 'amh', 'flag': 'ZH1'}, 327 707: {'title_en': 'Arabic', 'title': 'العربية', 'code2': 'ar', 'code3': 'ara', 'flag': 'J06'}, 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 }, 328 407 708: {'title_en': 'Armenian', 'title': 'Հայերեն', 'code2': 'hy', 'code3': 'hye', 'flag': 'q9U'}, 329 408 709: {'title_en': 'Azerbaijan', 'title': 'Azərbaycanca', 'code2': 'az', 'code3': 'aze', 'flag': 'Wg1'}, … … 337 416 717: {'title_en': 'Catalan', 'title': 'Català', 'code2': 'ca', 'code3': 'cat', 'flag': 'Pw6'}, 338 417 718: {'title_en': 'Cebuano', 'title': 'Cebuano', 'code2': 'ceb', 'code3': 'ceb', 'flag': ''}, 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'}, 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 }, 341 441 720: {'title_en': 'Croatian', 'title': 'Hrvatski', 'code2': 'hr', 'code3': 'hrv', 'flag': '7KQ'}, 342 442 721: {'title_en': 'Czech', 'title': 'Čeština', 'code2': 'cs', 'code3': 'cze', 'flag': '1ZY'}, … … 353 453 'flag': 'nM4' 354 454 }, 355 727: {'title_en': 'French', 'title': 'Français', 'code2': 'fr', 'code3': 'fre', 'flag': 'E77'}, 455 727: {'title_en': 'French', 'title': 'Français', 'code2': 'fr', 'code3': 'fre', 'flag': 'E77', 456 'flag_codes': { 457 'ca': 'Canada' 458 } 459 }, 356 460 728: {'title_en': 'Galician', 'title': 'Galego', 'code2': 'gl', 'code3': 'glg', 'flag': 'A5d'}, 357 461 729: {'title_en': 'Georgian', 'title': 'ქართული', 'code2': 'ka', 'code3': 'kat', 'flag': '8Ou'}, … … 416 520 'code3': 'spa', 417 521 'flag': 'A5d', 418 'flag_codes': {'mx': 'Mexico', 'ar': 'Argentina', 'co': 'Colombia' , 'es': 'Spain'}522 'flag_codes': {'mx': 'Mexico', 'ar': 'Argentina', 'co': 'Colombia'} 419 523 }, 420 524 778: {'title_en': 'Sundanese', 'title': 'Basa Sunda', 'code2': 'su', 'code3': 'sun', 'flag': 'Wh1'}, … … 507 611 // 508 612 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 ); 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 }); 520 627 521 628 conveythisSettings.effect(function () { … … 563 670 $(document).find('.conveythis-delete-page').on('click', function (e) { 564 671 e.preventDefault(); 565 $(this).parent().remove(); 672 const $parent = $(this).parent(); 673 $parent.remove(); 674 updateStyleLanguageDropdowns(); 566 675 }); 567 676 … … 589 698 e.preventDefault(); 590 699 $(this).parent().remove(); 700 updateStyleLanguageDropdowns(); 591 701 }); 592 702 … … 597 707 e.preventDefault(); 598 708 599 if ($(".style-language").length == 4) {709 if ($(".style-language").length == 8) { 600 710 $('#add_flag_style').prop("disable", true); 601 711 return; 602 712 } 603 713 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="">') 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 609 725 $("#flag-style_wrapper").append($rule_style); 726 sortFlagsByLanguage(); 610 727 611 728 $(document).find('.conveythis-delete-page').on('click', function (e) { … … 616 733 $('.ui.dropdown').dropdown(); 617 734 sortFlagsByLanguage(); 735 updateStyleLanguageDropdowns(); 618 736 }); 619 737 … … 1227 1345 1228 1346 }); 1347 updateStyleLanguageDropdowns(); 1229 1348 }, 1349 }); 1350 } 1351 1352 // Prevents the user from selecting same language twice 1353 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 }); 1230 1384 }); 1231 1385 } -
conveythis-translate/trunk/changelog.txt
r3394560 r3408258 1 1 == Changelog == 2 = 268.9 = 3 * Enhanced Change Flag feature with broader functionality. 4 2 5 = 268.8 = 3 6 * Now elements can be excluded using their class attribute. -
conveythis-translate/trunk/config.php
r3394560 r3408258 7 7 $dev_server = 'default'; 8 8 9 //$dev_server = 3;9 //$dev_server = 4; 10 10 11 11 $allowed_app_servers = array( -
conveythis-translate/trunk/index.php
r3394560 r3408258 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. 86 Version: 268.9 7 7 8 8 Author: ConveyThis Translate Team
Note: See TracChangeset
for help on using the changeset viewer.