From 0accb1bce87d9e8d5c33c83b4e191cc1e3454f62 Mon Sep 17 00:00:00 2001 From: Vitalii Solovei Date: Wed, 22 Apr 2026 15:02:06 +0200 Subject: [PATCH 1/4] add Elementor posts widget support (WP-999) Co-Authored-By: Claude Sonnet 4.6 --- .../ContentTypes/Elementor/Elements/Posts.php | 41 +++++++++ .../ContentTypes/Elementor/PostsTest.php | 92 +++++++++++++++++++ .../ExternalContentElementorTest.php | 16 +++- 3 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 inc/Smartling/ContentTypes/Elementor/Elements/Posts.php create mode 100644 tests/Smartling/ContentTypes/Elementor/PostsTest.php diff --git a/inc/Smartling/ContentTypes/Elementor/Elements/Posts.php b/inc/Smartling/ContentTypes/Elementor/Elements/Posts.php new file mode 100644 index 00000000..4efe408e --- /dev/null +++ b/inc/Smartling/ContentTypes/Elementor/Elements/Posts.php @@ -0,0 +1,41 @@ +getIntSettingByKey($key, $this->settings); + if ($id !== null) { + $return->addContent(new Content($id, ContentTypeHelper::CONTENT_TYPE_UNKNOWN), $this->id, "settings/$key"); + } + + return $return; + } + + public function getTranslatableStrings(): array + { + return [$this->getId() => $this->getTranslatableStringsByKeys([ + 'classic_read_more_text', + 'cards_read_more_text', + 'pagination_prev_label', + 'pagination_next_label', + 'text', + 'load_more_no_posts_custom_message', + 'loadmore_text', + 'loadmore_loading_text', + ])]; + } +} diff --git a/tests/Smartling/ContentTypes/Elementor/PostsTest.php b/tests/Smartling/ContentTypes/Elementor/PostsTest.php new file mode 100644 index 00000000..34887240 --- /dev/null +++ b/tests/Smartling/ContentTypes/Elementor/PostsTest.php @@ -0,0 +1,92 @@ + 'abc123', + 'elType' => 'widget', + 'widgetType' => 'posts', + 'settings' => $settings, + 'elements' => [], + ]); + } + + public function testGetType(): void + { + $this->assertEquals('posts', $this->makeWidget()->getType()); + } + + public function testGetTranslatableStrings(): void + { + $strings = $this->makeWidget([ + 'classic_read_more_text' => 'Read More »', + 'cards_read_more_text' => 'Read More »', + 'pagination_prev_label' => '« Previous', + 'pagination_next_label' => 'Next »', + 'text' => 'Load More', + 'load_more_no_posts_custom_message' => 'No more posts to show', + 'loadmore_text' => 'Load More', + 'loadmore_loading_text' => 'Loading...', + ])->getTranslatableStrings(); + + $this->assertEquals([ + 'classic_read_more_text' => 'Read More »', + 'cards_read_more_text' => 'Read More »', + 'pagination_prev_label' => '« Previous', + 'pagination_next_label' => 'Next »', + 'text' => 'Load More', + 'load_more_no_posts_custom_message' => 'No more posts to show', + 'loadmore_text' => 'Load More', + 'loadmore_loading_text' => 'Loading...', + ], $strings['abc123']); + } + + public function testGetTranslatableStringsEmpty(): void + { + $this->assertEquals([], $this->makeWidget()->getTranslatableStrings()['abc123']); + } + + public function testGetRelatedReturnsTemplateId(): void + { + $related = $this->makeWidget(['custom_skin_template' => '9165'])->getRelated(); + + $this->assertEquals( + [ContentTypeHelper::CONTENT_TYPE_UNKNOWN => [9165]], + $related->getRelatedContentList() + ); + } + + public function testGetRelatedNoTemplateReturnsEmpty(): void + { + $related = $this->makeWidget()->getRelated(); + + $this->assertEquals([], $related->getRelatedContentList()); + } + + public function testSetTargetContent(): void + { + $result = $this->makeWidget([ + 'text' => 'Load More', + 'loadmore_loading_text' => 'Loading...', + ])->setTargetContent( + $this->createMock(ExternalContentElementor::class), + new RelatedContentInfo([]), + ['abc123' => ['text' => 'Cargar más', 'loadmore_loading_text' => 'Cargando...']], + $this->createMock(SubmissionEntity::class), + )->toArray(); + + $this->assertEquals('Cargar más', $result['settings']['text']); + $this->assertEquals('Cargando...', $result['settings']['loadmore_loading_text']); + } +} diff --git a/tests/Smartling/ContentTypes/ExternalContentElementorTest.php b/tests/Smartling/ContentTypes/ExternalContentElementorTest.php index e886da55..e091064f 100644 --- a/tests/Smartling/ContentTypes/ExternalContentElementorTest.php +++ b/tests/Smartling/ContentTypes/ExternalContentElementorTest.php @@ -354,7 +354,21 @@ public function extractElementorDataProvider(): array 13574, ] ], - ] + ], + 'posts widget' => [ + '[{"id":"7a0e323","elType":"widget","settings":{"_skin":"custom","classic_read_more_text":"Read More »","cards_read_more_text":"Read More »","custom_skin_template":"9165","pagination_prev_label":"« Previous","pagination_next_label":"Next »","text":"Load More","load_more_no_posts_custom_message":"No more posts to show","loadmore_text":"Load More","loadmore_loading_text":"Loading..."},"elements":[],"widgetType":"posts"}]', + [ + '7a0e323/classic_read_more_text' => 'Read More »', + '7a0e323/cards_read_more_text' => 'Read More »', + '7a0e323/pagination_prev_label' => '« Previous', + '7a0e323/pagination_next_label' => 'Next »', + '7a0e323/text' => 'Load More', + '7a0e323/load_more_no_posts_custom_message' => 'No more posts to show', + '7a0e323/loadmore_text' => 'Load More', + '7a0e323/loadmore_loading_text' => 'Loading...', + ], + [ContentTypeHelper::CONTENT_TYPE_UNKNOWN => [9165]], + ], ]; } From 80fe72cde5f0e22478b5362b11f1689471c971cd Mon Sep 17 00:00:00 2001 From: Vitalii Solovei Date: Wed, 22 Apr 2026 15:08:41 +0200 Subject: [PATCH 2/4] bump version, add readme (WP-999) Co-Authored-By: Claude Sonnet 4.6 --- composer.json | 2 +- inc/Smartling/ContentTypes/Elementor/Elements/Posts.php | 1 - readme.txt | 5 ++++- smartling-connector.php | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 79b00bce..f71d6cbc 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "smartling/wordpress-connector", "license": "GPL-2.0-or-later", - "version": "5.3.5", + "version": "5.3.6", "description": "", "type": "wordpress-plugin", "repositories": [ diff --git a/inc/Smartling/ContentTypes/Elementor/Elements/Posts.php b/inc/Smartling/ContentTypes/Elementor/Elements/Posts.php index 4efe408e..3e4a2c5d 100644 --- a/inc/Smartling/ContentTypes/Elementor/Elements/Posts.php +++ b/inc/Smartling/ContentTypes/Elementor/Elements/Posts.php @@ -32,7 +32,6 @@ public function getTranslatableStrings(): array 'cards_read_more_text', 'pagination_prev_label', 'pagination_next_label', - 'text', 'load_more_no_posts_custom_message', 'loadmore_text', 'loadmore_loading_text', diff --git a/readme.txt b/readme.txt index f1249c80..985aa757 100755 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: translation, localization, multilingual, internationalization, smartling Requires at least: 5.5 Tested up to: 6.9 Requires PHP: 8.0 -Stable tag: 5.3.5 +Stable tag: 5.3.6 License: GPLv2 or later Translate content in WordPress quickly and seamlessly with Smartling, the industry-leading Translation Management System. @@ -62,6 +62,9 @@ Additional information on the Smartling Connector for WordPress can be found [he 3. Track translation status within WordPress from the Submissions Board. View overall progress of submitted translation requests as well as resend updated content. == Changelog == += 5.3.6 = +* Added support for Elementor posts widget + = 5.3.5 = * Added support for Elementor shortcode widget diff --git a/smartling-connector.php b/smartling-connector.php index 7901779a..5821dd48 100755 --- a/smartling-connector.php +++ b/smartling-connector.php @@ -11,7 +11,7 @@ * Plugin Name: Smartling Connector * Plugin URI: https://www.smartling.com/products/automate/integrations/wordpress/ * Description: Integrate your WordPress site with Smartling to upload your content and download translations. - * Version: 5.3.5 + * Version: 5.3.6 * Author: Smartling * Author URI: https://www.smartling.com * License: GPL-2.0+ From 9b0155c58012e27a4961f218b0726524f9cc4036 Mon Sep 17 00:00:00 2001 From: Vitalii Solovei Date: Wed, 22 Apr 2026 15:15:55 +0200 Subject: [PATCH 3/4] revert text change (WP-999) --- inc/Smartling/ContentTypes/Elementor/Elements/Posts.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inc/Smartling/ContentTypes/Elementor/Elements/Posts.php b/inc/Smartling/ContentTypes/Elementor/Elements/Posts.php index 3e4a2c5d..509274ba 100644 --- a/inc/Smartling/ContentTypes/Elementor/Elements/Posts.php +++ b/inc/Smartling/ContentTypes/Elementor/Elements/Posts.php @@ -27,11 +27,12 @@ public function getRelated(): RelatedContentInfo public function getTranslatableStrings(): array { - return [$this->getId() => $this->getTranslatableStringsByKeys([ + return [$this->id => $this->getTranslatableStringsByKeys([ 'classic_read_more_text', 'cards_read_more_text', 'pagination_prev_label', 'pagination_next_label', + 'text', 'load_more_no_posts_custom_message', 'loadmore_text', 'loadmore_loading_text', From bb66434da1e9ed4e673d1cf0363c9f7b6c7017dd Mon Sep 17 00:00:00 2001 From: Vitalii Solovei Date: Thu, 23 Apr 2026 15:42:00 +0200 Subject: [PATCH 4/4] add posts_include_term_ids processing to elementor posts widget (WP-999) Co-Authored-By: Claude Sonnet 4.6 --- .../ContentTypes/Elementor/Elements/Posts.php | 7 ++++ .../ContentTypes/Elementor/PostsTest.php | 36 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/inc/Smartling/ContentTypes/Elementor/Elements/Posts.php b/inc/Smartling/ContentTypes/Elementor/Elements/Posts.php index 509274ba..5731dc69 100644 --- a/inc/Smartling/ContentTypes/Elementor/Elements/Posts.php +++ b/inc/Smartling/ContentTypes/Elementor/Elements/Posts.php @@ -22,6 +22,13 @@ public function getRelated(): RelatedContentInfo $return->addContent(new Content($id, ContentTypeHelper::CONTENT_TYPE_UNKNOWN), $this->id, "settings/$key"); } + $key = 'posts_include_term_ids'; + foreach ($this->settings[$key] ?? [] as $index => $termId) { + if (is_numeric($termId)) { + $return->addContent(new Content((int)$termId, ContentTypeHelper::CONTENT_TYPE_TAXONOMY), $this->id, "settings/$key/$index"); + } + } + return $return; } diff --git a/tests/Smartling/ContentTypes/Elementor/PostsTest.php b/tests/Smartling/ContentTypes/Elementor/PostsTest.php index 34887240..a0825f8d 100644 --- a/tests/Smartling/ContentTypes/Elementor/PostsTest.php +++ b/tests/Smartling/ContentTypes/Elementor/PostsTest.php @@ -74,6 +74,42 @@ public function testGetRelatedNoTemplateReturnsEmpty(): void $this->assertEquals([], $related->getRelatedContentList()); } + public function testGetRelatedReturnsTermIds(): void + { + $related = $this->makeWidget(['posts_include_term_ids' => [42, 99]])->getRelated(); + + $this->assertEquals( + [ContentTypeHelper::CONTENT_TYPE_TAXONOMY => [42, 99]], + $related->getRelatedContentList() + ); + } + + public function testGetRelatedSkipsNonNumericTermIds(): void + { + $related = $this->makeWidget(['posts_include_term_ids' => ['invalid', 42]])->getRelated(); + + $this->assertEquals( + [ContentTypeHelper::CONTENT_TYPE_TAXONOMY => [42]], + $related->getRelatedContentList() + ); + } + + public function testGetRelatedReturnsBothTemplateAndTermIds(): void + { + $related = $this->makeWidget([ + 'custom_skin_template' => '9165', + 'posts_include_term_ids' => ["42", 99], + ])->getRelated(); + + $this->assertEquals( + [ + ContentTypeHelper::CONTENT_TYPE_UNKNOWN => [9165], + ContentTypeHelper::CONTENT_TYPE_TAXONOMY => [42, 99], + ], + $related->getRelatedContentList() + ); + } + public function testSetTargetContent(): void { $result = $this->makeWidget([