Changeset 3441087
- Timestamp:
- 01/16/2026 03:02:11 PM (3 months ago)
- Location:
- smartling-connector/trunk
- Files:
-
- 2 added
- 53 edited
-
inc/Smartling/Base/SmartlingCore.php (modified) (1 diff)
-
inc/Smartling/Bootstrap.php (modified) (2 diffs)
-
inc/Smartling/ContentTypes/CustomPostType.php (modified) (1 diff)
-
inc/Smartling/ContentTypes/CustomTaxonomyType.php (modified) (2 diffs)
-
inc/Smartling/ContentTypes/Elementor/ElementAbstract.php (modified) (1 diff)
-
inc/Smartling/ContentTypes/Elementor/Elements/LoopCarousel.php (modified) (2 diffs)
-
inc/Smartling/ContentTypes/Elementor/Elements/Unknown.php (modified) (1 diff)
-
inc/Smartling/ContentTypes/Elementor/Elements/Video.php (added)
-
inc/Smartling/DbAl/WordpressContentEntities/EntityAbstract.php (modified) (1 diff)
-
inc/Smartling/DbAl/WordpressContentEntities/PostEntityStd.php (modified) (3 diffs)
-
inc/Smartling/DbAl/WordpressContentEntities/TaxonomyEntityStd.php (modified) (1 diff)
-
inc/Smartling/Helpers/ContentHelper.php (modified) (2 diffs)
-
inc/Smartling/Helpers/FileUriHelper.php (modified) (2 diffs)
-
inc/Smartling/Helpers/WordpressFunctionProxyHelper.php (modified) (2 diffs)
-
inc/Smartling/Models/RelatedContentInfo.php (modified) (1 diff)
-
inc/Smartling/Services/ContentRelationsDiscoveryService.php (modified) (5 diffs)
-
inc/Smartling/WP/Controller/AdminPage.php (modified) (1 diff)
-
inc/Smartling/WP/Controller/BulkSubmitController.php (modified) (4 diffs)
-
inc/Smartling/WP/Controller/CheckStatusController.php (modified) (4 diffs)
-
inc/Smartling/WP/Controller/ConfigurationProfileFormController.php (modified) (3 diffs)
-
inc/Smartling/WP/Controller/ConfigurationProfilesController.php (modified) (4 diffs)
-
inc/Smartling/WP/Controller/ContentEditJobController.php (modified) (8 diffs)
-
inc/Smartling/WP/Controller/ControllerAbstract.php (modified) (1 diff)
-
inc/Smartling/WP/Controller/DuplicateSubmissionsCleaner.php (modified) (1 diff)
-
inc/Smartling/WP/Controller/FilterForm.php (modified) (1 diff)
-
inc/Smartling/WP/Controller/PostBasedWidgetControllerStd.php (modified) (5 diffs)
-
inc/Smartling/WP/Controller/ShortcodeForm.php (modified) (1 diff)
-
inc/Smartling/WP/Controller/SubmissionsPageController.php (modified) (2 diffs)
-
inc/Smartling/WP/Controller/TaxonomyLinksController.php (modified) (3 diffs)
-
inc/Smartling/WP/Controller/TaxonomyWidgetController.php (modified) (2 diffs)
-
inc/Smartling/WP/Controller/TestRunController.php (modified) (5 diffs)
-
inc/Smartling/WP/Controller/TranslationLockController.php (modified) (6 diffs)
-
inc/Smartling/WP/View/AdminPage.php (modified) (2 diffs)
-
inc/Smartling/WP/View/BulkSubmit.php (modified) (3 diffs)
-
inc/Smartling/WP/View/ConfigurationProfileForm.php (modified) (4 diffs)
-
inc/Smartling/WP/View/ConfigurationProfiles.php (modified) (1 diff)
-
inc/Smartling/WP/View/ContentEditJob.php (modified) (3 diffs)
-
inc/Smartling/WP/View/DuplicateSubmissionsCleaner.php (modified) (2 diffs)
-
inc/Smartling/WP/View/FilterForm.php (modified) (1 diff)
-
inc/Smartling/WP/View/PostBasedWidgetStd.php (modified) (1 diff)
-
inc/Smartling/WP/View/ShortcodeForm.php (modified) (1 diff)
-
inc/Smartling/WP/View/SubmissionsPage.php (modified) (1 diff)
-
inc/Smartling/WP/View/TaxonomyLinks.php (modified) (1 diff)
-
inc/Smartling/WP/View/TaxonomyWidget.php (modified) (1 diff)
-
inc/Smartling/WP/View/TestRun.php (modified) (1 diff)
-
inc/Smartling/WP/View/TranslationLock.php (modified) (4 diffs)
-
inc/Smartling/WP/View/post-based-content-type.php (modified) (3 diffs)
-
inc/Smartling/WP/View/taxonomy-based-content-type.php (modified) (1 diff)
-
inc/Smartling/WP/WPAbstract.php (modified) (4 diffs)
-
inc/config/logger.yml (modified) (1 diff)
-
inc/config/plugin-info.yml (modified) (1 diff)
-
inc/config/services.yml (modified) (6 diffs)
-
js/app.js (added)
-
readme.txt (modified) (2 diffs)
-
smartling-connector.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
smartling-connector/trunk/inc/Smartling/Base/SmartlingCore.php
r3415470 r3441087 253 253 } 254 254 255 /**256 * @param ConfigurationProfileEntity $profile257 *258 * @return array259 */260 public function getProjectLocales(ConfigurationProfileEntity $profile)261 {262 $cacheKey = 'profile.locales.' . $profile->getId();263 $cached = $this->getCache()->get($cacheKey);264 265 if (false === $cached) {266 $cached = $this->getApiWrapper()->getSupportedLocales($profile);267 $this->getCache()->set($cacheKey, $cached);268 }269 270 return $cached;271 }272 273 255 public function handleBadBlogId(SubmissionEntity $submission) 274 256 { -
smartling-connector/trunk/inc/Smartling/Bootstrap.php
r3415470 r3441087 16 16 use Smartling\Exception\SmartlingBootException; 17 17 use Smartling\Exception\SmartlingConfigException; 18 use Smartling\Extensions\Acf\AcfDynamicSupport;19 18 use Smartling\Helpers\DiagnosticsHelper; 20 19 use Smartling\Helpers\MetaFieldProcessor\CustomFieldFilterHandler; … … 430 429 (new Taxonomies($di->getParameter('ignoredTypes')['taxonomies'] ?? []))->registerHookHandler(); 431 430 (new PostTypes($di->getParameter('ignoredTypes')['posts'] ?? []))->registerHookHandler(); 431 432 add_action('admin_enqueue_scripts', static function () { 433 wp_enqueue_script('wp-element'); 434 wp_enqueue_script('wp-components'); 435 wp_enqueue_script('wp-date'); 436 wp_enqueue_script( 437 'smartling-react-app', 438 plugin_dir_url(__FILE__) . '../../js/app.js', 439 ['wp-element', 'wp-components', 'wp-date'], 440 static::$pluginVersion, 441 true, 442 ); 443 wp_enqueue_style('wp-components'); 444 }); 432 445 433 446 $action = defined('DOING_CRON') && true === DOING_CRON ? 'wp_loaded' : 'admin_init'; -
smartling-connector/trunk/inc/Smartling/ContentTypes/CustomPostType.php
r2932593 r3441087 89 89 $di 90 90 ->register($tag, ContentEditJobController::class) 91 ->addArgument($di->getDefinition('api.wrapper.with.retries')) 91 92 ->addArgument($di->getDefinition('multilang.proxy')) 92 93 ->addArgument($di->getDefinition('plugin.info')) -
smartling-connector/trunk/inc/Smartling/ContentTypes/CustomTaxonomyType.php
r2932593 r3441087 68 68 $di 69 69 ->register($tag, TaxonomyWidgetController::class) 70 ->addArgument($di->getDefinition('api.wrapper.with.retries')) 70 71 ->addArgument($di->getDefinition('multilang.proxy')) 71 72 ->addArgument($di->getDefinition('plugin.info')) … … 88 89 $di 89 90 ->register($tag, ContentEditJobController::class) 91 ->addArgument($di->getDefinition('api.wrapper.with.retries')) 90 92 ->addArgument($di->getDefinition('multilang.proxy')) 91 93 ->addArgument($di->getDefinition('plugin.info')) -
smartling-connector/trunk/inc/Smartling/ContentTypes/Elementor/ElementAbstract.php
r3418195 r3441087 132 132 $arrayHelper = new ArrayHelper(); 133 133 $result = clone $this; 134 $contentType = $content->getType() === ContentTypeHelper::CONTENT_TYPE_POST ? 135 $externalContentElementor->getWpProxy()->get_post_type($content->getId()) : 136 $content->getType(); 134 135 $wpProxy = $externalContentElementor->getWpProxy(); 136 if ($content->getType() === ContentTypeHelper::CONTENT_TYPE_POST) { 137 $contentType = $wpProxy->get_post_type($content->getId()); 138 } elseif ($content->getType() === ContentTypeHelper::CONTENT_TYPE_TAXONOMY) { 139 $term = $wpProxy->getTerm($content->getId()); 140 $contentType = (is_array($term) && isset($term['taxonomy'])) ? $term['taxonomy'] : $content->getType(); 141 } else { 142 $contentType = $content->getType(); 143 } 144 137 145 if ($contentType === false) { 138 $this->getLogger()->debug("Unable to get post type for contentId={$content->getId()}, proceeding with unknown type");146 $this->getLogger()->debug("Unable to get content type for contentId={$content->getId()}, proceeding with unknown type"); 139 147 $contentType = ContentTypeHelper::CONTENT_TYPE_UNKNOWN; 140 148 } -
smartling-connector/trunk/inc/Smartling/ContentTypes/Elementor/Elements/LoopCarousel.php
r3380258 r3441087 4 4 5 5 use Smartling\ContentTypes\ContentTypeHelper; 6 use Smartling\ContentTypes\ExternalContentElementor;7 6 use Smartling\Models\Content; 8 7 use Smartling\Models\RelatedContentInfo; 9 use Smartling\Submissions\SubmissionEntity;10 8 11 9 class LoopCarousel extends Unknown { … … 24 22 } 25 23 24 foreach ($this->settings['post_query_include_term_ids'] ?? [] as $index => $termId) { 25 if (is_numeric($termId)) { 26 $return->addContent(new Content((int)$termId, ContentTypeHelper::CONTENT_TYPE_TAXONOMY), $this->id, "settings/post_query_include_term_ids/$index"); 27 } 28 } 29 26 30 return $return; 27 31 } -
smartling-connector/trunk/inc/Smartling/ContentTypes/Elementor/Elements/Unknown.php
r3418195 r3441087 18 18 { 19 19 $return = new RelatedContentInfo(); 20 $keys = ['background_image/id']; 20 $keys = [ 21 'background_image/id', 22 'background_overlay_image/id', 23 'background_overlay_image_mobile/id', 24 ]; 21 25 foreach ($this->elements as $element) { 22 26 if ($element instanceof Element) { -
smartling-connector/trunk/inc/Smartling/DbAl/WordpressContentEntities/EntityAbstract.php
r3338937 r3441087 125 125 throw new \BadMethodCallException(sprintf("Method $method does not exists in class '%s'", get_class($this))); 126 126 } 127 } 128 129 public function getEditLink(): ?string 130 { 131 return null; 127 132 } 128 133 -
smartling-connector/trunk/inc/Smartling/DbAl/WordpressContentEntities/PostEntityStd.php
r3338937 r3441087 39 39 class PostEntityStd extends EntityAbstract implements EntityWithPostStatus, EntityWithMetadata 40 40 { 41 private WordpressFunctionProxyHelper $wordpressFunctionProxyHelper;42 41 /** 43 42 * Standard 'post' content-type fields … … 69 68 ]; 70 69 71 public function __construct($type = 'post', array $related = [], ?WordpressFunctionProxyHelper $wordpressFunctionProxyHelper = null) 72 { 70 public function __construct( 71 string $type = 'post', 72 array $related = [], 73 private ?WordpressFunctionProxyHelper $wordpressFunctionProxyHelper = null, 74 ) { 73 75 parent::__construct(); 74 76 $this->setType($type); … … 98 100 { 99 101 return 'post_type'; 102 } 103 104 public function getEditLink(): ?string 105 { 106 return $this->wordpressFunctionProxyHelper->get_edit_post_link($this->ID); 100 107 } 101 108 -
smartling-connector/trunk/inc/Smartling/DbAl/WordpressContentEntities/TaxonomyEntityStd.php
r3338937 r3441087 37 37 38 38 private WordpressFunctionProxyHelper $wordpressProxy; 39 40 public function getEditLink(): ?string 41 { 42 return $this->wordpressProxy->get_edit_term_link($this->getPK()); 43 } 39 44 40 45 public function getMetadata(): array -
smartling-connector/trunk/inc/Smartling/Helpers/ContentHelper.php
r3387552 r3441087 12 12 use Smartling\DbAl\WordpressContentEntities\VirtualEntityAbstract; 13 13 use Smartling\Exception\EntityNotFoundException; 14 use Smartling\Exception\SmartlingInvalidFactoryArgumentException; 14 15 use Smartling\Processors\ContentEntitiesIOFactory; 15 16 use Smartling\Submissions\SubmissionEntity; … … 80 81 } 81 82 83 /** 84 * @throws SmartlingInvalidFactoryArgumentException 85 */ 82 86 public function getWrapper(string $contentType): EntityHandler 83 87 { 84 $return = clone $this->getIoFactory()->getHandler($contentType); 85 if (!$return instanceof EntityHandler) { 86 throw new \RuntimeException("Handler for $contentType expected to be " . EntityHandler::class . ", factory returned " . get_class($return)); 88 try { 89 $return = clone $this->getIoFactory()->getHandler($contentType); 90 if (!$return instanceof EntityHandler) { 91 throw new \RuntimeException("Handler for $contentType expected to be " . EntityHandler::class . ", factory returned " . get_class($return)); 92 } 93 } catch (SmartlingInvalidFactoryArgumentException $e) { 94 try { 95 return $this->getHandler($contentType); 96 } catch (\RuntimeException) { 97 throw $e; 98 } 87 99 } 88 100 89 101 return $return; 102 } 103 104 public function getHandler(string $type): PostEntityStd|TaxonomyEntityStd 105 { 106 if ($this->wordpressFunctionProxyHelper->post_type_exists($type)) { 107 return new PostEntityStd($type, wordpressFunctionProxyHelper: $this->wordpressFunctionProxyHelper); 108 } 109 if ($this->wordpressFunctionProxyHelper->taxonomy_exists($type)) { 110 return new TaxonomyEntityStd($type, wordpressProxy: $this->wordpressFunctionProxyHelper); 111 } 112 throw new \RuntimeException("Unknown content type: $type"); 90 113 } 91 114 -
smartling-connector/trunk/inc/Smartling/Helpers/FileUriHelper.php
r3096059 r3441087 22 22 23 23 public function __construct( 24 private Content EntitiesIOFactory $ioFactory,24 private ContentHelper $contentHelper, 25 25 private SiteHelper $siteHelper, 26 26 ) { 27 27 } 28 28 29 /**30 * @throws SmartlingInvalidFactoryArgumentException31 * @throws SmartlingConfigException32 */33 29 private function buildFileUri(Submission $submission): string { 34 try { 35 $wrapper = $this->ioFactory->getMapper($submission->getContentType()); 36 } catch (SmartlingInvalidFactoryArgumentException $e) { 37 $this->getLogger()->notice(sprintf( 38 'ContentType=%s is not registered, expected one of %s', 39 $submission->getContentType(), 40 implode(',' , array_keys($this->ioFactory->getCollection())) 41 )); 42 throw $e; 43 } 30 $wrapper = $this->contentHelper->getHandler($submission->getContentType()); 44 31 if ($wrapper instanceof TaxonomyEntityStd) { 45 32 $permalink = $this->preparePermalink(get_term_link($submission->getSourceId()), $submission->getSourceTitle()); … … 60 47 61 48 /** 62 * @throws SmartlingInvalidFactoryArgumentException63 49 * @throws BlogNotFoundException 64 * @throws SmartlingConfigException65 50 * @throws SmartlingDirectRunRuntimeException 66 51 */ -
smartling-connector/trunk/inc/Smartling/Helpers/WordpressFunctionProxyHelper.php
r3418195 r3441087 52 52 } 53 53 54 public function post_type_exists() 55 { 56 return post_type_exists(...func_get_args()); 57 } 58 59 public function taxonomy_exists() 60 { 61 return taxonomy_exists(...func_get_args()); 62 } 63 54 64 public function get_post_types() 55 65 { … … 160 170 { 161 171 return get_term(...func_get_args()); 172 } 173 174 public function getTerm(int $termId): array|null|\WP_Error 175 { 176 return get_term($termId, '', ARRAY_A); 162 177 } 163 178 -
smartling-connector/trunk/inc/Smartling/Models/RelatedContentInfo.php
r3377267 r3441087 41 41 } 42 42 43 /**44 * @return Content[]45 */46 43 public function getRelatedContentList(): array 47 44 { -
smartling-connector/trunk/inc/Smartling/Services/ContentRelationsDiscoveryService.php
r3408250 r3441087 16 16 use Smartling\Exception\SmartlingGutenbergParserNotFoundException; 17 17 use Smartling\Exception\SmartlingHumanReadableException; 18 use Smartling\Exception\SmartlingInvalidFactoryArgumentException;19 18 use Smartling\Extensions\Acf\AcfDynamicSupport; 20 19 use Smartling\Helpers\AbsoluteLinkedAttachmentCoreHelper; … … 298 297 } 299 298 300 try { 301 $submission->setFileUri($this->fileUriHelper->generateFileUri($submission)); 302 $submission = $this->storeWithJobInfo($submission, $jobInfo, $request->getDescription()); 303 $fileUris[] = $submission->getFileUri(); 304 $queueIds[] = $submission->getId(); 305 } catch (SmartlingInvalidFactoryArgumentException) { 306 $this->getLogger()->info("Skipping submission because no mapper was found: contentType={$submission->getContentType()} sourceBlogId={$submission->getSourceBlogId()}, sourceId={$submission->getSourceId()}, targetBlogId={$submission->getTargetBlogId()}"); 307 } 299 $submission->setFileUri($this->fileUriHelper->generateFileUri($submission)); 300 $submission = $this->storeWithJobInfo($submission, $jobInfo, $request->getDescription()); 301 $fileUris[] = $submission->getFileUri(); 302 $queueIds[] = $submission->getId(); 308 303 } 309 304 } … … 608 603 } 609 604 610 if (isset($references[self::TERM_BASED_PROCESSOR])) { 611 $termTypeIds = $references[self::TERM_BASED_PROCESSOR]; 612 foreach ($termTypeIds as $termTypeId) { 613 $term = get_term($termTypeId, '', \ARRAY_A); 614 if (is_array($term)) { 615 $result[$term['taxonomy']][] = $termTypeId; 616 } 605 foreach (array_merge($references[self::TERM_BASED_PROCESSOR] ?? [], $references[ContentTypeHelper::CONTENT_TYPE_TAXONOMY] ?? []) as $termTypeId) { 606 $term = $this->wordpressProxy->getTerm((int)$termTypeId); 607 if (is_array($term)) { 608 $result[$term['taxonomy']][] = $termTypeId; 617 609 } 618 610 } … … 652 644 { 653 645 try { 654 return $this->contentHelper->readSourceContent($submission)->getTitle(); 646 return $this->contentHelper->getHandler($submission->getContentType())->get($submission->getSourceId()) 647 ->getTitle(); 655 648 } catch (\Exception $e) { 656 649 $this->getLogger()->notice(sprintf('Unable to get content title for submissionId=%d, sourceBlogId=%d, sourceId=%d, type="%s"', $submission->getId(), $submission->getSourceBlogId(), $submission->getSourceId(), $submission->getContentType())); … … 778 771 $thumbnailUrl = ''; 779 772 try { 780 switch ($type) { 781 /** @noinspection PhpMissingBreakStatementInspection */ 782 case 'attachment': 783 $thumbnailUrl = $this->wordpressProxy->wp_get_attachment_image_url($id) ?: ''; 784 // fallthrough intentional 785 case 'page': 786 case 'post': 787 $post = $this->wordpressProxy->get_post($id); 788 if ($post === null) { 789 continue 2; 790 } 791 $title = $this->wordpressProxy->get_post($id)->post_title; 792 $url = $this->wordpressProxy->get_edit_post_link($id); 793 break; 794 default: 795 $term = $this->wordpressProxy->get_term($id); 796 if ($term instanceof \WP_Term) { 797 $title = $term->name; 798 $url = $this->wordpressProxy->get_edit_term_link($id, $type); 799 } else { 800 continue 2; 801 } 773 if ($type === 'attachment') { 774 $thumbnailUrl = $this->wordpressProxy->wp_get_attachment_image_url($id) ?: ''; 775 } 776 777 $handler = $this->contentHelper->getHandler($type); 778 try { 779 $entity = $handler->get($id); 780 $title = $entity->getTitle(); 781 $url = $entity->getEditLink(); 782 } 783 catch (EntityNotFoundException) { 784 continue; 802 785 } 803 786 } catch (\Exception) { -
smartling-connector/trunk/inc/Smartling/WP/Controller/AdminPage.php
r2862047 r3441087 135 135 } 136 136 137 $this->setViewData( 138 [ 139 'shortcodes' => new ShortcodeTableClass(new ShortcodeManager()), 140 'filters' => new LocalizationRulesTableWidget(new FilterManager()), 141 'media' => new MediaAttachmentTableWidget($this->mediaAttachmentRulesManager, $this->replacerFactory), 142 ] 143 ); 137 $this->viewData = [ 138 'shortcodes' => new ShortcodeTableClass(new ShortcodeManager()), 139 'filters' => new LocalizationRulesTableWidget(new FilterManager()), 140 'media' => new MediaAttachmentTableWidget($this->mediaAttachmentRulesManager, $this->replacerFactory), 141 ]; 144 142 $this->renderScript(); 145 143 } -
smartling-connector/trunk/inc/Smartling/WP/Controller/BulkSubmitController.php
r3338937 r3441087 24 24 public function __construct( 25 25 private AcfDynamicSupport $acfDynamicSupport, 26 pr ivate ApiWrapperInterface $apiWrapper,26 protected ApiWrapperInterface $api, 27 27 LocalizationPluginProxyInterface $connector, 28 28 PluginInfo $pluginInfo, … … 34 34 Cache $cache, 35 35 ) { 36 parent::__construct($ connector, $pluginInfo, $settingsManager, $siteHelper, $manager, $cache);36 parent::__construct($api, $connector, $pluginInfo, $settingsManager, $siteHelper, $manager, $cache); 37 37 } 38 38 … … 47 47 public function wp_enqueue() 48 48 { 49 $resPath = $this-> getPluginInfo()->getUrl();49 $resPath = $this->pluginInfo->getUrl(); 50 50 $jsPath = $resPath . 'js/'; 51 $ver = $this-> getPluginInfo()->getVersion();51 $ver = $this->pluginInfo->getVersion(); 52 52 wp_enqueue_script('jquery'); 53 53 $jsFiles = [ … … 84 84 $table = new BulkSubmitTableWidget( 85 85 $this->acfDynamicSupport, 86 $this->api Wrapper,86 $this->api, 87 87 $this->localizationPluginProxy, 88 88 $this->siteHelper, 89 89 $this->core, 90 $this-> getManager(),90 $this->submissionManager, 91 91 $this->uploadQueueManager, 92 92 $profile -
smartling-connector/trunk/inc/Smartling/WP/Controller/CheckStatusController.php
r2521316 r3441087 11 11 use Smartling\WP\WPHookInterface; 12 12 13 /**14 * Class CheckStatusController15 *16 * @package Smartling\WP\Controller17 */18 13 class CheckStatusController extends WPAbstract implements WPHookInterface 19 14 { … … 24 19 public function wp_enqueue() 25 20 { 26 wp_enqueue_script($this-> getPluginInfo()->getName() . "submission", $this->getPluginInfo()27 ->getUrl() . 'js/smartling-submissions-check.js', ['jquery'], $this-> getPluginInfo()21 wp_enqueue_script($this->pluginInfo->getName() . "submission", $this->pluginInfo 22 ->getUrl() . 'js/smartling-submissions-check.js', ['jquery'], $this->pluginInfo 28 23 ->getVersion(), false); 29 24 } … … 75 70 { 76 71 $result = []; 77 $cache = $this->getCache();78 72 79 $cachedItems = $ cache->get(self::SUBMISSION_CHECKED_KEY);73 $cachedItems = $this->cache->get(self::SUBMISSION_CHECKED_KEY); 80 74 81 75 $now = new \DateTime("now"); … … 104 98 } 105 99 106 $ cache->set(self::SUBMISSION_CHECKED_KEY, $cachedItems, self::CACHE_EXPIRATION);100 $this->cache->set(self::SUBMISSION_CHECKED_KEY, $cachedItems, self::CACHE_EXPIRATION); 107 101 108 102 return $result; -
smartling-connector/trunk/inc/Smartling/WP/Controller/ConfigurationProfileFormController.php
r3338937 r3441087 6 6 use Smartling\Exception\BlogNotFoundException; 7 7 use Smartling\Helpers\ArrayHelper; 8 use Smartling\Helpers\HtmlTagGeneratorHelper; 8 9 use Smartling\Helpers\SmartlingUserCapabilities; 9 10 use Smartling\Helpers\StringHelper; … … 20 21 public function wp_enqueue(): void 21 22 { 22 $resPath = $this-> getPluginInfo()->getUrl();23 $resPath = $this->pluginInfo->getUrl(); 23 24 $jsPath = $resPath . 'js/'; 24 $ver = $this-> getPluginInfo()->getVersion();25 $ver = $this->pluginInfo->getVersion(); 25 26 wp_enqueue_script('jquery'); 26 27 $jsFiles = [ … … 250 251 } 251 252 253 protected function renderLocales( 254 array $locales, 255 string $displayName, 256 int $blogId, 257 string $smartlingName, 258 bool $enabled, 259 ): string { 260 $parts = []; 261 262 $checkboxProperties = [ 263 'type' => 'checkbox', 264 'class' => 'mcheck', 265 'name' => sprintf('smartling_settings[targetLocales][%s][enabled]', $blogId), 266 ]; 267 268 if (true === $enabled) { 269 $checkboxProperties['checked'] = 'checked'; 270 } 271 272 $parts[] = HtmlTagGeneratorHelper::tag('input', '', $checkboxProperties); 273 $parts[] = HtmlTagGeneratorHelper::tag('span', htmlspecialchars($displayName)); 274 $parts = [ 275 HtmlTagGeneratorHelper::tag('label', implode('', $parts), ['class' => 'radio-label']), 276 ]; 277 278 if (0 === count($locales)) { 279 $sLocale = HtmlTagGeneratorHelper::tag( 280 'input', 281 '', 282 [ 283 'name' => sprintf('smartling_settings[targetLocales][%s][target]', $blogId), 284 'type' => 'text', 285 ]); 286 } else { 287 $sLocale = HtmlTagGeneratorHelper::tag( 288 'select', 289 HtmlTagGeneratorHelper::renderSelectOptions( 290 $smartlingName, 291 $locales 292 ), 293 [ 294 'name' => sprintf('smartling_settings[targetLocales][%s][target]', $blogId), 295 ]); 296 } 297 298 $parts = [ 299 HtmlTagGeneratorHelper::tag('td', implode('', $parts), ['style' => 'display:table-cell;']), 300 ]; 301 $parts[] = HtmlTagGeneratorHelper::tag('td', $sLocale, [ 302 'style' => 'display:table-cell', 303 'class' => 'targetLocaleSelectCell', 304 ]); 305 306 return implode('', $parts); 307 } 308 252 309 private function validateTargetLocales(array $targetLocales): bool { 253 310 $values = array_count_values($targetLocales); -
smartling-connector/trunk/inc/Smartling/WP/Controller/ConfigurationProfilesController.php
r3351155 r3441087 31 31 32 32 public function __construct( 33 pr ivateApiWrapperInterface $api,33 protected ApiWrapperInterface $api, 34 34 LocalizationPluginProxyInterface $connector, 35 35 PluginInfo $pluginInfo, … … 42 42 private WordpressFunctionProxyHelper $wpProxy, 43 43 ) { 44 parent::__construct($ connector, $pluginInfo, $settingsManager, $siteHelper, $manager, $cache);44 parent::__construct($api, $connector, $pluginInfo, $settingsManager, $siteHelper, $manager, $cache); 45 45 } 46 46 … … 48 48 { 49 49 wp_enqueue_script( 50 $this-> getPluginInfo()->getName() . 'settings',51 $this-> getPluginInfo()->getUrl() . 'js/smartling-connector-admin.js', ['jquery'],52 $this-> getPluginInfo()->getVersion(),50 $this->pluginInfo->getName() . 'settings', 51 $this->pluginInfo->getUrl() . 'js/smartling-connector-admin.js', ['jquery'], 52 $this->pluginInfo->getVersion(), 53 53 false 54 54 ); 55 55 wp_enqueue_script( 56 $this-> getPluginInfo()->getName() . 'settings-admin-footer',57 $this-> getPluginInfo()->getUrl() . 'js/smartling-connector-gutenberg-lock-attributes.js',56 $this->pluginInfo->getName() . 'settings-admin-footer', 57 $this->pluginInfo->getUrl() . 'js/smartling-connector-gutenberg-lock-attributes.js', 58 58 [], 59 $this-> getPluginInfo()->getVersion(),59 $this->pluginInfo->getVersion(), 60 60 false 61 61 ); 62 wp_localize_script($this-> getPluginInfo()->getName() . 'settings-admin-footer', 'smartling', [62 wp_localize_script($this->pluginInfo->getName() . 'settings-admin-footer', 'smartling', [ 63 63 'addLockIdAttributeOnSave' => GlobalSettingsManager::isGenerateLockIdsEnabled(), 64 64 ]); 65 65 wp_register_style( 66 $this-> getPluginInfo()->getName(),67 $this-> getPluginInfo()->getUrl() . 'css/smartling-connector-admin.css', [],68 $this-> getPluginInfo()->getVersion(), 'all'69 ); 70 wp_enqueue_style($this-> getPluginInfo()->getName());66 $this->pluginInfo->getName(), 67 $this->pluginInfo->getUrl() . 'css/smartling-connector-admin.css', [], 68 $this->pluginInfo->getVersion(), 'all' 69 ); 70 wp_enqueue_style($this->pluginInfo->getName()); 71 71 } 72 72 … … 195 195 { 196 196 $this->view([ 197 'profilesTable' => new ConfigurationProfilesWidget($this-> getPluginInfo()->getSettingsManager()),197 'profilesTable' => new ConfigurationProfilesWidget($this->pluginInfo->getSettingsManager()), 198 198 'cnqTable' => new QueueManagerTableWidget( 199 199 $this->api, 200 200 $this->queue, 201 201 $this->settingsManager, 202 $this-> getManager(),202 $this->submissionManager, 203 203 $this->uploadQueueManager, 204 204 $this->wpProxy, -
smartling-connector/trunk/inc/Smartling/WP/Controller/ContentEditJobController.php
r2862047 r3441087 11 11 use Smartling\Helpers\DiagnosticsHelper; 12 12 use Smartling\Helpers\HtmlTagGeneratorHelper; 13 use Smartling\Helpers\SiteHelper; 13 14 use Smartling\Helpers\SmartlingUserCapabilities; 15 use Smartling\Settings\SettingsManager; 14 16 use Smartling\Vendor\Smartling\Jobs\JobStatus; 15 17 use Smartling\WP\WPAbstract; … … 61 63 } 62 64 63 public function initJobApiProxy() 65 public function initJobApiProxy(): void 64 66 { 65 67 add_action('wp_ajax_' . self::SMARTLING_JOB_API_PROXY, function () { 66 67 68 $data =& $_POST; 68 69 … … 71 72 ]; 72 73 73 $wrapper = Bootstrap::getContainer()->get('api.wrapper.with.retries'); 74 /** 75 * @var ApiWrapper $wrapper 76 */ 77 78 $siteHelper = Bootstrap::getContainer()->get('site.helper'); 79 /** 80 * @var SiteHelper $siteHelper 81 */ 82 83 $settingsManager = Bootstrap::getContainer()->get('manager.settings'); 84 /** 85 * @var SettingsManager $settingsManager 86 */ 87 88 $curSiteId = $siteHelper->getCurrentBlogId(); 89 $profile = $settingsManager->getSingleSettingsProfile($curSiteId); 74 $profile = $this->settingsManager->getSingleSettingsProfile($this->siteHelper->getCurrentBlogId()); 90 75 $params = &$data['params']; 91 76 92 $validateRequires = function ($fieldName) use (&$result, $params) {93 if (array_key_exists($fieldName, $params) && '' !== ($value = trim($params[$fieldName]))) {94 return $value; 95 } else{77 $validateRequires = static function ($fieldName) use (&$result, $params) { 78 $value = trim($params[$fieldName] ?? ''); 79 80 if (!array_key_exists($fieldName, $params) || $value === '') { 96 81 $msg = vsprintf('The field \'%s\' cannot be empty', [$fieldName]); 97 82 Bootstrap::getLogger()->warning($msg); … … 99 84 $result['message'][$fieldName] = $msg; 100 85 } 86 87 return $value; 101 88 }; 102 89 … … 104 91 switch ($data['innerAction']) { 105 92 case 'list-jobs' : 106 $jobs = $ wrapper->listJobs($profile, null, [93 $jobs = $this->api->listJobs($profile, null, [ 107 94 JobStatus::AWAITING_AUTHORIZATION, 108 95 JobStatus::IN_PROGRESS, 109 96 JobStatus::COMPLETED, 110 97 ]); 111 $preparcedJobs = []; 112 if (is_array($jobs) && array_key_exists('items', $jobs) && 113 array_key_exists('totalCount', $jobs) && 0 < (int)$jobs['totalCount']) { 114 foreach ($jobs['items'] as $job) { 115 if (!empty($job['dueDate'])) { 116 $job['dueDate'] = \DateTime::createFromFormat('Y-m-d\TH:i:s\Z', $job['dueDate']) 117 ->format(DateTimeHelper::DATE_TIME_FORMAT_JOB); 118 } 119 120 $preparcedJobs[] = $job; 98 $parsedJobs = []; 99 if (!array_key_exists('items', $jobs)) { 100 throw new \RuntimeException('Jobs api response is invalid.'); 101 } 102 foreach ($jobs['items'] as $job) { 103 if (!empty($job['dueDate'])) { 104 $job['dueDate'] = \DateTime::createFromFormat('Y-m-d\TH:i:s\Z', $job['dueDate']) 105 ->format(DateTimeHelper::DATE_TIME_FORMAT_JOB); 121 106 } 122 } 123 $result['data'] = $preparcedJobs; 107 108 $parsedJobs[] = $job; 109 } 110 $result['data'] = $parsedJobs; 124 111 break; 125 112 case 'create-job': … … 131 118 $jobLocales = []; 132 119 foreach ($jobLocalesRaw as $blogId) { 133 $jobLocales[] = $settingsManager->getSmartlingLocaleIdBySettingsProfile($profile, (int)$blogId); 134 } 135 $debug['status'] = $result['status']; 120 $jobLocales[] = $this->settingsManager->getSmartlingLocaleIdBySettingsProfile($profile, (int)$blogId); 121 } 136 122 if ($result['status'] === 200) { 137 123 try { … … 140 126 141 127 if (!empty($jobDueDate)) { 142 $utcDateTime = \DateTime::createFromFormat(DateTimeHelper::DATE_TIME_FORMAT_JOB, $jobDueDate, new DateTimeZone($timezone)); 128 $utcDateTime = \DateTime::createFromFormat('Y-m-d\TH:i', $jobDueDate, new DateTimeZone($timezone)); 129 if (!$utcDateTime) { 130 throw new \RuntimeException('Invalid due date format.'); 131 } 143 132 $utcDateTime->setTimeZone(new DateTimeZone('UTC')); 144 133 } 145 134 146 $res = $ wrapper->createJob($profile, [135 $res = $this->api->createJob($profile, [ 147 136 'name' => $jobName, 148 137 'description' => $jobDescription, … … 209 198 public function wp_enqueue() 210 199 { 211 $resPath = $this-> getPluginInfo()->getUrl();200 $resPath = $this->pluginInfo->getUrl(); 212 201 $jsPath = $resPath . 'js/'; 213 202 $cssPath = $resPath . 'css/'; 214 $ver = $this-> getPluginInfo()->getVersion();203 $ver = $this->pluginInfo->getVersion(); 215 204 216 205 $jsFiles = [ -
smartling-connector/trunk/inc/Smartling/WP/Controller/ControllerAbstract.php
r2862047 r3441087 28 28 } 29 29 30 private array $viewData; 31 32 public function getViewData(): array 33 { 34 return $this->viewData; 35 } 36 37 public function setViewData(array $viewData): void 38 { 39 $this->viewData = $viewData; 40 } 30 protected array $viewData; 41 31 42 32 /** -
smartling-connector/trunk/inc/Smartling/WP/Controller/DuplicateSubmissionsCleaner.php
r2967105 r3441087 87 87 $duplicateSets[] = new DuplicateSubmissions($this->contentHelper, $this->siteHelper, $this->submissionManager, $set, $nonce); 88 88 } 89 $this-> setViewData(['duplicates' => $duplicateSets]);89 $this->viewData = ['duplicates' => $duplicateSets]; 90 90 $this->renderScript(); 91 91 } -
smartling-connector/trunk/inc/Smartling/WP/Controller/FilterForm.php
r2862047 r3441087 37 37 public function pageHandler(): void 38 38 { 39 $this->setViewData( 40 [ 41 'manager' => new FilterManager(), 42 ] 43 ); 39 $this->viewData = [ 40 'manager' => new FilterManager(), 41 ]; 44 42 $this->renderScript(); 45 43 } -
smartling-connector/trunk/inc/Smartling/WP/Controller/PostBasedWidgetControllerStd.php
r3338937 r3441087 3 3 namespace Smartling\WP\Controller; 4 4 5 use Smartling\ApiWrapperInterface;6 5 use Smartling\Base\ExportedAPI; 7 6 use Smartling\Base\SmartlingCore; 8 7 use Smartling\Bootstrap; 9 use Smartling\DbAl\LocalizationPluginProxyInterface;10 8 use Smartling\Exception\SmartlingDbException; 11 9 use Smartling\Extensions\Acf\AcfDynamicSupport; 12 10 use Smartling\Helpers\ArrayHelper; 13 use Smartling\Helpers\Cache;14 11 use Smartling\Helpers\CommonLogMessagesTrait; 15 12 use Smartling\Helpers\DateTimeHelper; 16 13 use Smartling\Helpers\DiagnosticsHelper; 17 use Smartling\Helpers\PluginInfo;18 use Smartling\Helpers\SiteHelper;19 14 use Smartling\Helpers\SmartlingUserCapabilities; 20 15 use Smartling\Jobs\JobEntityWithBatchUid; 21 use Smartling\Settings\SettingsManager;22 16 use Smartling\Submissions\SubmissionEntity; 23 use Smartling\Submissions\SubmissionManager;24 17 use Smartling\Vendor\Smartling\AuditLog\Params\CreateRecordParameters; 25 18 use Smartling\WP\WPAbstract; … … 64 57 'attachment', 65 58 ]; 66 67 public function __construct(68 private ApiWrapperInterface $apiWrapper,69 LocalizationPluginProxyInterface $connector,70 PluginInfo $pluginInfo,71 SettingsManager $settingsManager,72 SiteHelper $siteHelper,73 private SubmissionManager $submissionManager,74 Cache $cache,75 ) {76 parent::__construct($connector, $pluginInfo, $settingsManager, $siteHelper, $submissionManager, $cache);77 }78 59 79 60 private function isMuted() … … 142 123 $submissionIds = explode(',', $_POST['submissionIds']); 143 124 foreach ($submissionIds as $submissionId) { 144 $submission = $this-> getManager()->getEntityById($submissionId);125 $submission = $this->submissionManager->getEntityById($submissionId); 145 126 if ($submission !== null) { 146 127 $submissions[] = $submission; … … 161 142 try { 162 143 $requestDescription = 'User request to download submissions'; 163 $this->api Wrapper->createAuditLogRecord($profile, CreateRecordParameters::ACTION_TYPE_DOWNLOAD, $requestDescription, ['submissions' => $logSubmissions]);144 $this->api->createAuditLogRecord($profile, CreateRecordParameters::ACTION_TYPE_DOWNLOAD, $requestDescription, ['submissions' => $logSubmissions]); 164 145 } catch (\Exception) { 165 146 $this->getLogger()->error(sprintf('Failed to create audit log record actionType=%s, requestDescription="%s", submissions="%s"', CreateRecordParameters::ACTION_TYPE_DOWNLOAD, $requestDescription, json_encode($logSubmissions))); … … 480 461 wp_enqueue_script( 481 462 'smartling-block-sidebar', 482 $this-> getPluginInfo()->getUrl() . 'js/smartling-block-sidebar.js',463 $this->pluginInfo->getUrl() . 'js/smartling-block-sidebar.js', 483 464 ['wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor'], 484 $this-> getPluginInfo()->getVersion(),465 $this->pluginInfo->getVersion(), 485 466 true 486 467 ); -
smartling-connector/trunk/inc/Smartling/WP/Controller/ShortcodeForm.php
r2862047 r3441087 37 37 public function pageHandler(): void 38 38 { 39 $this->setViewData( 40 [ 41 'manager' => new ShortcodeManager(), 42 ] 43 ); 39 $this->viewData = [ 40 'manager' => new ShortcodeManager(), 41 ]; 44 42 $this->renderScript(); 45 43 } -
smartling-connector/trunk/inc/Smartling/WP/Controller/SubmissionsPageController.php
r2821492 r3441087 18 18 class SubmissionsPageController extends WPAbstract implements WPHookInterface 19 19 { 20 private ApiWrapperInterface $apiWrapper; 21 private Queue $queue; 22 23 public function __construct(ApiWrapperInterface $apiWrapper, LocalizationPluginProxyInterface $connector, PluginInfo $pluginInfo, SettingsManager $settingsManager, SiteHelper $siteHelper, SubmissionManager $manager, Cache $cache, Queue $queue) 24 { 25 parent::__construct($connector, $pluginInfo, $settingsManager, $siteHelper, $manager, $cache); 26 $this->apiWrapper = $apiWrapper; 27 $this->queue = $queue; 20 public function __construct( 21 protected ApiWrapperInterface $api, 22 LocalizationPluginProxyInterface $connector, 23 PluginInfo $pluginInfo, 24 SettingsManager $settingsManager, 25 SiteHelper $siteHelper, 26 SubmissionManager $manager, 27 Cache $cache, 28 private Queue $queue, 29 ) { 30 parent::__construct($api, $connector, $pluginInfo, $settingsManager, $siteHelper, $manager, $cache); 28 31 } 29 32 … … 57 60 public function renderPage(): void 58 61 { 59 $table = new SubmissionTableWidget($this->apiWrapper, $this->localizationPluginProxy, $this->settingsManager, $this->siteHelper, $this->getManager(), $this->queue); 62 $table = new SubmissionTableWidget( 63 $this->api, 64 $this->localizationPluginProxy, 65 $this->settingsManager, 66 $this->siteHelper, 67 $this->submissionManager, 68 $this->queue, 69 ); 60 70 $table->prepare_items(); 61 71 $this->view($table); -
smartling-connector/trunk/inc/Smartling/WP/Controller/TaxonomyLinksController.php
r2821492 r3441087 3 3 namespace Smartling\WP\Controller; 4 4 5 use Smartling\ApiWrapperInterface; 5 6 use Smartling\DbAl\LocalizationPluginProxyInterface; 6 7 use Smartling\Helpers\ArrayHelper; … … 19 20 class TaxonomyLinksController extends WPAbstract implements WPHookInterface 20 21 { 21 private $submissionManager; 22 private $wordpressProxy; 23 24 public function __construct(PluginInfo $pluginInfo, SettingsManager $settingsManager, LocalizationPluginProxyInterface $localizationPluginProxy, SiteHelper $siteHelper, SubmissionManager $submissionManager, WordpressFunctionProxyHelper $wordpressProxy, Cache $cache) 25 { 26 parent::__construct($localizationPluginProxy, $pluginInfo, $settingsManager, $siteHelper, $submissionManager, $cache); 27 $this->submissionManager = $submissionManager; 28 $this->wordpressProxy = $wordpressProxy; 22 public function __construct( 23 protected ApiWrapperInterface $api, 24 PluginInfo $pluginInfo, 25 SettingsManager $settingsManager, 26 LocalizationPluginProxyInterface $localizationPluginProxy, 27 SiteHelper $siteHelper, 28 protected SubmissionManager $submissionManager, 29 private WordpressFunctionProxyHelper $wordpressProxy, 30 Cache $cache, 31 ) 32 { 33 parent::__construct($api, $localizationPluginProxy, $pluginInfo, $settingsManager, $siteHelper, $submissionManager, $cache); 29 34 } 30 35 … … 37 42 { 38 43 wp_enqueue_script( 39 $this-> getPluginInfo()->getName() . 'settings',40 $this-> getPluginInfo()->getUrl() . 'js/smartling-connector-taxonomy-links.js', ['jquery'],41 $this-> getPluginInfo()->getVersion(),44 $this->pluginInfo->getName() . 'settings', 45 $this->pluginInfo->getUrl() . 'js/smartling-connector-taxonomy-links.js', ['jquery'], 46 $this->pluginInfo->getVersion(), 42 47 false 43 48 ); 44 49 wp_enqueue_script( 45 $this-> getPluginInfo()->getName() . 'admin',46 $this-> getPluginInfo()->getUrl() . 'js/smartling-connector-admin.js', ['jquery'],47 $this-> getPluginInfo()->getVersion(),50 $this->pluginInfo->getName() . 'admin', 51 $this->pluginInfo->getUrl() . 'js/smartling-connector-admin.js', ['jquery'], 52 $this->pluginInfo->getVersion(), 48 53 false 49 54 ); 50 55 wp_register_style( 51 $this-> getPluginInfo()->getName(),52 $this-> getPluginInfo()->getUrl() . 'css/smartling-connector-admin.css', [],53 $this-> getPluginInfo()->getVersion(), 'all'54 ); 55 wp_enqueue_style($this-> getPluginInfo()->getName());56 $this->pluginInfo->getName(), 57 $this->pluginInfo->getUrl() . 'css/smartling-connector-admin.css', [], 58 $this->pluginInfo->getVersion(), 'all' 59 ); 60 wp_enqueue_style($this->pluginInfo->getName()); 56 61 } 57 62 -
smartling-connector/trunk/inc/Smartling/WP/Controller/TaxonomyWidgetController.php
r3077564 r3441087 14 14 use Smartling\Helpers\WordpressContentTypeHelper; 15 15 use Smartling\Submissions\SubmissionEntity; 16 use Smartling\Submissions\SubmissionManager; 16 17 use Smartling\WP\WPAbstract; 17 18 use Smartling\WP\WPHookInterface; … … 101 102 102 103 if (0 < count($applicableProfiles)) { 103 $submissions = $this-> getManager()104 $submissions = $this->submissionManager 104 105 ->find([ 105 106 SubmissionEntity::FIELD_SOURCE_BLOG_ID => $curBlogId, -
smartling-connector/trunk/inc/Smartling/WP/Controller/TestRunController.php
r3393007 r3441087 39 39 public const SLUG = 'smartling_test_run'; 40 40 41 private ContentRelationsDiscoveryService $contentRelationDiscoveryService;42 private ApiWrapperInterface $apiWrapper;43 private SubmissionManager $submissionManager;44 41 private int $uploadCronInterval; 45 42 … … 48 45 LocalizationPluginProxyInterface $localizationPluginProxy, 49 46 SiteHelper $siteHelper, 50 SubmissionManager $submissionManager,47 protected SubmissionManager $submissionManager, 51 48 Cache $cache, 52 ContentRelationsDiscoveryService $contentRelationDiscoveryService,53 ApiWrapperInterface $apiWrapper,49 private ContentRelationsDiscoveryService $contentRelationDiscoveryService, 50 protected ApiWrapperInterface $api, 54 51 SettingsManager $settingsManager, 55 52 string $uploadCronInterval 56 53 ) { 57 parent::__construct($localizationPluginProxy, $pluginInfo, $settingsManager, $siteHelper, $submissionManager, $cache); 58 $this->apiWrapper = $apiWrapper; 59 $this->contentRelationDiscoveryService = $contentRelationDiscoveryService; 60 $this->submissionManager = $submissionManager; 54 parent::__construct($api, $localizationPluginProxy, $pluginInfo, $settingsManager, $siteHelper, $submissionManager, $cache); 61 55 if (!preg_match('~^\d+m$~', $uploadCronInterval)) { 62 56 throw new SmartlingConfigException('Upload job cron interval must be specified in minutes (e. g. 5m), with no extra symbols'); … … 98 92 { 99 93 wp_enqueue_script( 100 $this-> getPluginInfo()->getName() . 'admin',101 $this-> getPluginInfo()->getUrl() . 'js/smartling-connector-admin.js', ['jquery'],102 $this-> getPluginInfo()->getVersion(),94 $this->pluginInfo->getName() . 'admin', 95 $this->pluginInfo->getUrl() . 'js/smartling-connector-admin.js', ['jquery'], 96 $this->pluginInfo->getVersion(), 103 97 false, 104 98 ); 105 99 wp_register_style( 106 $this-> getPluginInfo()->getName(),107 $this-> getPluginInfo()->getUrl() . 'css/smartling-connector-admin.css', [],108 $this-> getPluginInfo()->getVersion(),109 ); 110 wp_enqueue_style($this-> getPluginInfo()->getName());100 $this->pluginInfo->getName(), 101 $this->pluginInfo->getUrl() . 'css/smartling-connector-admin.css', [], 102 $this->pluginInfo->getVersion(), 103 ); 104 wp_enqueue_style($this->pluginInfo->getName()); 111 105 } 112 106 … … 205 199 private function getJob(ConfigurationProfileEntity $profile): JobEntity 206 200 { 207 $response = $this->api Wrapper->listJobs($profile, self::TEST_RUN_JOB_NAME, [201 $response = $this->api->listJobs($profile, self::TEST_RUN_JOB_NAME, [ 208 202 JobStatus::AWAITING_AUTHORIZATION, 209 203 JobStatus::IN_PROGRESS, … … 214 208 $jobUId = $response['items'][0]['translationJobUid']; 215 209 } else { 216 $result = $this->api Wrapper->createJob($profile, [210 $result = $this->api->createJob($profile, [ 217 211 'name' => self::TEST_RUN_JOB_NAME, 218 212 'description' => 'Test run job', -
smartling-connector/trunk/inc/Smartling/WP/Controller/TranslationLockController.php
r3004164 r3441087 3 3 namespace Smartling\WP\Controller; 4 4 5 use Smartling\ApiWrapperInterface; 5 6 use Smartling\DbAl\LocalizationPluginProxyInterface; 6 7 use Smartling\Helpers\ArrayHelper; … … 21 22 class TranslationLockController extends WPAbstract implements WPHookInterface 22 23 { 23 private ContentHelper $contentHelper;24 25 24 public function __construct( 25 protected ApiWrapperInterface $api, 26 26 LocalizationPluginProxyInterface $connector, 27 27 PluginInfo $pluginInfo, … … 30 30 SubmissionManager $manager, 31 31 Cache $cache, 32 ContentHelper $contentHelper,32 private ContentHelper $contentHelper, 33 33 ) { 34 parent::__construct($connector, $pluginInfo, $settingsManager, $siteHelper, $manager, $cache); 35 $this->contentHelper = $contentHelper; 34 parent::__construct($api, $connector, $pluginInfo, $settingsManager, $siteHelper, $manager, $cache); 36 35 } 37 36 … … 114 113 private function getSubmission(int $postId, string $postType): ?SubmissionEntity 115 114 { 116 return $this-> getManager()->findOne([115 return $this->submissionManager->findOne([ 117 116 SubmissionEntity::FIELD_TARGET_BLOG_ID => $this->siteHelper->getCurrentBlogId(), 118 117 SubmissionEntity::FIELD_TARGET_ID => $postId, … … 146 145 $submission->setLockedFields(array_keys($_POST['lockField'] ?? [])); 147 146 $submission->setIsLocked(array_key_exists('lock_page', $_POST) ? 1 : 0); 148 $this-> getManager()->storeEntity($submission);147 $this->submissionManager->storeEntity($submission); 149 148 } 150 149 } … … 180 179 $submissionId = (int)$this->getQueryParam('submission', 0); 181 180 if (0 < $submissionId) { 182 $searchResult = $this-> getManager()->findByIds([$submissionId]);181 $searchResult = $this->submissionManager->findByIds([$submissionId]); 183 182 if (0 < count($searchResult)) { 184 183 /** -
smartling-connector/trunk/inc/Smartling/WP/View/AdminPage.php
r2862047 r3441087 9 9 use Smartling\WP\Table\ShortcodeTableClass; 10 10 11 /** 12 * @var AdminPage $this 13 */ 11 14 ?> 12 15 <style> … … 20 23 <h3>Custom Shortcodes</h3> 21 24 <?php 22 /** 23 * @var ShortcodeTableClass $shortcodeTable 24 */ 25 $shortcodeTable = $this->getViewData()['shortcodes']; 26 /** 27 * @var LocalizationRulesTableWidget $filterTable 28 */ 29 $filterTable = $this->getViewData()['filters']; 30 /** 31 * @var MediaAttachmentTableWidget $mediaTable 32 */ 33 $mediaTable = $this->getViewData()['media']; 25 $shortcodeTable = $this->viewData['shortcodes']; 26 assert($shortcodeTable instanceof ShortcodeTableClass); 27 $filterTable = $this->viewData['filters']; 28 assert($filterTable instanceof LocalizationRulesTableWidget); 29 $mediaTable = $this->viewData['media']; 30 assert($mediaTable instanceof MediaAttachmentTableWidget); 34 31 35 32 foreach ([$shortcodeTable, $filterTable, $mediaTable] as $widget) { -
smartling-connector/trunk/inc/Smartling/WP/View/BulkSubmit.php
r3025850 r3441087 2 2 3 3 use Smartling\Helpers\ArrayHelper; 4 use Smartling\WP\Controller\BulkSubmitController; 4 5 use Smartling\WP\Table\BulkSubmitTableWidget; 5 6 use Smartling\WP\WPAbstract; 6 7 7 $data = $this->getViewData(); 8 if (!$data instanceof BulkSubmitTableWidget) { 9 throw new \LogicException(BulkSubmitTableWidget::class . ' expected'); 10 } 8 /** 9 * @var BulkSubmitController $this 10 */ 11 $data = $this->viewData; 12 assert($data instanceof BulkSubmitTableWidget); 11 13 $widgetName = 'bulk-submit-locales'; 12 14 … … 50 52 <?php $bulkSubmitTable->display() ?> 51 53 <div id="error-messages" class="tab"></div> 52 <div class="postbox-container"> 53 <div id="panel-box" class="postbox hndle"><h2><span>Content actions</span></h2> 54 <?php 55 $locales = $data->getProfile()->getTargetLocales(); 56 ArrayHelper::sortLocales($locales); 57 $localesData = array_map(function($locale) { 58 return [ 59 'blogId' => $locale->getBlogId(), 60 'label' => $locale->getLabel(), 61 'smartlingLocale' => $locale->getSmartlingLocale(), 62 'enabled' => $locale->isEnabled() 63 ]; 64 }, array_filter($locales, fn($l) => $l->isEnabled())); 65 ?> 66 <div id="smartling-app" 67 data-bulk-submit="true" 68 data-content-type="" 69 data-content-id="0" 70 data-locales='<?= htmlspecialchars(json_encode(array_values($localesData), JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_HEX_TAG), ENT_QUOTES, 'UTF-8') ?>' 71 data-ajax-url="<?= admin_url('admin-ajax.php') ?>" 72 data-admin-url="<?= admin_url('admin-ajax.php') ?>"></div> 73 <div class="postbox-container" style="display:none;"> 74 <div id="panel-box" class="postbox hndle"> 54 75 <div class="inside"> 55 76 <div id="action-tabs"> … … 60 81 <div id="translate" class="tab"> 61 82 <?php 62 // Render job wizard. 63 $this->setViewData( 64 [ 65 'profile' => $bulkSubmitTable->getProfile(), 66 'contentType' => '', 67 ] 68 ); 83 $this->viewData = [ 84 'profile' => $bulkSubmitTable->getProfile(), 85 'contentType' => '', 86 ]; 69 87 $this->renderViewScript('ContentEditJob.php'); 70 88 ?> -
smartling-connector/trunk/inc/Smartling/WP/View/ConfigurationProfileForm.php
r3373443 r3441087 13 13 /** 14 14 * @var ConfigurationProfileFormController $this 15 * @var SettingsManager $settingsManager16 15 */ 17 $settingsManager = $this-> getViewData();18 19 $pluginInfo = $this-> getPluginInfo();16 $settingsManager = $this->settingsManager; 17 18 $pluginInfo = $this->pluginInfo; 20 19 $domain = $pluginInfo->getDomain(); 21 20 … … 473 472 <?php 474 473 $targetLocales = $profile->getTargetLocales(); 474 $supportedLocales = $this->api->getSupportedLocales($profile); 475 475 foreach ($locales as $blogId => $label) { 476 476 if ($blogId === $profile->getSourceLocale() … … 480 480 } 481 481 482 $smartlingLocale = -1;482 $smartlingLocale = ''; 483 483 $enabled = false; 484 484 … … 493 493 494 494 <tr> 495 <?= WPAbstract::settingsPageTsargetLocaleCheckbox($profile, $label, $blogId, 496 $smartlingLocale, $enabled) ?> 495 <?= $this->renderLocales($supportedLocales, $label, $blogId, $smartlingLocale, $enabled) ?> 497 496 </tr> 498 497 <?php -
smartling-connector/trunk/inc/Smartling/WP/View/ConfigurationProfiles.php
r3333320 r3441087 12 12 * @var ConfigurationProfilesController $this 13 13 */ 14 $data = $this-> getViewData();14 $data = $this->viewData; 15 15 ?> 16 16 <div class="wrap"> -
smartling-connector/trunk/inc/Smartling/WP/View/ContentEditJob.php
r3408250 r3441087 9 9 use Smartling\Submissions\SubmissionEntity; 10 10 use Smartling\WP\Controller\ContentEditJobController; 11 use Smartling\WP\Table\BulkSubmitTableWidget;12 11 use Smartling\WP\WPAbstract; 13 12 14 13 /** 15 14 * @var WPAbstract $this 16 * @var BulkSubmitTableWidget $data17 * @var ConfigurationProfileEntity $profile18 15 */ 19 $data = $this-> getViewData();16 $data = $this->viewData; 20 17 $profile = $data['profile']; 18 assert($profile instanceof ConfigurationProfileEntity); 21 19 $widgetName = 'bulk-submit-locales'; 22 20 23 ?> 21 $isBulkSubmitPage = get_current_screen()?->id === 'smartling_page_smartling-bulk-submit'; 22 global $tag; 23 $needWrapper = ($tag instanceof WP_Term); 24 25 $id = 0; 26 $baseType = 'unknown'; 27 global $post; 28 if ($post instanceof WP_Post) { 29 $id = $post->ID; 30 $baseType = 'post'; 31 } else { 32 if ($tag instanceof WP_Term) { 33 $id = $tag->term_id; 34 $baseType = 'taxonomy'; 35 } 36 } 37 38 $locales = $profile->getTargetLocales(); 39 ArrayHelper::sortLocales($locales); 40 $localesData = array_map(function($locale) { 41 return [ 42 'blogId' => $locale->getBlogId(), 43 'label' => $locale->getLabel(), 44 'smartlingLocale' => $locale->getSmartlingLocale(), 45 'enabled' => $locale->isEnabled() 46 ]; 47 }, array_filter($locales, fn($l) => $l->isEnabled())); 48 49 if (!$isBulkSubmitPage) : ?> 50 <?php if ($needWrapper) : ?> 51 <div class="postbox-container" style="width: 550px"> 52 <div id="panel-box" class="postbox hndle"><h2><span>Translate content</span></h2> 53 <div class="inside"> 54 <?php endif; ?> 55 <div id="smartling-app" 56 data-bulk-submit="false" 57 data-content-type="<?= $data['contentType'] ?? $baseType ?>" 58 data-content-id="<?= $id ?>" 59 data-locales='<?= htmlspecialchars(json_encode(array_values($localesData), JSON_THROW_ON_ERROR | JSON_HEX_APOS | JSON_HEX_QUOT), ENT_QUOTES, 'UTF-8') ?>' 60 data-ajax-url="<?= admin_url('admin-ajax.php') ?>" 61 data-admin-url="<?= admin_url('admin-ajax.php') ?>"></div> 62 <?php if ($needWrapper) : ?> 63 </div> 64 </div> 65 </div> 66 <?php endif; ?> 67 <?php endif; ?> 68 69 <div style="display:none;"> 24 70 <style> 25 71 .relations-list { … … 36 82 </style> 37 83 <?php 38 $isBulkSubmitPage = get_current_screen()?->id === 'smartling_page_smartling-bulk-submit';39 global $tag;40 $needWrapper = ($tag instanceof WP_Term);41 84 ?> 42 85 … … 48 91 </script> 49 92 50 <?php if ($needWrapper ) : ?>93 <?php if ($needWrapper && false) : ?> 51 94 <div class="postbox-container" style="width: 550px"> 52 95 <div id="panel-box" class="postbox hndle"><h2><span>Translate content</span></h2> -
smartling-connector/trunk/inc/Smartling/WP/View/DuplicateSubmissionsCleaner.php
r2967105 r3441087 1 1 <?php 2 2 3 use Smartling\WP\Controller\DuplicateSubmissionsCleaner; 3 4 use Smartling\WP\Table\DuplicateSubmissions; 4 5 6 /** 7 * @var DuplicateSubmissionsCleaner $this 8 */ 5 9 ?> 6 10 <div class="wrap"> … … 12 16 </ul> 13 17 <?php 14 $duplicates = $this-> getViewData()['duplicates'];18 $duplicates = $this->viewData['duplicates']; 15 19 foreach ($duplicates as $set) { 16 20 assert($set instanceof DuplicateSubmissions); -
smartling-connector/trunk/inc/Smartling/WP/View/FilterForm.php
r2862047 r3441087 12 12 use Smartling\Tuner\FilterManager; 13 13 use Smartling\WP\Controller\FilterForm; 14 15 $data = $this->getViewData(); 16 14 /** 15 * @var FilterForm $this 16 */ 17 $data = $this->viewData; 17 18 18 19 /** -
smartling-connector/trunk/inc/Smartling/WP/View/PostBasedWidgetStd.php
r1819304 r3441087 5 5 /** 6 6 * @var WPAbstract $this 7 * @var WPAbstract self8 7 */ 9 8 10 $this-> setWidgetHeader(__('Download translation:'));9 $this->widgetHeader = __('Download translation:'); 11 10 $this->renderViewScript('post-based-content-type.php'); -
smartling-connector/trunk/inc/Smartling/WP/View/ShortcodeForm.php
r2862047 r3441087 13 13 use Smartling\WP\Controller\ShortcodeForm; 14 14 15 $data = $this->getViewData(); 15 /** 16 * @var ShortcodeForm $this 17 */ 18 $data = $this->viewData; 16 19 17 20 /** -
smartling-connector/trunk/inc/Smartling/WP/View/SubmissionsPage.php
r2567071 r3441087 3 3 use Smartling\Helpers\DiagnosticsHelper; 4 4 use Smartling\Helpers\UiMessageHelper; 5 use Smartling\WP\Controller\SubmissionsPageController; 5 6 use Smartling\WP\Table\SubmissionTableWidget; 6 use Smartling\WP\WPAbstract;7 7 8 8 /** 9 * @var WPAbstract$this9 * @var SubmissionsPageController $this 10 10 */ 11 $data = $this-> getViewData();11 $data = $this->viewData; 12 12 ?> 13 13 <?php if (!DiagnosticsHelper::isBlocked()) : ?> -
smartling-connector/trunk/inc/Smartling/WP/View/TaxonomyLinks.php
r2862047 r3441087 7 7 * @var TaxonomyLinksController $this 8 8 */ 9 $blogs = $this-> getViewData()['blogs'];9 $blogs = $this->viewData['blogs']; 10 10 ?> 11 11 <script> 12 let submissions = <?= json_encode($this-> getViewData()['submissions'])?>;13 const terms = <?= json_encode($this-> getViewData()['terms'])?>;12 let submissions = <?= json_encode($this->viewData['submissions'], JSON_THROW_ON_ERROR)?>; 13 const terms = <?= json_encode($this->viewData['terms'], JSON_THROW_ON_ERROR)?>; 14 14 </script> 15 15 <p>This section allows linking of taxonomy terms between different blogs to avoid target blog terms duplication upon translation.</p> -
smartling-connector/trunk/inc/Smartling/WP/View/TaxonomyWidget.php
r1344113 r3441087 5 5 /** 6 6 * @var WPAbstract $this 7 * @var WPAbstract self8 7 */ 9 8 -
smartling-connector/trunk/inc/Smartling/WP/View/TestRun.php
r3387552 r3441087 8 8 /** 9 9 * @var TestRunController $this 10 * @var TestRunViewData $viewData11 10 */ 12 $viewData = $this->getViewData(); 11 $viewData = $this->viewData; 12 assert($viewData instanceof TestRunViewData); 13 13 ?> 14 14 <h1>Test run</h1> <!--needed for admin notices--> -
smartling-connector/trunk/inc/Smartling/WP/View/TranslationLock.php
r3004164 r3441087 1 1 <?php 2 3 use Smartling\Helpers\HtmlTagGeneratorHelper; 4 use Smartling\Submissions\SubmissionEntity; 5 use Smartling\WP\Table\TranslationLockTableWidget; 6 2 7 defined('IFRAME_REQUEST') || define('IFRAME_REQUEST', true); 3 8 defined('WP_ADMIN') || define('WP_ADMIN', true); … … 52 57 /** 53 58 * @var WPAbstract $this 54 * @var WPAbstract self55 59 */ 56 $data = $this->getViewData(); 57 /** 58 * @var \Smartling\WP\Table\TranslationLockTableWidget $table 59 */ 60 $data = $this->viewData; 60 61 $table = $data['table']; 61 /** 62 * @var \Smartling\Submissions\SubmissionEntity $submission 63 */ 62 assert($table instanceof TranslationLockTableWidget); 64 63 $submission = $data['submission']; 64 assert($submission instanceof SubmissionEntity); 65 65 ?> 66 66 … … 68 68 <div> 69 69 <?= 70 \Smartling\Helpers\HtmlTagGeneratorHelper::tag(70 HtmlTagGeneratorHelper::tag( 71 71 'label', 72 72 __('Lock all fields'), … … 89 89 90 90 <?= 91 \Smartling\Helpers\HtmlTagGeneratorHelper::tag('input', '', $options);91 HtmlTagGeneratorHelper::tag('input', '', $options); 92 92 ?> 93 93 </div> 94 94 95 <? = $table->display();?>96 <?= \Smartling\Helpers\HtmlTagGeneratorHelper::tag(95 <?php $table->display() ?> 96 <?= HtmlTagGeneratorHelper::tag( 97 97 'input', 98 98 '', -
smartling-connector/trunk/inc/Smartling/WP/View/post-based-content-type.php
r2731800 r3441087 12 12 /** 13 13 * @var WPAbstract $this 14 * @var WPAbstract self15 14 */ 16 $data = $this-> getViewData();15 $data = $this->viewData; 17 16 $widgetName = PostBasedWidgetControllerStd::WIDGET_DATA_NAME; 18 17 … … 45 44 <div class="fields"> 46 45 47 <h3><?= $this-> getWidgetHeader()?></h3>46 <h3><?= $this->widgetHeader ?></h3> 48 47 <?= WPAbstract::checkUncheckBlock($widgetName) ?> 49 48 <div class="locale-list"> … … 89 88 $editUrl = WordpressContentTypeHelper::getEditUrl($item); 90 89 } 91 90 92 91 /** 93 92 * Disable download checkbox for new state -
smartling-connector/trunk/inc/Smartling/WP/View/taxonomy-based-content-type.php
r2927786 r3441087 28 28 /** 29 29 * @var WPAbstract $this 30 * @var WPAbstract self31 30 */ 32 $data = $this-> getViewData();31 $data = $this->viewData; 33 32 $widgetName = TaxonomyWidgetController::WIDGET_DATA_NAME; 34 33 -
smartling-connector/trunk/inc/Smartling/WP/WPAbstract.php
r2821492 r3441087 3 3 namespace Smartling\WP; 4 4 5 use Smartling\Base\SmartlingCore; 6 use Smartling\Bootstrap; 5 use Smartling\ApiWrapperInterface; 7 6 use Smartling\DbAl\LocalizationPluginProxyInterface; 8 7 use Smartling\Exception\SmartlingIOException; 9 8 use Smartling\Helpers\Cache; 10 9 use Smartling\Helpers\HtmlTagGeneratorHelper; 10 use Smartling\Helpers\LoggerSafeTrait; 11 11 use Smartling\Helpers\PluginInfo; 12 12 use Smartling\Helpers\SiteHelper; 13 13 use Smartling\Helpers\StringHelper; 14 use Smartling\MonologWrapper\MonologWrapper;15 14 use Smartling\Settings\ConfigurationProfileEntity; 16 15 use Smartling\Settings\SettingsManager; 17 16 use Smartling\Submissions\SubmissionEntity; 18 17 use Smartling\Submissions\SubmissionManager; 19 use Smartling\Vendor\Psr\Log\LoggerInterface;20 18 21 19 class WPAbstract 22 20 { 23 24 /** 25 * @var LoggerInterface 26 */ 27 private $logger; 28 29 /** 30 * @var PluginInfo 31 */ 32 private $pluginInfo; 33 34 protected LocalizationPluginProxyInterface $localizationPluginProxy; 35 protected SettingsManager $settingsManager; 36 protected SiteHelper $siteHelper; 37 38 /** 39 * @var SubmissionManager 40 */ 41 private $manager; 42 43 /** 44 * @var Cache 45 */ 46 private $cache; 47 48 /** 49 * @var string 50 */ 51 private $widgetHeader = ''; 52 53 /** 54 * @var mixed 55 */ 56 private $viewData; 57 58 /** 59 * @return mixed 60 */ 61 public function getViewData() 62 { 63 return $this->viewData; 64 } 65 66 /** 67 * @param mixed $viewData 68 */ 69 public function setViewData($viewData) 70 { 71 $this->viewData = $viewData; 72 } 73 74 75 /** 76 * @return string 77 */ 78 public function getWidgetHeader() 79 { 80 return $this->widgetHeader; 81 } 82 83 /** 84 * @param string $widgetHeader 85 */ 86 public function setWidgetHeader($widgetHeader) 87 { 88 $this->widgetHeader = $widgetHeader; 89 } 21 use LoggerSafeTrait; 22 protected mixed $viewData; 23 24 protected string $widgetHeader = ''; 90 25 91 26 public function __construct( 92 LocalizationPluginProxyInterface $connector, 93 PluginInfo $pluginInfo, 94 SettingsManager $settingsManager, 95 SiteHelper $siteHelper, 96 SubmissionManager $manager, 97 Cache $cache 98 ) 99 { 100 $this->logger = MonologWrapper::getLogger(get_called_class()); 101 $this->localizationPluginProxy = $connector; 102 $this->pluginInfo = $pluginInfo; 103 $this->settingsManager = $settingsManager; 104 $this->siteHelper = $siteHelper; 105 $this->manager = $manager; 106 $this->cache = $cache; 107 } 108 109 /** 110 * @return Cache 111 */ 112 public function getCache() 113 { 114 return $this->cache; 115 } 116 117 /** 118 * @return SubmissionManager 119 */ 120 public function getManager() 121 { 122 return $this->manager; 123 } 124 125 /** 126 * @return LoggerInterface 127 */ 128 public function getLogger() 129 { 130 return $this->logger; 131 } 132 133 /** 134 * @return PluginInfo 135 */ 136 public function getPluginInfo() 137 { 138 return $this->pluginInfo; 27 protected ApiWrapperInterface $api, 28 protected LocalizationPluginProxyInterface $localizationPluginProxy, 29 protected PluginInfo $pluginInfo, 30 protected SettingsManager $settingsManager, 31 protected SiteHelper $siteHelper, 32 protected SubmissionManager $submissionManager, 33 protected Cache $cache 34 ) { 139 35 } 140 36 … … 147 43 } 148 44 149 /** 150 * @param mixed $data 151 */ 152 public function view($data = null) 153 { 154 $this->setViewData($data); 155 $class = get_called_class(); 156 $class = str_replace('Smartling\\WP\\Controller\\', '', $class); 157 158 $class = str_replace('Controller', '', $class); 159 160 $this->renderViewScript($class . '.php'); 161 } 162 163 public function renderViewScript($script) 45 public function view(mixed $data = null): void 46 { 47 $this->viewData = $data; 48 $this->renderViewScript(str_replace(['Smartling\\WP\\Controller\\', 'Controller'], '', static::class) . '.php'); 49 } 50 51 public function renderViewScript($script): void 164 52 { 165 53 $filename = plugin_dir_path(__FILE__) . 'View/' . $script; … … 167 55 if (!file_exists($filename) || !is_file($filename) || !is_readable($filename)) { 168 56 throw new SmartlingIOException(vsprintf('Requested view file (%s) not found.', [$filename])); 169 } else { 170 /** @noinspection PhpIncludeInspection */ 171 require_once $filename; 172 } 57 } 58 59 require_once $filename; 173 60 } 174 61 … … 381 268 } 382 269 383 public static function settingsPageTsargetLocaleCheckbox(384 ConfigurationProfileEntity $profile,385 $displayName,386 $blogId,387 $smartlingName = '',388 $enabled = false389 )390 {391 $parts = [];392 393 $checkboxProperties = [394 'type' => 'checkbox',395 'class' => 'mcheck',396 'name' => vsprintf('smartling_settings[targetLocales][%s][enabled]', [$blogId]),397 ];398 399 if (true === $enabled) {400 $checkboxProperties['checked'] = 'checked';401 }402 403 $parts[] = HtmlTagGeneratorHelper::tag('input', '', $checkboxProperties);404 405 $parts[] = HtmlTagGeneratorHelper::tag('span', htmlspecialchars($displayName), []);406 407 $parts = [408 HtmlTagGeneratorHelper::tag('label', implode('', $parts), ['class' => 'radio-label']),409 ];410 411 /**412 * @var SmartlingCore $ep413 */414 $ep = Bootstrap::getContainer()->get('entrypoint');415 416 $locales = $ep->getProjectLocales($profile);417 418 if (0 === count($locales)) {419 $sLocale = HtmlTagGeneratorHelper::tag(420 'input',421 '',422 [423 'name' => vsprintf('smartling_settings[targetLocales][%s][target]', [$blogId]),424 'type' => 'text',425 ]);426 } else {427 $sLocale = HtmlTagGeneratorHelper::tag(428 'select',429 HtmlTagGeneratorHelper::renderSelectOptions(430 $smartlingName,431 $locales432 ),433 [434 'name' => vsprintf('smartling_settings[targetLocales][%s][target]', [$blogId]),435 ]);436 }437 438 $parts = [439 HtmlTagGeneratorHelper::tag('td', implode('', $parts), ['style' => 'display:table-cell;']),440 ];441 $parts[] = HtmlTagGeneratorHelper::tag('td', $sLocale, ['style' => 'display:table-cell', 'class' => 'targetLocaleSelectCell']);442 443 return implode('', $parts);444 }445 446 270 protected function getQueryParam($paramName, $defaultValue = null) 447 271 { -
smartling-connector/trunk/inc/config/logger.yml
r2997020 r3441087 2 2 logger.buffer.limit: 1000 3 3 logger.channel: default 4 logger.filehandler.standard.filename.default: %%plugin.dir%%/logs/logfile5 logger.filehandler.standard.filename: %%plugin.dir%%/logs/logfile4 logger.filehandler.standard.filename.default: "%%plugin.dir%%/logs/logfile" 5 logger.filehandler.standard.filename: "%%plugin.dir%%/logs/logfile" 6 6 logger.filehandler.standard.loglevel: DEBUG 7 7 logger.filehandler.standard.maxfiles: 1 -
smartling-connector/trunk/inc/config/plugin-info.yml
r2997020 r3441087 1 1 parameters: 2 2 plugin.name: "wordpress-connector" 3 plugin.url: "@=service('wp.proxy').plugin_dir_url(constant('SMARTLING_PLUGIN_DIR')~constant('DIRECTORY_SEPARATOR')~'..')"4 3 plugin.version: "auto updated" 5 plugin.domain: %plugin.name%4 plugin.domain: "wordpress-connector" -
smartling-connector/trunk/inc/config/services.yml
r3415470 r3441087 263 263 class: Smartling\Helpers\FileUriHelper 264 264 arguments: 265 - "@ factory.contentIO"265 - "@content.helper" 266 266 - "@site.helper" 267 267 … … 301 301 - "%plugin.name%" 302 302 - "%plugin.version%" 303 - " %plugin.url%"303 - "@=service('wp.proxy').plugin_dir_url(constant('SMARTLING_PLUGIN_DIR')~constant('DIRECTORY_SEPARATOR')~'..')" 304 304 - "%plugin.domain%" 305 305 - "@manager.settings" … … 357 357 class: Smartling\WP\Controller\ConfigurationProfileFormController 358 358 arguments: 359 - "@api.wrapper.with.retries" 359 360 - "@multilang.proxy" 360 361 - "@plugin.info" … … 379 380 class: Smartling\WP\Controller\TaxonomyLinksController 380 381 arguments: 382 - "@api.wrapper.with.retries" 381 383 - "@plugin.info" 382 384 - "@manager.settings" … … 403 405 class: Smartling\WP\Controller\CheckStatusController 404 406 arguments: 407 - "@api.wrapper.with.retries" 405 408 - "@multilang.proxy" 406 409 - "@plugin.info" … … 567 570 class: Smartling\WP\Controller\TranslationLockController 568 571 arguments: 572 - "@api.wrapper.with.retries" 569 573 - "@multilang.proxy" 570 574 - "@plugin.info" -
smartling-connector/trunk/readme.txt
r3418195 r3441087 3 3 Tags: translation, localization, multilingual, internationalization, smartling 4 4 Requires at least: 5.5 5 Tested up to: 6. 6.25 Tested up to: 6.9 6 6 Requires PHP: 8.0 7 Stable tag: 5. 1.37 Stable tag: 5.2.0 8 8 License: GPLv2 or later 9 9 … … 63 63 64 64 == Changelog == 65 = 5.2.0 = 66 * Added support for Synced Patterns (Reusable blocks) 67 68 = 5.1.4 = 69 * Removed caching of profile settings locales 70 * Updated UI 71 * Added support for Elementor video attachments 72 * Added support for Elementor loop carousel query tags 73 * Added support for Elementor widget background overlay image attachments 74 65 75 = 5.1.3 = 66 76 * Reworked Elementor save hook to preserve dynamic widget settings -
smartling-connector/trunk/smartling-connector.php
r3418195 r3441087 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: 5. 1.314 * Version: 5.2.0 15 15 * Author: Smartling 16 16 * Author URI: https://www.smartling.com
Note: See TracChangeset
for help on using the changeset viewer.