Plugin Directory

Changeset 3338937


Ignore:
Timestamp:
08/04/2025 12:01:08 PM (8 months ago)
Author:
smartling
Message:

Update to v 4.2.0

Location:
smartling-connector/trunk
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • smartling-connector/trunk/inc/Smartling/Base/SmartlingCore.php

    r3077564 r3338937  
    3939        parent::__construct();
    4040
    41         add_action(ExportedAPI::ACTION_SMARTLING_CLONE_CONTENT, [$this, 'cloneContent']);
    42         add_action(ExportedAPI::ACTION_SMARTLING_PREPARE_SUBMISSION_UPLOAD, [$this, 'prepareUpload']);
    43         add_action(ExportedAPI::ACTION_SMARTLING_SEND_FOR_TRANSLATION, [$this, 'sendForTranslation']);
    44         add_action(ExportedAPI::ACTION_SMARTLING_DOWNLOAD_TRANSLATION, [$this, 'downloadTranslationBySubmission',]);
    45         add_action(ExportedAPI::ACTION_SMARTLING_REGENERATE_THUMBNAILS, [$this, 'regenerateTargetThumbnailsBySubmission']);
    46         add_filter(ExportedAPI::FILTER_SMARTLING_PREPARE_TARGET_CONTENT, [$this, 'prepareTargetContent']);
    47         add_action(ExportedAPI::ACTION_SMARTLING_SYNC_MEDIA_ATTACHMENT, [$this, 'syncAttachment']);
     41        $this->wpProxy->add_action(ExportedAPI::ACTION_SMARTLING_CLONE_CONTENT, [$this, 'cloneContent']);
     42        $this->wpProxy->add_action(ExportedAPI::ACTION_SMARTLING_PREPARE_SUBMISSION_UPLOAD, [$this, 'prepareUpload']);
     43        $this->wpProxy->add_action(ExportedAPI::ACTION_SMARTLING_SEND_FOR_TRANSLATION, [$this, 'sendForTranslation']);
     44        $this->wpProxy->add_action(ExportedAPI::ACTION_SMARTLING_DOWNLOAD_TRANSLATION, [$this, 'downloadTranslationBySubmission',]);
     45        $this->wpProxy->add_action(ExportedAPI::ACTION_SMARTLING_REGENERATE_THUMBNAILS, [$this, 'regenerateTargetThumbnailsBySubmission']);
     46        $this->wpProxy->add_filter(ExportedAPI::FILTER_SMARTLING_PREPARE_TARGET_CONTENT, [$this, 'prepareTargetContent']);
     47        $this->wpProxy->add_action(ExportedAPI::ACTION_SMARTLING_SYNC_MEDIA_ATTACHMENT, [$this, 'syncAttachment']);
    4848    }
    4949
  • smartling-connector/trunk/inc/Smartling/Base/SmartlingCoreTrait.php

    r3077564 r3338937  
    33namespace Smartling\Base;
    44
     5use Smartling\DbAl\WordpressContentEntities\Entity;
    56use Smartling\DbAl\WordpressContentEntities\EntityWithPostStatus;
    67use Smartling\DbAl\WordpressContentEntities\EntityAbstract;
     
    6667        $unfilteredSourceData = $this->readSourceContentWithMetadataAsArray($submission);
    6768
    68         $filteredData = $submission->isCloned() ? $unfilteredSourceData : $this->getFieldsFilter()->removeIgnoringFields($submission, $unfilteredSourceData);
     69        $filteredData = $this->filterData($targetContent, $submission, $unfilteredSourceData);
    6970
    70         unset ($filteredData['entity']['ID'], $filteredData['entity']['term_id'], $filteredData['entity']['id']);
    71 
    72         if (array_key_exists('entity', $filteredData) &&
    73             $targetContent instanceof EntityAbstract &&
    74             ArrayHelper::notEmpty($filteredData['entity'])
    75         ) {
    76             foreach ($filteredData['entity'] as $k => $v) {
    77                 $targetContent->{$k} = apply_filters(ExportedAPI::FILTER_SMARTLING_METADATA_FIELD_PROCESS, $k, $v, $submission);
     71        if ($targetContent instanceof EntityAbstract) {
     72            foreach ($filteredData['entity'] ?? [] as $k => $v) {
     73                $targetContent->{$k} = $this->wpProxy->apply_filters(ExportedAPI::FILTER_SMARTLING_METADATA_FIELD_PROCESS, $k, $v, $submission);
    7874            }
    7975        }
     
    119115        return $submission;
    120116    }
     117
     118    private function filterData(Entity $target, SubmissionEntity $submission, array $unfilteredSourceData): array
     119    {
     120        if ($submission->isCloned()) {
     121            if ($target instanceof EntityAbstract) {
     122                foreach ($target->getNonCloneableFields() as $field) {
     123                    unset($unfilteredSourceData['entity'][$field]);
     124                }
     125            }
     126            $result = $unfilteredSourceData;
     127        } else {
     128            $result = $this->getFieldsFilter()->removeIgnoringFields($submission, $unfilteredSourceData);
     129        }
     130
     131        unset ($result['entity']['ID'], $result['entity']['term_id'], $result['entity']['id']);
     132
     133        return $result;
     134    }
    121135}
  • smartling-connector/trunk/inc/Smartling/Base/SmartlingEntityAbstract.php

    r3077564 r3338937  
    101101    }
    102102
    103     /**
    104      * @param bool $addVirtualColumns
    105      *
    106      * @return array
    107      */
    108     public function toArray($addVirtualColumns = true)
     103    public function toArray(bool $addVirtualColumns = true): array
    109104    {
    110105        $arr = $this->stateFields;
  • smartling-connector/trunk/inc/Smartling/DbAl/WordpressContentEntities/EntityAbstract.php

    r3025850 r3338937  
    219219     * @return string[]
    220220     */
    221     abstract protected function getNonCloneableFields(): array;
     221    abstract public function getNonCloneableFields(): array;
    222222
    223223    public function forInsert(): static
  • smartling-connector/trunk/inc/Smartling/DbAl/WordpressContentEntities/PostEntityStd.php

    r3289052 r3338937  
    117117    }
    118118
    119     protected function getNonCloneableFields(): array
     119    public function getNonCloneableFields(): array
    120120    {
    121121        return [
  • smartling-connector/trunk/inc/Smartling/DbAl/WordpressContentEntities/TaxonomyEntityStd.php

    r3025850 r3338937  
    291291    }
    292292
    293     protected function getNonCloneableFields(): array
     293    public function getNonCloneableFields(): array
    294294    {
    295295        return [
  • smartling-connector/trunk/inc/Smartling/DbAl/WordpressContentEntities/WidgetEntity.php

    r3025850 r3338937  
    189189     * @return array
    190190     */
    191     protected function getNonCloneableFields(): array
     191    public function getNonCloneableFields(): array
    192192    {
    193193        return [$this->getPrimaryFieldName()];
  • smartling-connector/trunk/inc/Smartling/Extensions/Acf/AcfDynamicSupport.php

    r3333320 r3338937  
    2525    use LoggerSafeTrait;
    2626
    27     public const POST_TYPE_ACF_FIELD_GROUP = 'acf-field-group';
     27    public const POST_TYPE_FIELD = 'acf-field';
     28    public const POST_TYPE_GROUP = 'acf-field-group';
    2829    public const REFERENCED_TYPE_NONE = 'none';
    2930    public const REFERENCED_TYPE_MEDIA = 'media';
     
    7071    {}
    7172
    72     public function addCopyRules(array $rules) {
     73    public function addCopyRules(array $rules): void
     74    {
    7375        $this->rules['copy'] = $this->arrayHelper->add($this->rules['copy'], $rules);
    7476    }
     
    9597            if (
    9698                ($profile instanceof ConfigurationProfileEntity)
    97                 && in_array($profile->getOriginalBlogId()->getBlogId(), $blogs, true)
     99                && in_array($profile->getSourceLocale()->getBlogId(), $blogs, true)
    98100            ) {
    99                 $blogsToSearch[] = $profile->getOriginalBlogId()->getBlogId();
     101                $blogsToSearch[] = $profile->getSourceLocale()->getBlogId();
    100102            }
    101103        }
     
    186188        $posts = (new \WP_Query(
    187189            [
    188                 'post_type' => self::POST_TYPE_ACF_FIELD_GROUP,
     190                'post_type' => self::POST_TYPE_GROUP,
    189191                'suppress_filters' => true,
    190192                'posts_per_page'   => -1,
     
    208210        $posts = (new \WP_Query(
    209211            [
    210                 'post_type'        => 'acf-field',
     212                'post_type'        => self::POST_TYPE_FIELD,
    211213                'suppress_filters' => true,
    212214                'posts_per_page'   => -1,
     
    301303    private function getLocalDefinitionsOld(): array
    302304    {
    303         $acf  = null;
    304305        $defs = [];
    305306        try {
     
    411412    }
    412413
    413     public function syncFieldGroup(SubmissionEntity $submission): void
    414     {
     414    public function syncAcfData(SubmissionEntity $submission): void
     415    {
     416        if ($submission->isLocked()) {
     417            $this->logger->debug("Submission submissionId={$submission->getId()} is locked, skipping ACF sync");
     418
     419            return;
     420        }
     421
    415422        $context = [
    416423            'submissionId' => $submission->getId(),
     
    422429                LogContextMixinHelper::addToContext($key, $value);
    423430            }
    424             if ($submission->getContentType() !== self::POST_TYPE_ACF_FIELD_GROUP) {
    425                 $this->getLogger()->error("Trying to sync ACF field group, expected content type: " . self::POST_TYPE_ACF_FIELD_GROUP);
     431            if (!in_array($submission->getContentType(), $this->getTypes(), true)) {
     432                $this->getLogger()->error("Trying to sync {$submission->getContentType()}, expected content types: " . implode(', ', $this->getTypes()));
    426433
    427434                return;
     
    430437            $post = $this->wpProxy->get_post($submission->getSourceId(), ARRAY_A);
    431438            if ($post === null) {
    432                 $this->getLogger()->error("Trying to sync ACF field group, source post not found");
     439                $this->getLogger()->error("Trying to sync {$submission->getContentType()}, source post not found");
    433440
    434441                return;
     
    437444            $array = $this->wpProxy->maybe_unserialize($post['post_content']);
    438445            if (!is_array($array)) {
    439                 $this->getLogger()->error("Trying to sync ACF field group, post content could not be unserialized, content=\"$post->post_content\"");
     446                $this->getLogger()->error("Trying to sync {$submission->getContentType()}, post content could not be unserialized, content=\"$post->post_content\"");
    440447
    441448                return;
    442449            }
    443450
    444             if (!array_key_exists('location', $array)) {
    445                 $this->getLogger()->debug("Sync of ACF field group skipped: no location fields");
    446 
    447                 return;
    448             }
    449 
    450             foreach ($array['location'] as &$rules) {
    451                 foreach ($rules as &$rule) {
    452                     if ($rule['param'] === 'page') {
    453                         $targetSubmission = $this->submissionManager->findOne([
    454                             SubmissionEntity::FIELD_SOURCE_BLOG_ID => $submission->getSourceBlogId(),
    455                             SubmissionEntity::FIELD_SOURCE_ID => $rule['value'],
    456                             SubmissionEntity::FIELD_TARGET_BLOG_ID => $submission->getTargetBlogId(),
    457                             SubmissionEntity::FIELD_CONTENT_TYPE => $this->wpProxy->get_post_types(),
    458                         ]);
    459                         if ($targetSubmission === null) {
    460                             $this->getLogger()->debug("Skip change location page {$rule['operator']} {$rule['value']}: no target submission exists");
    461                             continue;
     451            if (array_key_exists('location', $array) && is_array($array['location'])) { // Null coalesce doesn't work with references
     452                foreach ($array['location'] as &$rules) {
     453                    foreach ($rules as &$rule) {
     454                        if ($rule['param'] === 'page') {
     455                            $targetSubmission = $this->submissionManager->findOne([
     456                                SubmissionEntity::FIELD_SOURCE_BLOG_ID => $submission->getSourceBlogId(),
     457                                SubmissionEntity::FIELD_SOURCE_ID => $rule['value'],
     458                                SubmissionEntity::FIELD_TARGET_BLOG_ID => $submission->getTargetBlogId(),
     459                                SubmissionEntity::FIELD_CONTENT_TYPE => $this->wpProxy->get_post_types(),
     460                            ]);
     461                            if ($targetSubmission === null) {
     462                                $this->getLogger()->debug("Skip change location page {$rule['operator']} {$rule['value']}: no target submission exists");
     463                                continue;
     464                            }
     465                            $rule['value'] = (string)$targetSubmission->getTargetId();
    462466                        }
    463                         $rule['value'] = (string)$targetSubmission->getTargetId();
    464467                    }
     468                    unset($rule);
    465469                }
    466                 unset($rule);
    467             }
    468             unset($rules);
     470                unset($rules);
     471            }
    469472
    470473            $this->siteHelper->withBlog($submission->getTargetBlogId(), function () use ($array, $submission): void {
     
    487490    {
    488491        $this->getLogger()->debug('Checking if ACF presents...');
    489         if (true === $this->checkAcfTypes()) {
     492        if ($this->isAcfActive()) {
    490493            $this->getLogger()->debug('ACF detected.');
    491494            $localDefinitions = $this->getLocalDefinitions();
     
    594597        $type = $this->definitions[$key]['type'] ?? '';
    595598
    596         switch ($type) {
    597             case 'image':
    598             case 'image_aspect_ratio_crop':
    599             case 'file':
    600             case 'gallery':
    601                 return self::REFERENCED_TYPE_MEDIA;
    602             case 'post_object':
    603             case 'page_link':
    604             case 'relationship':
    605                 return self::REFERENCED_TYPE_POST;
    606             case 'taxonomy':
    607                 return self::REFERENCED_TYPE_TAXONOMY;
    608         }
    609 
    610         return self::REFERENCED_TYPE_NONE;
     599        return match ($type) {
     600            'image', 'image_aspect_ratio_crop', 'file', 'gallery' => self::REFERENCED_TYPE_MEDIA,
     601            'post_object', 'page_link', 'relationship' => self::REFERENCED_TYPE_POST,
     602            'taxonomy' => self::REFERENCED_TYPE_TAXONOMY,
     603            default => self::REFERENCED_TYPE_NONE,
     604        };
    611605    }
    612606
     
    621615
    622616        foreach ($data['meta'] as $key => $value) {
    623             if (strpos($key, '_') === 0 && in_array($value, $this->rules['copy'], true)) {
     617            if (str_starts_with($key, '_') && in_array($value, $this->rules['copy'], true)) {
    624618                $realKey = substr($key, 1);
    625619                unset($data['meta'][$realKey], $data['meta'][$key]);
     
    692686    }
    693687
    694     private function checkAcfTypes(): bool
     688    public function isAcfActive(): bool
    695689    {
    696690        $postTypes = $this->getPostTypes();
    697691
    698         return in_array('acf-field', $postTypes, true) && in_array(self::POST_TYPE_ACF_FIELD_GROUP, $postTypes, true);
     692        return in_array(self::POST_TYPE_FIELD, $postTypes, true)
     693            && in_array(self::POST_TYPE_GROUP, $postTypes, true);
     694    }
     695
     696    /**
     697     * @return string[]
     698     */
     699    public function getTypes(): array
     700    {
     701        return [self::POST_TYPE_GROUP];
    699702    }
    700703
  • smartling-connector/trunk/inc/Smartling/Extensions/AcfOptionPages/AcfOptionEntity.php

    r3025850 r3338937  
    133133    }
    134134
    135     protected function getNonCloneableFields(): array
     135    public function getNonCloneableFields(): array
    136136    {
    137137        return [$this->getPrimaryFieldName()];
  • smartling-connector/trunk/inc/Smartling/Helpers/DetectChangesHelper.php

    r3333320 r3338937  
    2626
    2727    /**
     28     * @param string[] $contentTypes
    2829     * @return SubmissionEntity[]
    2930     */
    30     private function getSubmissions(int $blogId, int $contentId, string $contentType): array
     31    public function getSubmissions(int $blogId, int $contentId, array $contentTypes): array
    3132    {
    3233        try {
     
    3435                SubmissionEntity::FIELD_SOURCE_ID       => $contentId,
    3536                SubmissionEntity::FIELD_SOURCE_BLOG_ID  => $blogId,
    36                 SubmissionEntity::FIELD_CONTENT_TYPE    => $contentType,
     37                SubmissionEntity::FIELD_CONTENT_TYPE    => $contentTypes,
    3738                SubmissionEntity::FIELD_TARGET_BLOG_ID  => $this->settingsManager
    3839                                                                ->getProfileTargetBlogIdsByMainBlogId($blogId),
     
    105106    public function detectChanges(int $blogId, int $contentId, string $contentType): void
    106107    {
    107         $submissions = $this->getSubmissions($blogId, $contentId, $contentType);
     108        $submissions = $this->getSubmissions($blogId, $contentId, [$contentType]);
    108109
    109110        if (0 === count($submissions)) {
    110             $submissions = $this->getSubmissions($blogId, $contentId, AcfDynamicSupport::POST_TYPE_ACF_FIELD_GROUP);
    111             foreach ($submissions as $submission) {
    112                 $this->getLogger()->debug("Sync field group submissionId={$submission->getId()}");
    113                 $this->acfDynamicSupport->syncFieldGroup($submission);
     111            foreach ($this->getSubmissions($blogId, $contentId, $this->acfDynamicSupport->getTypes()) as $submission) {
     112                $this->getLogger()->debug("Sync ACF submissionId={$submission->getId()}");
     113                $this->acfDynamicSupport->syncAcfData($submission);
    114114            }
    115115
  • smartling-connector/trunk/inc/Smartling/Helpers/WordpressFunctionProxyHelper.php

    r3333320 r3338937  
    1616        return add_action(...func_get_args());
    1717    }
     18
     19    public function add_filter()
     20    {
     21        return add_filter(...func_get_args());
     22    }
     23
    1824    public function get_home_url()
    1925    {
  • smartling-connector/trunk/inc/Smartling/Processors/ContentEntitiesIOFactory.php

    r2998712 r3338937  
    44
    55use Smartling\DbAl\WordpressContentEntities\EntityHandler;
     6use Smartling\DbAl\WordpressContentEntities\PostEntityStd;
    67use Smartling\Exception\SmartlingConfigException;
    78use Smartling\Exception\SmartlingInvalidFactoryArgumentException;
     9use Smartling\Extensions\Acf\AcfDynamicSupport;
    810
    911class ContentEntitiesIOFactory extends SmartlingFactoryAbstract
    1012{
    11     public function __construct(bool $allowDefault = false, ?object $defaultHandler = null)
    12     {
     13    public function __construct(
     14        private AcfDynamicSupport $acfDynamicSupport,
     15        bool $allowDefault = false,
     16        ?object $defaultHandler = null,
     17    ) {
    1318        parent::__construct($allowDefault, $defaultHandler);
    1419        $this->message = 'Requested entity wrapper for content-type \'%s\' is not registered. Called by: %s';
     
    2126    public function getMapper(string $contentType): EntityHandler
    2227    {
     28        $this->processDynamicMappers();
    2329        $obj = $this->getHandler($contentType);
    2430
     
    2935        throw new SmartlingConfigException(self::class . __METHOD__ . ' expected return is ' . EntityHandler::class);
    3036    }
     37
     38    private function processDynamicMappers(): void
     39    {
     40        if ($this->acfDynamicSupport->isAcfActive()) {
     41            foreach ($this->acfDynamicSupport->getTypes() as $type) {
     42                $this->registerHandler($type, new PostEntityStd($type));
     43            }
     44        }
     45    }
    3146}
  • smartling-connector/trunk/inc/Smartling/Services/BlogRemovalHandler.php

    r2946970 r3338937  
    99use Smartling\Submissions\SubmissionEntity;
    1010use Smartling\Submissions\SubmissionManager;
     11use Smartling\Vendor\Smartling\AuditLog\Params\CreateRecordParameters;
    1112use Smartling\WP\WPHookInterface;
    1213
     
    3940    {
    4041        $submissions = $this->getSubmissions($blogId);
     42        $profiles = [];
     43        foreach ($this->settingsManager->getEntities() as $profile) {
     44            $array = [];
     45            foreach ($profile->getTargetLocales() as $locale) {
     46                $array[$locale->getBlogId()] = $profile;
     47            }
     48            $profiles[$profile->getSourceLocale()->getBlogId()] = $array;
     49        }
    4150
    4251        if (0 < count($submissions)) {
     
    6271                        )
    6372                    );
     73                    $profile = $profiles[$submission->getSourceBlogId()][$submission->getTargetBlogId()] ?? null;
     74                    if ($profile !== null) {
     75                        $this->apiWrapper->createAuditLogRecord(
     76                            $profile,
     77                            CreateRecordParameters::ACTION_TYPE_DELETE,
     78                            "Blog deletion handler, submissionId={$submission->getId()}, fileUri={$submission->getFileUri()}",
     79                            [],
     80                        );
     81                    }
    6482                    $this->apiWrapper->deleteFile($submission);
    6583                }
     
    6886
    6987        foreach ($this->settingsManager->getEntities() as $profile) {
    70             if ($profile->getOriginalBlogId()->getBlogId() === $blogId) {
     88            if ($profile->getSourceLocale()->getBlogId() === $blogId) {
    7189                $this->settingsManager->deleteProfile($profile->getId());
    7290                $this->getLogger()->notice("Deleted profile profileId={$profile->getId()} while deleting blogId=$blogId");
  • smartling-connector/trunk/inc/Smartling/Settings/ConfigurationProfileEntity.php

    r3212146 r3338937  
    187187    }
    188188
    189     public function getOriginalBlogId(): Locale
     189    public function getSourceLocale(): Locale
    190190    {
    191191        return $this->stateFields['original_blog_id'] ?? new Locale();
    192192    }
    193193
    194     public function setLocale(Locale $mainLocale): void
     194    public function setSourceLocale(Locale $mainLocale): void
    195195    {
    196196        $this->stateFields['original_blog_id'] = $mainLocale;
     
    205205        $locale = new Locale();
    206206        $locale->setBlogId($blogId);
    207         $this->setLocale($locale);
     207        $this->setSourceLocale($locale);
    208208    }
    209209
     
    399399        $state = parent::toArray(false);
    400400
    401         $state['original_blog_id'] = $this->getOriginalBlogId()->getBlogId();
     401        $state['original_blog_id'] = $this->getSourceLocale()->getBlogId();
    402402
    403403        $state['auto_authorize'] = !$state['auto_authorize'] ? 0 : 1;
  • smartling-connector/trunk/inc/Smartling/Settings/SettingsManager.php

    r3333320 r3338937  
    296296    protected function updateLabels(ConfigurationProfileEntity $entity): ConfigurationProfileEntity
    297297    {
    298         $mainLocaleBlogId = $entity->getOriginalBlogId()->getBlogId();
     298        $mainLocaleBlogId = $entity->getSourceLocale()->getBlogId();
    299299        if (0 < $mainLocaleBlogId) {
    300300            try {
    301                 $entity->getOriginalBlogId()->setLabel($this->getSiteHelper()
     301                $entity->getSourceLocale()->setLabel($this->getSiteHelper()
    302302                    ->getBlogLabelById($this->getPluginProxy(), $mainLocaleBlogId));
    303303            } catch (BlogNotFoundException $e) {
    304304                $this->getLogger()->notice("Got {$e->getMessage()}, removing profileId={$entity->getId()}");
    305                 $entity->getOriginalBlogId()->setLabel("* deleted blog *");
     305                $entity->getSourceLocale()->setLabel("* deleted blog *");
    306306                $this->deleteProfile($entity->getId());
    307307            }
  • smartling-connector/trunk/inc/Smartling/WP/Controller/BulkSubmitController.php

    r3077564 r3338937  
    66use Smartling\DbAl\LocalizationPluginProxyInterface;
    77use Smartling\DbAl\UploadQueueManager;
     8use Smartling\Extensions\Acf\AcfDynamicSupport;
    89use Smartling\Helpers\ArrayHelper;
    910use Smartling\Helpers\Cache;
     
    2223{
    2324    public function __construct(
     25        private AcfDynamicSupport $acfDynamicSupport,
    2426        private ApiWrapperInterface $apiWrapper,
    2527        LocalizationPluginProxyInterface $connector,
     
    8183            $profile = ArrayHelper::first($applicableProfiles);
    8284            $table = new BulkSubmitTableWidget(
     85                $this->acfDynamicSupport,
    8386                $this->apiWrapper,
    8487                $this->localizationPluginProxy,
  • smartling-connector/trunk/inc/Smartling/WP/Controller/ConfigurationProfileFormController.php

    r2821492 r3338937  
    213213            $locale->setLabel($this->siteHelper->getBlogLabelById($this->localizationPluginProxy, $defaultBlogId));
    214214
    215             $profile->setLocale($locale);
     215            $profile->setSourceLocale($locale);
    216216        }
    217217
  • smartling-connector/trunk/inc/Smartling/WP/Controller/PostBasedWidgetControllerStd.php

    r3333320 r3338937  
    612612    {
    613613        return $this->servedContentType === $postType
    614             // acf field groups are a private post type that needs to be handled
    615             || $postType === AcfDynamicSupport::POST_TYPE_ACF_FIELD_GROUP;
     614            // acf underlying posts are of private post types, that needs to be handled
     615            || in_array($postType, [AcfDynamicSupport::POST_TYPE_FIELD, AcfDynamicSupport::POST_TYPE_GROUP], true);
    616616    }
    617617}
  • smartling-connector/trunk/inc/Smartling/WP/Table/BulkSubmitTableWidget.php

    r3318909 r3338937  
    1313use Smartling\DbAl\UploadQueueManager;
    1414use Smartling\Exception\BlogNotFoundException;
    15 use Smartling\Helpers\ArrayHelper;
     15use Smartling\Extensions\Acf\AcfDynamicSupport;
    1616use Smartling\Helpers\CommonLogMessagesTrait;
    1717use Smartling\Helpers\DateTimeHelper;
     
    6868
    6969    public function __construct(
     70        private AcfDynamicSupport $acfDynamicSupport,
    7071        private ApiWrapperInterface $apiWrapper,
    7172        protected LocalizationPluginProxyInterface $localizationPluginProxy,
     
    8182        $this->defaultValues[static::CONTENT_TYPE_SELECT_ELEMENT_NAME] =
    8283            array_key_exists('post', $filteredAllowedTypes) ? 'post' :
    83                 ArrayHelper::first(array_keys($filteredAllowedTypes));
     84                $filteredAllowedTypes[array_key_first($filteredAllowedTypes)];
    8485
    8586        parent::__construct($this->_settings);
     
    232233                    [$id] = explode('-', $submission);
    233234                    $type = $this->getContentTypeFilterValue();
    234                     $curBlogId = $this->getProfile()->getOriginalBlogId()->getBlogId();
     235                    $curBlogId = $this->getProfile()->getSourceLocale()->getBlogId();
    235236                    foreach ($locales as $blogId => $blogName) {
    236237                        $submissionId =  $this->core->prepareForUpload(
     
    394395            }
    395396            $typesFiltered[$value] = $title;
     397        }
     398        if ($this->acfDynamicSupport->isAcfActive()) {
     399            $typesFiltered[AcfDynamicSupport::POST_TYPE_FIELD] = 'ACF Fields';
     400            $typesFiltered[AcfDynamicSupport::POST_TYPE_GROUP] = 'ACF Field Groups';
    396401        }
    397402
  • smartling-connector/trunk/inc/Smartling/WP/View/ConfigurationProfileForm.php

    r3212146 r3338937  
    433433                        $tagOptions = ['prompt' => __('Please select source locale', $domain)];
    434434                        $options = HtmlTagGeneratorHelper::renderSelectOptions(
    435                             $profile->getOriginalBlogId()->getBlogId(),
     435                            $profile->getSourceLocale()->getBlogId(),
    436436                            $locales,
    437437                            $tagOptions
     
    448448                        <p>
    449449                            <?= __('Site source language is: ', $domain) ?>
    450                             <strong><?= $profile->getOriginalBlogId()->getLabel() ?></strong>
     450                            <strong><?= $profile->getSourceLocale()->getLabel() ?></strong>
    451451                        </p>
    452452                        <p>
     
    457457                            'select',
    458458                            HtmlTagGeneratorHelper::renderSelectOptions(
    459                                 $profile->getOriginalBlogId()->getBlogId(),
     459                                $profile->getSourceLocale()->getBlogId(),
    460460                                $locales
    461461                            ),
     
    474474                        $targetLocales = $profile->getTargetLocales();
    475475                        foreach ($locales as $blogId => $label) {
    476                             if ($blogId === $profile->getOriginalBlogId()
     476                            if ($blogId === $profile->getSourceLocale()
    477477                                    ->getBlogId()
    478478                            ) {
  • smartling-connector/trunk/inc/config/services.yml

    r3335327 r3338937  
    210210  factory.contentIO:
    211211    class: Smartling\Processors\ContentEntitiesIOFactory
     212    arguments:
     213      - "@acf.dynamic.support"
    212214
    213215  manager.content.external:
     
    416418    class: Smartling\WP\Controller\BulkSubmitController
    417419    arguments:
     420      - "@acf.dynamic.support"
    418421      - "@api.wrapper.with.retries"
    419422      - "@multilang.proxy"
  • smartling-connector/trunk/readme.txt

    r3335327 r3338937  
    55Tested up to: 6.6.2
    66Requires PHP: 8.0
    7 Stable tag: 4.1.0
     7Stable tag: 4.2.0
    88License: GPLv2 or later
    99
     
    6363
    6464== Changelog ==
     65= 4.2.0 =
     66* Fixed cloned items having the same guid field
     67
    6568= 4.1.0 =
    6669* Fixed navigation menu item parent relations after translation
  • smartling-connector/trunk/smartling-connector.php

    r3335327 r3338937  
    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.1.0
     14 * Version:           4.2.0
    1515 * Author:            Smartling
    1616 * Author URI:        https://www.smartling.com
Note: See TracChangeset for help on using the changeset viewer.