Plugin Directory

Changeset 3320573


Ignore:
Timestamp:
07/01/2025 11:35:35 AM (8 months ago)
Author:
smartling
Message:

Update to v 3.11.6

Location:
smartling-connector/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • smartling-connector/trunk/inc/Smartling/ContentTypes/ExternalContentElementor.php

    r3318909 r3320573  
    44
    55use Elementor\Core\Documents_Manager;
    6 use Elementor\TemplateLibrary\Source_Local;
     6use ElementorPro\Plugin;
    77use Smartling\Base\ExportedAPI;
    88use Smartling\ContentTypes\Elementor\ElementFactory;
     
    7070            return;
    7171        }
    72         $sourceLocalPath = WP_PLUGIN_DIR . '/elementor/includes/template-library/sources/local.php';
    73         $terms = [];
    74         if (file_exists($sourceLocalPath)) {
    75             $terms = $this->siteHelper->withBlog($submission->getSourceBlogId(), function () use ($submission) {
    76                 return $this->wpProxy->wp_get_object_terms($submission->getSourceId(), Source_Local::TAXONOMY_TYPE_SLUG);
    77             });
    78         }
    79         $this->siteHelper->withBlog($submission->getTargetBlogId(), function () use ($sourceLocalPath, $submission, $terms) {
     72        $this->siteHelper->withBlog($submission->getTargetBlogId(), function () use ($submission) {
    8073            $supportLevel = $this->getSupportLevel($submission->getContentType(), $submission->getTargetId());
    81             $this->getLogger()->debug(sprintf('Processing Elementor after content written hook, contentType=%s, sourceBlogId=%d, sourceId=%d, submissionId=%d, targetBlogId=%d, targetId=%d, supportLevel=%s', $submission->getContentType(), $submission->getSourceBlogId(), $submission->getSourceId(), $submission->getId(), $submission->getTargetBlogId(), $submission->getTargetId(), $supportLevel));
    82             $documentsManagerPath = WP_PLUGIN_DIR . '/elementor/core/documents-manager.php';
    83             if ($supportLevel !== Pluggable::NOT_SUPPORTED && file_exists($documentsManagerPath)) {
    84                 $this->userHelper->asAdministratorOrEditor(function () use ($documentsManagerPath, $submission) {
     74            $documentsManager = $this->getDocumentsManager();
     75            if ($supportLevel !== Pluggable::NOT_SUPPORTED && $documentsManager !== null) {
     76                $this->getLogger()->debug(sprintf('Processing Elementor after content written hook, contentType=%s, sourceBlogId=%d, sourceId=%d, submissionId=%d, targetBlogId=%d, targetId=%d, supportLevel=%s', $submission->getContentType(), $submission->getSourceBlogId(), $submission->getSourceId(), $submission->getId(), $submission->getTargetBlogId(), $submission->getTargetId(), $supportLevel));
     77                $this->userHelper->asAdministratorOrEditor(function () use ($documentsManager, $submission) {
    8578                    try {
    86                         require_once $documentsManagerPath;
    87                         $manager = new Documents_Manager();
    88                         do_action('elementor/documents/register', $manager);
    8979                        /** @noinspection PhpParamsInspection */
    90                         $manager->ajax_save([
     80                        $documentsManager->ajax_save([
    9181                            'editor_post_id' => $submission->getTargetId(),
    9282                            'elements' => json_decode($this->getDataFromPostMeta($submission->getTargetId()),
     
    10191                });
    10292            }
    103             if (file_exists($sourceLocalPath)) {
    104                 try {
    105                     $newTerms = [];
    106                     foreach ($terms as $term) {
    107                         $add = $term->term_id;
    108                         $related = $this->ensureSubmissionForRelatedTerm($submission, $term);
    109                         if ($related !== null) {
    110                             $add = $related->getTargetId();
    111                         }
    112                         $newTerms[] = $add;
    113                     }
    114                     $this->wpProxy->setObjectTerms($submission->getTargetId(), $newTerms, Source_Local::TAXONOMY_TYPE_SLUG);
    115                 } catch (\Throwable $e) {
    116                     $this->getLogger()->notice(sprintf("Unable to check object terms in Elementor contentType=%s, submissionId=%d, targetBlogId=%d, targetId=%d: %s (%s)", $submission->getContentType(), $submission->getId(), $submission->getTargetBlogId(), $submission->getTargetId(), $e->getMessage(), $e->getTraceAsString()));
    117                 }
    118             }
    11993        });
    12094        $this->getLogger()->info("Done processing Elementor after content written hook");
     
    196170    {
    197171        return $this->getData($this->readMeta($contentId))->getRelatedContentInfo()->getRelatedContentList();
    198     }
    199 
    200     public function ensureSubmissionForRelatedTerm(SubmissionEntity $submission, \WP_Term $term): ?SubmissionEntity
    201     {
    202         $result = $this->submissionManager->findOne([
    203             SubmissionEntity::FIELD_CONTENT_TYPE => $term->taxonomy,
    204             SubmissionEntity::FIELD_SOURCE_BLOG_ID => $submission->getSourceBlogId(),
    205             SubmissionEntity::FIELD_SOURCE_ID => $term->term_id,
    206             SubmissionEntity::FIELD_TARGET_BLOG_ID => $submission->getTargetBlogId(),
    207         ]);
    208         if ($result === null) {
    209             $this->getLogger()->debug("Creating submission for termId=$term->term_id, taxonomy=$term->taxonomy, slug=$term->slug, name=$term->name");
    210             $entity = $this->submissionManager->getSubmissionEntity($term->taxonomy, $submission->getSourceBlogId(), $term->term_id, $submission->getTargetBlogId());
    211             $entity->setSourceTitle($term->name);
    212             $entity->setIsCloned(1);
    213             $stored = $this->submissionManager->storeEntity($entity);
    214             do_action(ExportedAPI::ACTION_SMARTLING_CLONE_CONTENT, $stored);
    215             $result = $this->submissionManager->getEntityById($stored->getId());
    216         }
    217         return $result;
    218172    }
    219173
     
    252206        return $translation;
    253207    }
     208
     209    private function getDocumentsManager(): ?Documents_Manager
     210    {
     211        if (class_exists(Plugin::class)) {
     212            return Plugin::elementor()->documents;
     213        }
     214        $documentsManagerPath = WP_PLUGIN_DIR . '/elementor/core/documents-manager.php';
     215        if (file_exists($documentsManagerPath)) {
     216            try {
     217                require_once $documentsManagerPath;
     218
     219                $manager = new Documents_Manager();
     220                do_action('elementor/documents/register', $manager);
     221                return $manager;
     222            } catch (\Throwable) {
     223                // No documents manager available
     224            }
     225        }
     226        if (class_exists(Documents_Manager::class)) {
     227            return new Documents_Manager();
     228        }
     229
     230        return null;
     231    }
    254232}
  • smartling-connector/trunk/inc/Smartling/ContentTypes/ExternalContentGravityForms.php

    r3294670 r3320573  
    6262            || ($this->contentTypeHelper->isPost($contentType)
    6363                && str_contains(
    64                     $this->wpProxy->get_post($contentId)->post_content,
     64                    $this->wpProxy->get_post($contentId)->post_content ?? '',
    6565                    'gravityforms',
    6666                ))) {
  • smartling-connector/trunk/readme.txt

    r3318909 r3320573  
    55Tested up to: 6.6.2
    66Requires PHP: 8.0
    7 Stable tag: 3.11.4
     7Stable tag: 3.11.6
    88License: GPLv2 or later
    99
     
    6363
    6464== Changelog ==
     65= 3.11.6 =
     66* Improve fix for Elementor Templates type mismatch after translation or cloning with Elementor Pro
     67
    6568= 3.11.5 =
    6669* Fixed Elementor Templates type mismatch after translation or cloning
  • smartling-connector/trunk/smartling-connector.php

    r3318909 r3320573  
    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:           3.11.5
     14 * Version:           3.11.6
    1515 * Author:            Smartling
    1616 * Author URI:        https://www.smartling.com
Note: See TracChangeset for help on using the changeset viewer.