diff --git a/composer.json b/composer.json index 41aa5d42..480e4344 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "smartling/wordpress-connector", "license": "GPL-2.0-or-later", - "version": "5.3.4", + "version": "5.3.5", "description": "", "type": "wordpress-plugin", "repositories": [ diff --git a/inc/Smartling/ContentTypes/Elementor/Elements/Gallery.php b/inc/Smartling/ContentTypes/Elementor/Elements/Gallery.php index 27f1ea19..d5866d54 100644 --- a/inc/Smartling/ContentTypes/Elementor/Elements/Gallery.php +++ b/inc/Smartling/ContentTypes/Elementor/Elements/Gallery.php @@ -43,6 +43,9 @@ public function getTranslatableStrings(): array public function setTargetContent(ExternalContentElementor $externalContentElementor, RelatedContentInfo $info, array $strings, SubmissionEntity $submission): static { + $this->raw = parent::setTargetContent($externalContentElementor, $info, $strings, $submission)->toArray(); + $this->settings = $this->raw['settings'] ?? []; + foreach ($strings[$this->id] ?? [] as $array) { if (is_array($array)) { foreach ($array as $id => $values) { diff --git a/inc/Smartling/ContentTypes/Elementor/Elements/Shortcode.php b/inc/Smartling/ContentTypes/Elementor/Elements/Shortcode.php new file mode 100644 index 00000000..e1dbc405 --- /dev/null +++ b/inc/Smartling/ContentTypes/Elementor/Elements/Shortcode.php @@ -0,0 +1,16 @@ +getId() => $this->getTranslatableStringsByKeys(['shortcode'])]; + } +} diff --git a/readme.txt b/readme.txt index d3386109..f1249c80 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.4 +Stable tag: 5.3.5 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.5 = +* Added support for Elementor shortcode widget + = 5.3.4 = * Added support for Elementor mega-menu widget diff --git a/smartling-connector.php b/smartling-connector.php index e3eb7628..7901779a 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.4 + * Version: 5.3.5 * Author: Smartling * Author URI: https://www.smartling.com * License: GPL-2.0+ diff --git a/tests/Smartling/ContentTypes/Elementor/ShortcodeTest.php b/tests/Smartling/ContentTypes/Elementor/ShortcodeTest.php new file mode 100644 index 00000000..e08b7b82 --- /dev/null +++ b/tests/Smartling/ContentTypes/Elementor/ShortcodeTest.php @@ -0,0 +1,58 @@ + 'abc123', + 'elType' => 'widget', + 'widgetType' => 'shortcode', + 'settings' => $settings, + 'elements' => [], + ]); + } + + public function testGetType(): void + { + $this->assertEquals('shortcode', $this->makeWidget()->getType()); + } + + public function testGetTranslatableStrings(): void + { + $shortcodeValue = '[contact-form-7 id="123" title="Contact form 1"]'; + $strings = $this->makeWidget(['shortcode' => $shortcodeValue])->getTranslatableStrings(); + + $this->assertEquals($shortcodeValue, $strings['abc123']['shortcode']); + } + + public function testGetTranslatableStringsEmpty(): void + { + $strings = $this->makeWidget()->getTranslatableStrings(); + + $this->assertEquals([], $strings['abc123']); + } + + public function testSetTargetContent(): void + { + $translatedShortcode = '[contact-form-7 id="123" title="Formulario de contacto 1"]'; + + $result = $this->makeWidget(['shortcode' => '[contact-form-7 id="123" title="Contact form 1"]']) + ->setTargetContent( + $this->createMock(ExternalContentElementor::class), + new RelatedContentInfo([]), + ['abc123' => ['shortcode' => $translatedShortcode]], + $this->createMock(SubmissionEntity::class), + )->toArray(); + + $this->assertEquals($translatedShortcode, $result['settings']['shortcode']); + } +}