Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .claude/skills/bump-version/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: bump-version
description: Increase version number
---

1. Examine changes in the current git branch compared to master.
2. Decide if changes are minor, major or patch.
3. Update the smartling-connector.php comment that starts with `Version:` with the new version number.
4. Update the composer.json version with the new version number.
5. Update the readme.txt `Stable tag:` with the new version number and add the release notes.
Comment on lines +1 to +10
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Specify in description when it should be invoked (skills can be invoked automatically by claude harness form the current context). Like Use it when task is fully implemented or something like this.
  2. Not sure, maybe it already works, but I would like to add some semver description for it so that it clearly knows the rules when to up major vs minor vs patch versions.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "smartling/wordpress-connector",
"license": "GPL-2.0-or-later",
"version": "5.3.2",
"version": "5.3.3",
"description": "",
"type": "wordpress-plugin",
"repositories": [
Expand Down
63 changes: 63 additions & 0 deletions inc/Smartling/ContentTypes/Elementor/Elements/Gallery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

namespace Smartling\ContentTypes\Elementor\Elements;

use Smartling\ContentTypes\ContentTypeHelper;
use Smartling\ContentTypes\ExternalContentElementor;
use Smartling\Models\Content;
use Smartling\Models\RelatedContentInfo;
use Smartling\Submissions\SubmissionEntity;

class Gallery extends Unknown {
public function getType(): string
{
return 'gallery';
}

public function getRelated(): RelatedContentInfo
{
$return = parent::getRelated();
foreach ($this->settings['gallery'] ?? [] as $index => $listItem) {
$key = "gallery/$index/id";
$id = $this->getIntSettingByKey($key, $this->settings);
if ($id !== null) {
$return->addContent(new Content($id, ContentTypeHelper::POST_TYPE_ATTACHMENT), $this->id, "settings/$key");
}
}

return $return;
}

public function getTranslatableStrings(): array
{
$return = [];
foreach ($this->settings['galleries'] ?? [] as $gallery) {
$id = $gallery['_id'] ?? null;
if ($id !== null && array_key_exists('gallery_title', $gallery)) {
$return['galleries/' . $id]['gallery_title'] = $gallery['gallery_title'];
}
}

return [$this->getId() => $return];
}

public function setTargetContent(ExternalContentElementor $externalContentElementor, RelatedContentInfo $info, array $strings, SubmissionEntity $submission): static
{
foreach ($strings[$this->id] ?? [] as $array) {
if (is_array($array)) {
foreach ($array as $id => $values) {
foreach ($this->settings['galleries'] ?? [] as $index => $gallery) {
if (($gallery['_id'] ?? '') === $id) {
foreach ($values as $property => $value) {
$this->settings['galleries'][$index][$property] = $value;
}
}
}
}
}
}
$this->raw['settings'] = $this->settings;

return new static($this->raw);
}
}
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.2
Stable tag: 5.3.3
License: GPLv2 or later

Translate content in WordPress quickly and seamlessly with Smartling, the industry-leading Translation Management System.
Expand Down Expand Up @@ -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.3 =
* Added support for Elementor gallery widget

= 5.3.2 =
* Added support for Elementor nested accordion widget

Expand Down
2 changes: 1 addition & 1 deletion smartling-connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.2
* Version: 5.3.3
* Author: Smartling
* Author URI: https://www.smartling.com
* License: GPL-2.0+
Expand Down
84 changes: 84 additions & 0 deletions tests/Smartling/ContentTypes/Elementor/GalleryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php

namespace Smartling\ContentTypes\Elementor;

use PHPUnit\Framework\TestCase;
use Smartling\ContentTypes\ContentTypeHelper;
use Smartling\ContentTypes\Elementor\Elements\Gallery;
use Smartling\ContentTypes\ExternalContentElementor;
use Smartling\Models\Content;
use Smartling\Models\RelatedContentInfo;
use Smartling\Submissions\SubmissionEntity;

class GalleryTest extends TestCase
{
private function makeWidget(array $settings = []): Gallery
{
return new Gallery([
'id' => '14d5abc',
'elType' => 'widget',
'widgetType' => 'gallery',
'settings' => $settings,
'elements' => [],
]);
}

public function testRelated(): void
{
$imageSourceId = 21162;
$imageTargetId = 31162;

$externalContentElementor = $this->createMock(ExternalContentElementor::class);
$externalContentElementor->method('getTargetId')
->with(0, $imageSourceId, 0, ContentTypeHelper::POST_TYPE_ATTACHMENT)->willReturn($imageTargetId);

$this->assertEquals(
$imageTargetId,
$this->makeWidget(['gallery' => [
['id' => 21161, 'url' => 'https://example.com/1.webp'],
['id' => $imageSourceId, 'url' => 'https://example.com/2.webp'],
['id' => 21163, 'url' => 'https://example.com/3.webp'],
]])
->setRelations(
new Content($imageSourceId, ContentTypeHelper::POST_TYPE_ATTACHMENT),
$externalContentElementor,
'settings/gallery/1/id',
$this->createMock(SubmissionEntity::class),
)->toArray()['settings']['gallery'][1]['id'],
);
}

public function testGetTranslatableStrings(): void
{
$strings = $this->makeWidget(['galleries' => [
['gallery_title' => 'New Gallery', '_id' => '04c68ec'],
['gallery_title' => 'Second Gallery', '_id' => 'ab12345'],
]])->getTranslatableStrings();

$this->assertEquals('New Gallery', $strings['14d5abc']['galleries/04c68ec']['gallery_title']);
$this->assertEquals('Second Gallery', $strings['14d5abc']['galleries/ab12345']['gallery_title']);
}

public function testSetTargetContent(): void
{
$result = $this->makeWidget(['galleries' => [
['gallery_title' => 'New Gallery', '_id' => '04c68ec'],
['gallery_title' => 'Second Gallery', '_id' => 'ab12345'],
]])->setTargetContent(
$this->createMock(ExternalContentElementor::class),
new RelatedContentInfo([]),
[
'14d5abc' => [
'galleries' => [
'04c68ec' => ['gallery_title' => 'Translated Gallery'],
'ab12345' => ['gallery_title' => 'Translated Second'],
],
],
],
$this->createMock(SubmissionEntity::class),
)->toArray();

$this->assertEquals('Translated Gallery', $result['settings']['galleries'][0]['gallery_title']);
$this->assertEquals('Translated Second', $result['settings']['galleries'][1]['gallery_title']);
}
}
10 changes: 10 additions & 0 deletions tests/Smartling/ContentTypes/ExternalContentElementorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,16 @@ public function extractElementorDataProvider(): array
['abc123/text' => 'Click Me'],
[ContentTypeHelper::POST_TYPE_ATTACHMENT => [789]],
],
'gallery widget' => [
'[{"id":"14d5abc","elType":"widget","settings":{"gallery":[{"id":21161,"url":"https://example.com/1.webp"},{"id":21162,"url":"https://example.com/2.webp"}],"galleries":[{"gallery_title":"New Gallery","_id":"04c68ec"}]},"elements":[],"widgetType":"gallery"}]',
['14d5abc/galleries/04c68ec/gallery_title' => 'New Gallery'],
[ContentTypeHelper::POST_TYPE_ATTACHMENT => [21161, 21162]],
],
'nested accordion with svg icons' => [
'[{"id":"cf8c5a0","elType":"widget","settings":{"accordion_item_title_icon":{"value":{"url":"https://example.com/plus.svg","id":329},"library":"svg"},"accordion_item_title_icon_active":{"value":{"url":"https://example.com/minus.svg","id":330},"library":"svg"}},"elements":[],"widgetType":"nested-accordion"}]',
[],
[ContentTypeHelper::POST_TYPE_ATTACHMENT => [329, 330]],
],
'dynamic content in elements' => [
file_get_contents(__DIR__ . '/wp-975.json'),
[],
Expand Down
Loading