Skip to content

Commit 1ec4543

Browse files
Merge pull request #540 from Smartling/WP-906-unicode
remove unneeded slash (WP-906)
2 parents 7bbcbcd + 08e828b commit 1ec4543

6 files changed

Lines changed: 18 additions & 10 deletions

File tree

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": "3.9.7",
4+
"version": "3.9.8",
55
"description": "",
66
"type": "wordpress-plugin",
77
"repositories": [

inc/Smartling/DbAl/WordpressContentEntities/PostEntityStd.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public function set(Entity $entity): int
222222
$this->getLogger()->debug(sprintf(
223223
'Calling wp_insert_post with postArray="%s", addSlashes=%s, currentBlogId=%d',
224224
json_encode($array),
225-
$addSlashes,
225+
$addSlashes ? '1' : '0',
226226
$this->wordpressFunctionProxyHelper->get_current_blog_id(),
227227
));
228228
$res = wp_insert_post($array, true);

inc/Smartling/Helpers/GutenbergBlockHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,10 +416,10 @@ public function renderGutenbergBlock(string $name, array $attrs, array $chunks,
416416
{
417417
/* Some user content might have JSON with \u0022 to escape quotes.
418418
After processing XML \u0022 turns into ", which is correct for general content.
419-
To properly encode the quotes in JSON again we replace " with \" */
419+
To properly encode the quotes in JSON again we replace " with " */
420420
if ($depth === 0 && $this->isPossibleJson($attrs)) {
421421
array_walk_recursive($attrs, static function (&$value) {
422-
$value = str_replace('"', '\"', $value);
422+
$value = str_replace('"', '"', $value);
423423
});
424424
}
425425
$attributes = '';

readme.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tags: translation, localization, localisation, translate, multilingual, smartlin
44
Requires at least: 5.5
55
Tested up to: 6.4.1
66
Requires PHP: 8.0
7-
Stable tag: 3.9.7
7+
Stable tag: 3.9.8
88
License: GPLv2 or later
99

1010
Translate content in WordPress quickly and seamlessly with Smartling, the industry-leading Translation Management System.
@@ -62,11 +62,14 @@ 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+
= 3.9.8 =
66+
* Fixed extra slashes being added in Gutenberg block attributes that had quotes after translation
67+
6568
= 3.9.7 =
66-
* Exclude strings that require no translation from upload
69+
* Excluded strings that require no translation from upload
6770

6871
= 3.9.6 =
69-
* Improve ACF content detection for Gutenberg blocks, the plugin should no longer apply translation to ACF fields that don't require translation, such as `select`, `choice` and similar fields.
72+
* Improved ACF content detection for Gutenberg blocks, the plugin should no longer apply translation to ACF fields that don't require translation, such as `select`, `choice` and similar fields.
7073

7174
= 3.9.5 =
7275
* Fixed submissions failing with "Batch is not suitable for adding files" error when uploading with related content

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: 3.9.7
14+
* Version: 3.9.8
1515
* Author: Smartling
1616
* Author URI: https://www.smartling.com
1717
* License: GPL-2.0+

tests/Smartling/Helpers/GutenbergBlockHelperTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,12 @@ public function placeBlockDataProvider(): array
307307
*/
308308
public function testRenderGutenbergBlock(string $blockName, array $attributes, array $chunks, string $expected, int $level = 0)
309309
{
310-
self::assertEquals($expected, $this->helper->renderGutenbergBlock($blockName, $attributes, $chunks, $level));
310+
$rendered = $this->helper->renderGutenbergBlock($blockName, $attributes, $chunks, $level);
311+
$matches = [];
312+
preg_match('~({.+}) /?-->~', $rendered, $matches);
313+
self::assertEquals($expected, $rendered);
314+
// Ensure json in attributes is valid
315+
json_decode($matches[1], true, 512, JSON_THROW_ON_ERROR);
311316
}
312317

313318
public function renderGutenbergBlockDataProvider(): array
@@ -375,7 +380,7 @@ public function renderGutenbergBlockDataProvider(): array
375380
'wework-blocks/geo-location',
376381
['showList' => '[{"value":"united-states","label":"United States"}]'],
377382
[],
378-
'<!-- wp:wework-blocks/geo-location {"showList":"[{\\\\\\"value\\\\\\":\\\\\\"united-states\\\\\\",\\\\\\"label\\\\\\":\\\\\\"United States\\\\\\"}]"} /-->',
383+
'<!-- wp:wework-blocks/geo-location {"showList":"[{\\"value\\":\\"united-states\\",\\"label\\":\\"United States\\"}]"} /-->',
379384
],
380385
'nested attributes' => [
381386
'acf/image-text-wrap',

0 commit comments

Comments
 (0)