Changeset 3408250
- Timestamp:
- 12/02/2025 04:21:13 PM (4 months ago)
- Location:
- smartling-connector/trunk
- Files:
-
- 6 edited
-
inc/Smartling/Extensions/Acf/AcfDynamicSupport.php (modified) (1 diff)
-
inc/Smartling/Services/ContentRelationsDiscoveryService.php (modified) (2 diffs)
-
inc/Smartling/WP/View/ContentEditJob.php (modified) (8 diffs)
-
js/smartling-connector-gutenberg-lock-attributes.js (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
smartling-connector.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
smartling-connector/trunk/inc/Smartling/Extensions/Acf/AcfDynamicSupport.php
r3401776 r3408250 330 330 if ($definition['global_type'] === 'field') { 331 331 $local = $localDefinitions[$key]; 332 if ($local['type'] !== $definition['type'] || $local['name'] !== $definition['name'] || 333 $local['parent'] !== $definition['parent'] 334 ) { 332 if ($local['type'] !== $definition['type']) { 335 333 // ACF Option Pages has internal issue in definition, so skip it: 336 334 if ('group_572b269b668a4' !== $local['parent']) { -
smartling-connector/trunk/inc/Smartling/Services/ContentRelationsDiscoveryService.php
r3393007 r3408250 785 785 case 'page': 786 786 case 'post': 787 $post = $this->wordpressProxy->get_post($id); 788 if ($post === null) { 789 continue 2; 790 } 787 791 $title = $this->wordpressProxy->get_post($id)->post_title; 788 792 $url = $this->wordpressProxy->get_edit_post_link($id); … … 793 797 $title = $term->name; 794 798 $url = $this->wordpressProxy->get_edit_term_link($id, $type); 799 } else { 800 continue 2; 795 801 } 796 802 } -
smartling-connector/trunk/inc/Smartling/WP/View/ContentEditJob.php
r3393007 r3408250 134 134 </td> 135 135 </tr> 136 <?php if (!$isBulkSubmitPage) { ?> 137 <tr> 138 <th>Related content</th> 139 <td> 140 <?= HtmlTagGeneratorHelper::tag( 141 'select', 142 HtmlTagGeneratorHelper::renderSelectOptions( 143 GlobalSettingsManager::getRelatedContentSelectState(), 144 [ 145 0 => 'Don\'t send related content', 146 1 => 'Send related content one level deep', 147 2 => 'Send related content two levels deep', 148 ] 149 ), 136 <tr> 137 <th>Related content</th> 138 <td> 139 <?= HtmlTagGeneratorHelper::tag( 140 'select', 141 HtmlTagGeneratorHelper::renderSelectOptions( 142 GlobalSettingsManager::getRelatedContentSelectState(), 150 143 [ 151 'id' => 'depth', 152 'name' => 'depth', 153 ], 154 )?> 155 </td> 156 </tr> 157 <tr id="relationsInfo"> 158 <th>Related content to be uploaded:</th> 159 <td id="relatedContent"> 160 </td> 161 </tr> 162 163 <?php } ?> 144 0 => 'Don\'t send related content', 145 1 => 'Send related content one level deep', 146 2 => 'Send related content two levels deep', 147 ] 148 ), 149 [ 150 'id' => 'depth', 151 'name' => 'depth', 152 ], 153 )?> 154 </td> 155 </tr> 156 <tr id="relationsInfo"> 157 <th>Related content to be uploaded:</th> 158 <td id="relatedContent"> 159 </td> 160 </tr> 164 161 <tr> 165 162 <th class="center" colspan="2"> 166 163 <div id="error-messages"></div> 164 <div id="progress-indicator" class="hidden" style="margin: 10px 0;"> 165 <div style="background: #f0f0f0; border-radius: 4px; overflow: hidden; height: 20px;"> 166 <div id="progress-bar" style="background: #2271b1; height: 100%; width: 0; transition: width 0.3s;"></div> 167 </div> 168 <div id="progress-text" style="margin-top: 5px; font-size: 12px;"></div> 169 </div> 167 170 <div id="loader-image" class="hidden"><span class="loader"></span></div> 168 171 <button class="button button-primary components-button is-primary" id="createJob" … … 450 453 const loadRelations = function loadRelations(contentType, contentId, level = 1) { 451 454 const url = `${ajaxurl}?action=<?= ContentRelationsHandler::ACTION_NAME?>&id=${contentId}&content-type=${contentType}&targetBlogIds=${localeList}`; 455 pendingRequests++; 456 totalRequests++; 457 $('#progress-indicator').removeClass('hidden'); 458 updateProgress(); 452 459 $('#createJob, #addToJob').prop('disabled', true).addClass(busyClass); 453 460 … … 456 463 switch (level) { 457 464 case 1: 458 l1Relations = data.response.data; 465 const newReferences = data.response.data.references; 466 const existingKeys = new Set(l1Relations.references.map(r => `${r.contentType}-${r.id}`)); 467 const uniqueReferences = newReferences.filter(r => !existingKeys.has(`${r.contentType}-${r.id}`)); 468 l1Relations.references = l1Relations.references.concat(uniqueReferences); 459 469 window.relationsInfo = data.response.data; 460 470 break; 461 471 case 2: 462 472 const references = data.response.data.references; 463 l2Relations.references = (l2Relations.references).concat(references); 473 const existingL2Keys = new Set(l2Relations.references.map(r => `${r.contentType}-${r.id}`)); 474 const uniqueL2References = references.filter(r => !existingL2Keys.has(`${r.contentType}-${r.id}`)); 475 l2Relations.references = l2Relations.references.concat(uniqueL2References); 464 476 break; 465 477 } … … 468 480 } 469 481 }).always(() => { 470 $('#createJob, #addToJob').prop('disabled', false).removeClass(busyClass); 482 pendingRequests--; 483 updateProgress(); 484 if (pendingRequests === 0) { 485 $('#createJob, #addToJob').prop('disabled', false).removeClass(busyClass); 486 } 471 487 }); 472 488 }; … … 491 507 let relationsLoaded = false; 492 508 let level2RelationsLoaded = false; 509 let pendingRequests = 0; 510 let totalRequests = 0; 511 512 const updateProgress = function() { 513 const progress = totalRequests > 0 ? ((totalRequests - pendingRequests) / totalRequests) * 100 : 0; 514 $('#progress-bar').css('width', progress + '%'); 515 $('#progress-text').text(`Loading relations: ${totalRequests - pendingRequests} of ${totalRequests} completed`); 516 517 if (pendingRequests === 0 && totalRequests > 0) { 518 setTimeout(() => $('#progress-indicator').addClass('hidden'), 1000); 519 } 520 }; 493 521 494 522 const loadRelationsOnce = function() { 495 523 if (!relationsLoaded) { 496 524 relationsLoaded = true; 497 loadRelations(currentContent.contentType, currentContent.id, 1); 525 if (isBulkSubmitPage) { 526 $("input.bulkaction[type=checkbox]:checked").each(function () { 527 var parts = $(this).attr("id").split("-"); 528 var id = parseInt(parts.shift()); 529 var contentType = parts.join("-"); 530 loadRelations(contentType, id, 1); 531 }); 532 } else { 533 loadRelations(currentContent.contentType, currentContent.id, 1); 534 } 498 535 } 499 536 … … 507 544 }; 508 545 509 if (!isBulkSubmitPage) { 510 if (depthSelector.val() !== "0") { 546 if (depthSelector.val() !== "0") { 547 loadRelationsOnce(); 548 } 549 550 $('.job-wizard input.mcheck, .job-wizard a').on('click', recalculateRelations); 551 depthSelector.on('change', function() { 552 if ($(this).val() !== "0") { 511 553 loadRelationsOnce(); 512 554 } 513 514 $('.job-wizard input.mcheck, .job-wizard a').on('click', recalculateRelations); 515 depthSelector.on('change', function() { 516 if ($(this).val() !== "0") { 517 loadRelationsOnce(); 518 } 519 recalculateRelations(); 555 recalculateRelations(); 556 }); 557 558 if (isBulkSubmitPage) { 559 $(document).on('change', 'input.bulkaction[type=checkbox]', function() { 560 relationsLoaded = false; 561 level2RelationsLoaded = false; 562 pendingRequests = 0; 563 totalRequests = 0; 564 l1Relations = {references: []}; 565 l2Relations = {references: []}; 566 depthSelector.val('0'); 567 $("#relatedContent").html(""); 568 $('#progress-indicator').addClass('hidden'); 569 $('#createJob, #addToJob').prop('disabled', false).removeClass(busyClass); 520 570 }); 521 571 } … … 561 611 }; 562 612 563 if (!isBulkSubmitPage) { 564 const prepareRequest = () => { 565 const selectedRelations = {}; 566 567 // Get selected target blog IDs 568 const targetBlogIds = []; 569 $(".job-wizard input.mcheck[type=checkbox]:checked").each(function () { 570 targetBlogIds.push(this.dataset.blogId); 613 const prepareRequest = () => { 614 const selectedRelations = {}; 615 616 const targetBlogIds = []; 617 $(".job-wizard input.mcheck[type=checkbox]:checked").each(function () { 618 targetBlogIds.push(this.dataset.blogId); 619 }); 620 621 $(".relation-checkbox:checked").each(function () { 622 const contentType = this.dataset.contentType; 623 const id = parseInt(this.dataset.id); 624 625 targetBlogIds.forEach(blogId => { 626 if (!selectedRelations[blogId]) { 627 selectedRelations[blogId] = {}; 628 } 629 if (!selectedRelations[blogId][contentType]) { 630 selectedRelations[blogId][contentType] = []; 631 } 632 if (!selectedRelations[blogId][contentType].includes(id)) { 633 selectedRelations[blogId][contentType].push(id); 634 } 571 635 }); 572 573 $(".relation-checkbox:checked").each(function () { 574 const contentType = this.dataset.contentType; 575 const id = parseInt(this.dataset.id); 576 577 targetBlogIds.forEach(blogId => { 578 if (!selectedRelations[blogId]) { 579 selectedRelations[blogId] = {}; 580 } 581 if (!selectedRelations[blogId][contentType]) { 582 selectedRelations[blogId][contentType] = []; 583 } 584 if (!selectedRelations[blogId][contentType].includes(id)) { 585 selectedRelations[blogId][contentType].push(id); 586 } 587 }); 588 }); 589 590 return selectedRelations; 591 }; 592 593 data.relations = prepareRequest(); 594 } 636 }); 637 638 return selectedRelations; 639 }; 640 641 data.relations = prepareRequest(); 595 642 596 643 if (isBulkSubmitPage) { … … 643 690 var message = "Failed adding content to upload queue."; 644 691 $.post(url, data, function (d) { 645 if (!isBulkSubmitPage) {646 loadRelations(currentContent.contentType, currentContent.id, localeList);647 }648 692 switch (d.status) { 649 693 case "<?= BaseAjaxServiceAbstract::RESPONSE_SUCCESS ?>": -
smartling-connector/trunk/js/smartling-connector-gutenberg-lock-attributes.js
r3333320 r3408250 4 4 const registerBlockTypeHookName = 'blocks.registerBlockType'; 5 5 const namespace = 'smartling/connector/lockAttributes'; 6 if ( wp&& wp.hasOwnProperty('hooks') && wp.hooks.hasOwnProperty('hasFilter') && wp.hooks.hasFilter(registerBlockTypeHookName, namespace)) {6 if (typeof(wp) !== 'undefined' && wp.hasOwnProperty('hooks') && wp.hooks.hasOwnProperty('hasFilter') && wp.hooks.hasFilter(registerBlockTypeHookName, namespace)) { 7 7 added = true; 8 8 return; 9 9 } 10 if ( wp&& wp.hasOwnProperty('hooks') && wp.hooks.hasOwnProperty('addFilter')) {10 if (typeof(wp) !== 'undefined' && wp.hasOwnProperty('hooks') && wp.hooks.hasOwnProperty('addFilter')) { 11 11 wp.hooks.addFilter(registerBlockTypeHookName, namespace, (settings) => { 12 12 if (settings.attributes) { -
smartling-connector/trunk/readme.txt
r3401776 r3408250 5 5 Tested up to: 6.6.2 6 6 Requires PHP: 8.0 7 Stable tag: 5. 0.27 Stable tag: 5.1.0 8 8 License: GPLv2 or later 9 9 … … 63 63 64 64 == Changelog == 65 = 5.1.0 = 66 * Added Related assets UI on the Bulk Submit page 67 65 68 = 5.0.2 = 66 69 * Improved performance when working on installations with a large number of ACF fields -
smartling-connector/trunk/smartling-connector.php
r3401776 r3408250 12 12 * Plugin URI: https://www.smartling.com/products/automate/integrations/wordpress/ 13 13 * Description: Integrate your WordPress site with Smartling to upload your content and download translations. 14 * Version: 5. 0.214 * Version: 5.1.0 15 15 * Author: Smartling 16 16 * Author URI: https://www.smartling.com
Note: See TracChangeset
for help on using the changeset viewer.