Plugin Directory

Changeset 3408250


Ignore:
Timestamp:
12/02/2025 04:21:13 PM (4 months ago)
Author:
smartling
Message:

Update to v 5.1.0

Location:
smartling-connector/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • smartling-connector/trunk/inc/Smartling/Extensions/Acf/AcfDynamicSupport.php

    r3401776 r3408250  
    330330            if ($definition['global_type'] === 'field') {
    331331                $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']) {
    335333                    // ACF Option Pages has internal issue in definition, so skip it:
    336334                    if ('group_572b269b668a4' !== $local['parent']) {
  • smartling-connector/trunk/inc/Smartling/Services/ContentRelationsDiscoveryService.php

    r3393007 r3408250  
    785785                        case 'page':
    786786                        case 'post':
     787                            $post = $this->wordpressProxy->get_post($id);
     788                            if ($post === null) {
     789                                continue 2;
     790                            }
    787791                            $title = $this->wordpressProxy->get_post($id)->post_title;
    788792                            $url = $this->wordpressProxy->get_edit_post_link($id);
     
    793797                                $title = $term->name;
    794798                                $url = $this->wordpressProxy->get_edit_term_link($id, $type);
     799                            } else {
     800                                continue 2;
    795801                            }
    796802                    }
  • smartling-connector/trunk/inc/Smartling/WP/View/ContentEditJob.php

    r3393007 r3408250  
    134134                            </td>
    135135                        </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(),
    150143                                        [
    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>
    164161                        <tr>
    165162                            <th class="center" colspan="2">
    166163                                <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>
    167170                                <div id="loader-image" class="hidden"><span class="loader"></span></div>
    168171                                <button class="button button-primary components-button is-primary" id="createJob"
     
    450453            const loadRelations = function loadRelations(contentType, contentId, level = 1) {
    451454                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();
    452459                $('#createJob, #addToJob').prop('disabled', true).addClass(busyClass);
    453460
     
    456463                        switch (level) {
    457464                            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);
    459469                                window.relationsInfo = data.response.data;
    460470                                break;
    461471                            case 2:
    462472                                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);
    464476                                break;
    465477                        }
     
    468480                    }
    469481                }).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                    }
    471487                });
    472488            };
     
    491507            let relationsLoaded = false;
    492508            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            };
    493521
    494522            const loadRelationsOnce = function() {
    495523                if (!relationsLoaded) {
    496524                    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                    }
    498535                }
    499536
     
    507544            };
    508545
    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") {
    511553                    loadRelationsOnce();
    512554                }
    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);
    520570                });
    521571            }
     
    561611                };
    562612
    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                            }
    571635                        });
    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();
    595642
    596643                if (isBulkSubmitPage) {
     
    643690                var message = "Failed adding content to upload queue.";
    644691                $.post(url, data, function (d) {
    645                     if (!isBulkSubmitPage) {
    646                         loadRelations(currentContent.contentType, currentContent.id, localeList);
    647                     }
    648692                    switch (d.status) {
    649693                        case "<?= BaseAjaxServiceAbstract::RESPONSE_SUCCESS ?>":
  • smartling-connector/trunk/js/smartling-connector-gutenberg-lock-attributes.js

    r3333320 r3408250  
    44    const registerBlockTypeHookName = 'blocks.registerBlockType';
    55    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)) {
    77        added = true;
    88        return;
    99    }
    10     if (wp && wp.hasOwnProperty('hooks') && wp.hooks.hasOwnProperty('addFilter')) {
     10    if (typeof(wp) !== 'undefined' && wp.hasOwnProperty('hooks') && wp.hooks.hasOwnProperty('addFilter')) {
    1111        wp.hooks.addFilter(registerBlockTypeHookName, namespace, (settings) => {
    1212            if (settings.attributes) {
  • smartling-connector/trunk/readme.txt

    r3401776 r3408250  
    55Tested up to: 6.6.2
    66Requires PHP: 8.0
    7 Stable tag: 5.0.2
     7Stable tag: 5.1.0
    88License: GPLv2 or later
    99
     
    6363
    6464== Changelog ==
     65= 5.1.0 =
     66* Added Related assets UI on the Bulk Submit page
     67
    6568= 5.0.2 =
    6669* Improved performance when working on installations with a large number of ACF fields
  • smartling-connector/trunk/smartling-connector.php

    r3401776 r3408250  
    1212 * Plugin URI:        https://www.smartling.com/products/automate/integrations/wordpress/
    1313 * Description:       Integrate your WordPress site with Smartling to upload your content and download translations.
    14  * Version:           5.0.2
     14 * Version:           5.1.0
    1515 * Author:            Smartling
    1616 * Author URI:        https://www.smartling.com
Note: See TracChangeset for help on using the changeset viewer.