Skip to content

Commit ad248d7

Browse files
bump version, add readme, simplify code (WP-967)
1 parent 26dee16 commit ad248d7

File tree

6 files changed

+25
-27
lines changed

6 files changed

+25
-27
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "smartling/wordpress-connector",
33
"license": "GPL-2.0-or-later",
4-
"version": "4.4.1",
4+
"version": "5.0.0",
55
"description": "",
66
"type": "wordpress-plugin",
77
"repositories": [

inc/Smartling/Models/UserTranslationRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function isBulk(): bool
4747
return count($this->ids) > 0;
4848
}
4949

50-
private static function validate(array $array)
50+
private static function validate(array $array): void
5151
{
5252
if (!array_key_exists('source', $array)) {
5353
throw new \InvalidArgumentException('Source array required');

inc/Smartling/Services/ContentRelationsDiscoveryService.php

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,12 @@ public function createSubmissions(UserTranslationRequest $request): void
217217

218218
$relatedIds = [];
219219
try {
220-
foreach ($request->getRelationsOrdered() as $relations) {
221-
foreach ($relations as $content) {
222-
foreach ($content as $contentType => $contentIds) {
223-
if (!array_key_exists($contentType, $relatedIds)) {
224-
$relatedIds[$contentType] = [];
225-
}
226-
$relatedIds[$contentType] = array_merge($relatedIds[$contentType], $contentIds);
220+
foreach ($request->getRelationsOrdered() as $content) {
221+
foreach ($content as $contentType => $contentIds) {
222+
if (!array_key_exists($contentType, $relatedIds)) {
223+
$relatedIds[$contentType] = [];
227224
}
225+
$relatedIds[$contentType] = array_merge($relatedIds[$contentType], $contentIds);
228226
}
229227
}
230228
foreach ($relatedIds as $contentType => $contentIds) {
@@ -568,9 +566,7 @@ public function getRelations(string $contentType, int $id, array $targetBlogIds)
568566
$detectedReferences = $this->normalizeReferences($detectedReferences);
569567
$this->getLogger()->debug('References after normalizing: ' . json_encode($detectedReferences));
570568

571-
$responseData = new DetectedRelations($detectedReferences);
572-
573-
return $responseData;
569+
return new DetectedRelations($detectedReferences);
574570
}
575571

576572
public function normalizeReferences(array $references): array
@@ -666,17 +662,16 @@ private function getSources(UserCloneRequest $request, int $targetBlogId): array
666662
{
667663
$sources = [];
668664

669-
foreach ($request->getRelationsOrdered() as $relationSet) {
670-
foreach (($relationSet[$targetBlogId] ?? []) as $type => $ids) {
671-
foreach ($ids as $id) {
672-
if ($id === $request->getContentId() && $type === $request->getContentType()) {
673-
$this->getLogger()->info("Related list contains reference to root content, skip adding sourceId=$id, contentType=$type to sources list");
674-
} else {
675-
$sources[] = [
676-
'id' => $id,
677-
'type' => $type,
678-
];
679-
}
665+
$relationSet = $request->getRelationsOrdered();
666+
foreach (($relationSet[$targetBlogId] ?? []) as $type => $ids) {
667+
foreach ($ids as $id) {
668+
if ($id === $request->getContentId() && $type === $request->getContentType()) {
669+
$this->getLogger()->info("Related list contains reference to root content, skip adding sourceId=$id, contentType=$type to sources list");
670+
} else {
671+
$sources[] = [
672+
'id' => $id,
673+
'type' => $type,
674+
];
680675
}
681676
}
682677
}

inc/Smartling/WP/View/ContentEditJob.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ function (i, e) {
538538

539539
switch ($('#cloneDepth').val()) {
540540
case "1":
541-
data.relations = {1: prepareRequest(l1Relations.originalReferences)};
541+
data.relations = prepareRequest(l1Relations.originalReferences);
542542
break;
543543
case "2":
544544
const mergedOriginal = {...l1Relations.originalReferences};
@@ -549,7 +549,7 @@ function (i, e) {
549549
mergedOriginal[type] = l2Relations.originalReferences[type];
550550
}
551551
}
552-
data.relations = {1: prepareRequest(l1Relations.originalReferences), 2: prepareRequest(l2Relations.originalReferences)};
552+
data.relations = prepareRequest(mergedOriginal);
553553
break;
554554
}
555555
}

readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tags: translation, localization, multilingual, internationalization, smartling
44
Requires at least: 5.5
55
Tested up to: 6.6.2
66
Requires PHP: 8.0
7-
Stable tag: 4.4.1
7+
Stable tag: 5.0.0
88
License: GPLv2 or later
99

1010
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
6262
3. Track translation status within WordPress from the Submissions Board. View overall progress of submitted translation requests as well as resend updated content.
6363

6464
== Changelog ==
65+
= 5.0.0 =
66+
* Related assets will now be processed for translation when the content is submitted from the widget, even if they were previously sent for translation
67+
6568
= 4.4.1 =
6669
* Added possibility to clear the test run flag regardless of the test run status
6770
* Fixed test run erroneously flagging taxonomy submissions as failed

smartling-connector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Plugin Name: Smartling Connector
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: 4.4.1
14+
* Version: 5.0.0
1515
* Author: Smartling
1616
* Author URI: https://www.smartling.com
1717
* License: GPL-2.0+

0 commit comments

Comments
 (0)