Changeset 3320573
- Timestamp:
- 07/01/2025 11:35:35 AM (8 months ago)
- Location:
- smartling-connector/trunk
- Files:
-
- 4 edited
-
inc/Smartling/ContentTypes/ExternalContentElementor.php (modified) (5 diffs)
-
inc/Smartling/ContentTypes/ExternalContentGravityForms.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
smartling-connector.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
smartling-connector/trunk/inc/Smartling/ContentTypes/ExternalContentElementor.php
r3318909 r3320573 4 4 5 5 use Elementor\Core\Documents_Manager; 6 use Elementor \TemplateLibrary\Source_Local;6 use ElementorPro\Plugin; 7 7 use Smartling\Base\ExportedAPI; 8 8 use Smartling\ContentTypes\Elementor\ElementFactory; … … 70 70 return; 71 71 } 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) { 80 73 $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 ($documentsManager Path, $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) { 85 78 try { 86 require_once $documentsManagerPath;87 $manager = new Documents_Manager();88 do_action('elementor/documents/register', $manager);89 79 /** @noinspection PhpParamsInspection */ 90 $ manager->ajax_save([80 $documentsManager->ajax_save([ 91 81 'editor_post_id' => $submission->getTargetId(), 92 82 'elements' => json_decode($this->getDataFromPostMeta($submission->getTargetId()), … … 101 91 }); 102 92 } 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 }119 93 }); 120 94 $this->getLogger()->info("Done processing Elementor after content written hook"); … … 196 170 { 197 171 return $this->getData($this->readMeta($contentId))->getRelatedContentInfo()->getRelatedContentList(); 198 }199 200 public function ensureSubmissionForRelatedTerm(SubmissionEntity $submission, \WP_Term $term): ?SubmissionEntity201 {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;218 172 } 219 173 … … 252 206 return $translation; 253 207 } 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 } 254 232 } -
smartling-connector/trunk/inc/Smartling/ContentTypes/ExternalContentGravityForms.php
r3294670 r3320573 62 62 || ($this->contentTypeHelper->isPost($contentType) 63 63 && str_contains( 64 $this->wpProxy->get_post($contentId)->post_content ,64 $this->wpProxy->get_post($contentId)->post_content ?? '', 65 65 'gravityforms', 66 66 ))) { -
smartling-connector/trunk/readme.txt
r3318909 r3320573 5 5 Tested up to: 6.6.2 6 6 Requires PHP: 8.0 7 Stable tag: 3.11. 47 Stable tag: 3.11.6 8 8 License: GPLv2 or later 9 9 … … 63 63 64 64 == Changelog == 65 = 3.11.6 = 66 * Improve fix for Elementor Templates type mismatch after translation or cloning with Elementor Pro 67 65 68 = 3.11.5 = 66 69 * Fixed Elementor Templates type mismatch after translation or cloning -
smartling-connector/trunk/smartling-connector.php
r3318909 r3320573 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: 3.11. 514 * Version: 3.11.6 15 15 * Author: Smartling 16 16 * Author URI: https://www.smartling.com
Note: See TracChangeset
for help on using the changeset viewer.