Plugin Directory

Changeset 3006102


Ignore:
Timestamp:
12/06/2023 09:49:08 AM (2 years ago)
Author:
memsource
Message:

Version 4.6.0

Location:
memsource-connector/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • memsource-connector/trunk/css/memsource.css

    r2932560 r3006102  
    2424.memsource-admin-header .memsource-label { margin-left: 10px; font-size: 16px; padding-top: 2px; float: left; }
    2525.memsource-space-small { clear: both; margin-bottom: 12px; }
     26.memsource-space-smaller { clear: both; margin-bottom: 6px; }
    2627.memsource-space { clear: both; margin-bottom: 20px; }
    2728.memsource-space-big { clear: both; margin-bottom: 35px; }
  • memsource-connector/trunk/memsource.php

    r2949378 r3006102  
    55Plugin URI: https://support.phrase.com/hc/en-us/articles/5709657294620
    66Description: Localize WordPress websites with the help of professional translation tools: translation memories, terminology bases and quality checkers.
    7 Version: 4.5.1
     7Version: 4.6.0
    88Text Domain: memsource
    99Domain Path: /locale
     
    1818
    1919define('MEMSOURCE_PLUGIN_PATH', dirname(__FILE__));
    20 define('MEMSOURCE_PLUGIN_VERSION', '4.5.1');
     20define('MEMSOURCE_PLUGIN_VERSION', '4.6.0');
    2121define('MEMSOURCE_PLUGIN_DIR_URL', plugin_dir_url(__FILE__));
    2222
     
    243243    // URL rewrite:
    244244    isset($_POST['url-rewrite']) ? $optionsService->enableUrlRewrite() : $optionsService->disableUrlRewrite();
     245    isset($_POST['copy-permalink']) ? $optionsService->enableCopyPermalink() : $optionsService->disableCopyPermalink();
    245246
    246247    // Translation workflow:
  • memsource-connector/trunk/readme.txt

    r2949378 r3006102  
    3333== Changelog ==
    3434
     35= 4.6.0 =
     36*Release Date - 6 Dec 2023*
     37
     38* Added option to use the same permalink for source and target posts
     39
    3540= 4.5.1 =
    3641*Release Date - 8 Aug 2023*
  • memsource-connector/trunk/src/Page/ConnectorPage.php

    r2947778 r3006102  
    3636        $insertStatus = $this->optionsService->getInsertStatus();
    3737        $urlRewrite = $this->optionsService->isUrlRewriteEnabled();
     38        $copyPermalink = $this->optionsService->isCopyPermalinkEnabled();
    3839        ?>
    3940        <script>
     
    162163                                class="memsource-tooltip"
    163164                            >
    164                                 <?php _e('Rewrite URLs when exporting jobs from Phrase TMS', 'memsource'); ?></label>
     165                                <?php _e('Rewrite URLs when exporting jobs from Phrase TMS', 'memsource'); ?>
     166                            </label>
     167                            <div class="memsource-space-smaller"></div>
     168                            <input type="checkbox" id="copy-permalink" name="copy-permalink" value="on" <?php echo $copyPermalink ? 'checked' : ''; ?>/>
     169                            <label for="copy-permalink">
     170                                <?php _e('Translated content will use the same permalink as the source', 'memsource'); ?>
     171                            </label>
    165172                            <br/>
    166173                        </div>
  • memsource-connector/trunk/src/Service/Content/AbstractPostService.php

    r2947778 r3006102  
    243243        $mainSiteId = $this->translationPlugin->switchToSiteByTargetLang($language);
    244244
     245        // copy permalink from source to target
     246        $this->copyPermalinkIfEnabled($sourcePostId, $sourcePost->post_name, $targetPostId);
     247
    245248        // prepare response (translated post)
    246249        $targetPost = $this->getPost($targetPostId);
     
    269272
    270273        return $json;
     274    }
     275
     276    private function copyPermalinkIfEnabled($sourcePostId, $sourcePostName, $targetPostId) {
     277        if (!$this->optionsService->isCopyPermalinkEnabled()) {
     278            return;
     279        }
     280
     281        $permalink = $sourcePostName;
     282
     283        if (empty($permalink)) {
     284            $permalink = get_sample_permalink($sourcePostId)[1] ?? '';
     285        }
     286
     287        if (!empty($permalink)) {
     288            wp_update_post(['ID' => $targetPostId, 'post_name' => $permalink]);
     289            LogUtils::debug("Updated permalink: " . LogUtils::toStr($permalink));
     290        }
    271291    }
    272292
  • memsource-connector/trunk/src/Service/OptionsService.php

    r2947778 r3006102  
    1414    public const MULTILINGUAL_PLUGIN_MLP = 'MultilingualPress';
    1515
    16     public const URL_REWRITE_ON = 'on';
    17     public const URL_REWRITE_OFF = 'off';
     16    public const OPTION_ON = 'on';
     17    public const OPTION_OFF = 'off';
    1818
    1919    private $restNamespace = 'memsource/v1/connector';
     
    2727    private $optionInsertStatus = 'memsource_insert_status';
    2828    private $optionUrlRewrite = 'memsource_url_rewrite';
     29    private $optionCopyPermalink = 'memsource_copy_permalink';
    2930    private $optionTranslationWorkflow = 'memsource_translation_workflow';
    3031    private $optionAutomationWidgetId = 'memsource_automation_widget_id';
     
    4647        add_option($this->optionListStatus, 'publish');
    4748        add_option($this->optionInsertStatus, 'publish');
    48         add_option($this->optionUrlRewrite, self::URL_REWRITE_ON);
     49        add_option($this->optionUrlRewrite, self::OPTION_ON);
     50        add_option($this->optionCopyPermalink, self::OPTION_ON);
    4951        add_option($this->optionTranslationWorkflow, '[]');
    5052        add_option($this->optionAutomationWidgetId, null);
     
    148150    public function enableUrlRewrite()
    149151    {
    150         update_option($this->optionUrlRewrite, self::URL_REWRITE_ON);
     152        update_option($this->optionUrlRewrite, self::OPTION_ON);
    151153    }
    152154
    153155    public function disableUrlRewrite()
    154156    {
    155         update_option($this->optionUrlRewrite, self::URL_REWRITE_OFF);
     157        update_option($this->optionUrlRewrite, self::OPTION_OFF);
    156158    }
    157159
    158160    public function isUrlRewriteEnabled(): bool
    159161    {
    160         return get_option($this->optionUrlRewrite) !== self::URL_REWRITE_OFF;
     162        return get_option($this->optionUrlRewrite) !== self::OPTION_OFF;
     163    }
     164
     165    public function enableCopyPermalink()
     166    {
     167        update_option($this->optionCopyPermalink, self::OPTION_ON);
     168    }
     169
     170    public function disableCopyPermalink()
     171    {
     172        update_option($this->optionCopyPermalink, self::OPTION_OFF);
     173    }
     174
     175    public function isCopyPermalinkEnabled(): bool
     176    {
     177        return get_option($this->optionCopyPermalink) !== self::OPTION_OFF;
    161178    }
    162179
Note: See TracChangeset for help on using the changeset viewer.