Changeset 3387552
- Timestamp:
- 10/31/2025 09:51:05 AM (5 months ago)
- Location:
- smartling-connector/trunk
- Files:
-
- 6 edited
-
inc/Smartling/Helpers/ContentHelper.php (modified) (1 diff)
-
inc/Smartling/Helpers/TestRunHelper.php (modified) (3 diffs)
-
inc/Smartling/WP/View/TestRun.php (modified) (1 diff)
-
inc/config/services.yml (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
smartling-connector.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
smartling-connector/trunk/inc/Smartling/Helpers/ContentHelper.php
r3077564 r3387552 108 108 } 109 109 110 /** 111 * @throws EntityNotFoundException 112 */ 110 113 public function readTargetContent(SubmissionEntity $submission): Entity 111 114 { -
smartling-connector/trunk/inc/Smartling/Helpers/TestRunHelper.php
r2644986 r3387552 3 3 namespace Smartling\Helpers; 4 4 5 use Smartling\DbAl\WordpressContentEntities\PostEntityStd; 6 use Smartling\Exception\EntityNotFoundException; 5 7 use Smartling\Exception\SmartlingTestRunCheckFailedException; 6 8 use Smartling\Models\GutenbergBlock; … … 10 12 { 11 13 public const TEST_RUN_BLOG_ID_SETTING_NAME = 'smartling_TestRunBlogId'; 12 private SiteHelper $siteHelper;13 private GutenbergBlockHelper $gutenbergBlockHelper;14 14 15 public function __construct( SiteHelper $siteHelper, GutenbergBlockHelper $gutenbergBlockHelper)16 {17 $this->siteHelper = $siteHelper;18 $this->gutenbergBlockHelper = $gutenbergBlockHelper;15 public function __construct( 16 private ContentHelper $contentHelper, 17 private GutenbergBlockHelper $gutenbergBlockHelper, 18 ) { 19 19 } 20 20 … … 26 26 public function checkDownloadedSubmission(SubmissionEntity $submission): void 27 27 { 28 $original = $this->siteHelper->withBlog($submission->getSourceBlogId(), function () use ($submission) { 29 return get_post($submission->getSourceId()); 30 }); 31 if (!$original instanceof \WP_Post) { 32 throw new SmartlingTestRunCheckFailedException("Unable to get source post while checking test run download blogId={$submission->getSourceBlogId()}, postId={$submission->getSourceId()}"); 28 try { 29 $original = $this->contentHelper->readSourceContent($submission); 30 } catch (EntityNotFoundException) { 31 throw new SmartlingTestRunCheckFailedException("Unable to get source content while checking test run download blogId={$submission->getSourceBlogId()}, postId={$submission->getSourceId()}"); 33 32 } 34 $target = $this->siteHelper->withBlog($submission->getTargetBlogId(), function () use ($submission) { 35 return get_post($submission->getTargetId()); 36 }); 37 if (!$target instanceof \WP_Post) { 38 throw new SmartlingTestRunCheckFailedException("Unable to get target post while checking test run download blogId={$submission->getTargetBlogId()}, postId={$submission->getTargetId()}"); 33 try { 34 $target = $this->contentHelper->readTargetContent($submission); 35 } catch (EntityNotFoundException) { 36 throw new SmartlingTestRunCheckFailedException("Unable to get target content while checking test run download blogId={$submission->getTargetBlogId()}, postId={$submission->getTargetId()}"); 39 37 } 40 $sourceBlocks = $this->gutenbergBlockHelper->getPostContentBlocks($original->post_content); 41 $targetBlocks = $this->gutenbergBlockHelper->getPostContentBlocks($target->post_content); 42 if (count($sourceBlocks) !== count($targetBlocks)) { 43 throw new SmartlingTestRunCheckFailedException("Source and target block count does not match"); 38 if ($original instanceof PostEntityStd && $target instanceof PostEntityStd) { 39 $sourceBlocks = $this->gutenbergBlockHelper->getPostContentBlocks($original->post_content); 40 $targetBlocks = $this->gutenbergBlockHelper->getPostContentBlocks($target->post_content); 41 if (count($sourceBlocks) !== count($targetBlocks)) { 42 throw new SmartlingTestRunCheckFailedException("Source and target block count does not match"); 43 } 44 $this->assertBlockStructureSame($sourceBlocks, $targetBlocks); 44 45 } 45 $this->assertBlockStructureSame($sourceBlocks, $targetBlocks);46 46 } 47 47 -
smartling-connector/trunk/inc/Smartling/WP/View/TestRun.php
r2862047 r3387552 101 101 if ($viewData->getNew() + $viewData->getInProgress() === 0) { 102 102 echo '<p>Test run has completed. You should now review the translated blog to check if strings everywhere are replaced with pseudo translations.</p>'; 103 if ($viewData->getTestBlogId() !== null) {104 echo sprintf('<form method="post" action="%s"><input type="hidden" name="action" value="%s" /><input type="submit" class="button action" value="Clear Test Run flag from blog" /><br />(to allow regular translations to be applied.)</form>', get_admin_url(null, 'admin.php?page=' . $this::SLUG), $this::ACTION_CLEAR_FLAG);105 }106 103 } else { 107 echo '<p>Test run is in progress. When there are no pending submissions, you should review the translated blog.'; 104 echo '<p>Test run is in progress. When there are no pending submissions, you should review the translated blog.</p>'; 105 } 106 if ($viewData->getTestBlogId() !== null) { 107 echo sprintf('<form method="post" action="%s"><input type="hidden" name="action" value="%s" /><input type="submit" class="button action" value="Clear Test Run flag from blog" /><br />(to allow regular translations to be applied.)</form>', get_admin_url(null, 'admin.php?page=' . $this::SLUG), $this::ACTION_CLEAR_FLAG); 108 108 } 109 109 } -
smartling-connector/trunk/inc/config/services.yml
r3351155 r3387552 322 322 class: Smartling\Helpers\TestRunHelper 323 323 arguments: 324 - "@ site.helper"324 - "@content.helper" 325 325 - "@helper.gutenberg" 326 326 -
smartling-connector/trunk/readme.txt
r3380258 r3387552 1 1 === Smartling Connector === 2 2 Contributors: smartling 3 Tags: translation, localization, localisation, translate, multilingual, smartling, internationalization, internationalisation, automation, international3 Tags: translation, localization, multilingual, internationalization, smartling 4 4 Requires at least: 5.5 5 5 Tested up to: 6.6.2 6 6 Requires PHP: 8.0 7 Stable tag: 4.4. 07 Stable tag: 4.4.1 8 8 License: GPLv2 or later 9 9 … … 63 63 64 64 == Changelog == 65 = 4.4.1 = 66 * Added possibility to clear the test run flag regardless of the test run status 67 * Fixed test run erroneously flagging taxonomy submissions as failed 68 65 69 = 4.4.0 = 66 70 * Added support for the Elementor Loop Carousel element -
smartling-connector/trunk/smartling-connector.php
r3380258 r3387552 12 12 * Plugin URI: https://www.smartling.com/products/automate/integrations/wordpress/ 13 13 * Description: Integrate your WordPress site with Smartling to upload your content and download translations. 14 * Version: 4.4. 014 * Version: 4.4.1 15 15 * Author: Smartling 16 16 * Author URI: https://www.smartling.com
Note: See TracChangeset
for help on using the changeset viewer.