Changeset 3006102
- Timestamp:
- 12/06/2023 09:49:08 AM (2 years ago)
- Location:
- memsource-connector/trunk
- Files:
-
- 6 edited
-
css/memsource.css (modified) (1 diff)
-
memsource.php (modified) (3 diffs)
-
readme.txt (modified) (1 diff)
-
src/Page/ConnectorPage.php (modified) (2 diffs)
-
src/Service/Content/AbstractPostService.php (modified) (2 diffs)
-
src/Service/OptionsService.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
memsource-connector/trunk/css/memsource.css
r2932560 r3006102 24 24 .memsource-admin-header .memsource-label { margin-left: 10px; font-size: 16px; padding-top: 2px; float: left; } 25 25 .memsource-space-small { clear: both; margin-bottom: 12px; } 26 .memsource-space-smaller { clear: both; margin-bottom: 6px; } 26 27 .memsource-space { clear: both; margin-bottom: 20px; } 27 28 .memsource-space-big { clear: both; margin-bottom: 35px; } -
memsource-connector/trunk/memsource.php
r2949378 r3006102 5 5 Plugin URI: https://support.phrase.com/hc/en-us/articles/5709657294620 6 6 Description: Localize WordPress websites with the help of professional translation tools: translation memories, terminology bases and quality checkers. 7 Version: 4. 5.17 Version: 4.6.0 8 8 Text Domain: memsource 9 9 Domain Path: /locale … … 18 18 19 19 define('MEMSOURCE_PLUGIN_PATH', dirname(__FILE__)); 20 define('MEMSOURCE_PLUGIN_VERSION', '4. 5.1');20 define('MEMSOURCE_PLUGIN_VERSION', '4.6.0'); 21 21 define('MEMSOURCE_PLUGIN_DIR_URL', plugin_dir_url(__FILE__)); 22 22 … … 243 243 // URL rewrite: 244 244 isset($_POST['url-rewrite']) ? $optionsService->enableUrlRewrite() : $optionsService->disableUrlRewrite(); 245 isset($_POST['copy-permalink']) ? $optionsService->enableCopyPermalink() : $optionsService->disableCopyPermalink(); 245 246 246 247 // Translation workflow: -
memsource-connector/trunk/readme.txt
r2949378 r3006102 33 33 == Changelog == 34 34 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 35 40 = 4.5.1 = 36 41 *Release Date - 8 Aug 2023* -
memsource-connector/trunk/src/Page/ConnectorPage.php
r2947778 r3006102 36 36 $insertStatus = $this->optionsService->getInsertStatus(); 37 37 $urlRewrite = $this->optionsService->isUrlRewriteEnabled(); 38 $copyPermalink = $this->optionsService->isCopyPermalinkEnabled(); 38 39 ?> 39 40 <script> … … 162 163 class="memsource-tooltip" 163 164 > 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> 165 172 <br/> 166 173 </div> -
memsource-connector/trunk/src/Service/Content/AbstractPostService.php
r2947778 r3006102 243 243 $mainSiteId = $this->translationPlugin->switchToSiteByTargetLang($language); 244 244 245 // copy permalink from source to target 246 $this->copyPermalinkIfEnabled($sourcePostId, $sourcePost->post_name, $targetPostId); 247 245 248 // prepare response (translated post) 246 249 $targetPost = $this->getPost($targetPostId); … … 269 272 270 273 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 } 271 291 } 272 292 -
memsource-connector/trunk/src/Service/OptionsService.php
r2947778 r3006102 14 14 public const MULTILINGUAL_PLUGIN_MLP = 'MultilingualPress'; 15 15 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'; 18 18 19 19 private $restNamespace = 'memsource/v1/connector'; … … 27 27 private $optionInsertStatus = 'memsource_insert_status'; 28 28 private $optionUrlRewrite = 'memsource_url_rewrite'; 29 private $optionCopyPermalink = 'memsource_copy_permalink'; 29 30 private $optionTranslationWorkflow = 'memsource_translation_workflow'; 30 31 private $optionAutomationWidgetId = 'memsource_automation_widget_id'; … … 46 47 add_option($this->optionListStatus, 'publish'); 47 48 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); 49 51 add_option($this->optionTranslationWorkflow, '[]'); 50 52 add_option($this->optionAutomationWidgetId, null); … … 148 150 public function enableUrlRewrite() 149 151 { 150 update_option($this->optionUrlRewrite, self:: URL_REWRITE_ON);152 update_option($this->optionUrlRewrite, self::OPTION_ON); 151 153 } 152 154 153 155 public function disableUrlRewrite() 154 156 { 155 update_option($this->optionUrlRewrite, self:: URL_REWRITE_OFF);157 update_option($this->optionUrlRewrite, self::OPTION_OFF); 156 158 } 157 159 158 160 public function isUrlRewriteEnabled(): bool 159 161 { 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; 161 178 } 162 179
Note: See TracChangeset
for help on using the changeset viewer.