Changeset 3452798
- Timestamp:
- 02/03/2026 11:18:39 AM (5 weeks ago)
- Location:
- memsource-connector/trunk
- Files:
-
- 39 edited
-
memsource.php (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
-
src/Controller/ContentController.php (modified) (1 diff)
-
src/Controller/UserController.php (modified) (1 diff)
-
src/Dao/AbstractDao.php (modified) (1 diff)
-
src/Dao/ContentSettingsDao.php (modified) (1 diff)
-
src/Dao/MetaDao.php (modified) (1 diff)
-
src/Dto/ContentSettingsDto.php (modified) (1 diff)
-
src/Dto/MetaKeyDto.php (modified) (1 diff)
-
src/Page/AdvancedPage.php (modified) (4 diffs)
-
src/Page/BlockPage.php (modified) (1 diff)
-
src/Page/ConnectorPage.php (modified) (1 diff)
-
src/Page/CustomFieldsPage.php (modified) (1 diff)
-
src/Page/LanguageMappingPage.php (modified) (1 diff)
-
src/Page/ShortcodePage.php (modified) (2 diffs)
-
src/Parser/BlockParser.php (modified) (2 diffs)
-
src/Parser/ParserResult.php (modified) (1 diff)
-
src/Parser/ShortcodeParser.php (modified) (11 diffs)
-
src/Registry/AppRegistry.php (modified) (1 diff)
-
src/Service/AuthService.php (modified) (1 diff)
-
src/Service/BlockService.php (modified) (1 diff)
-
src/Service/Content/AbstractContentService.php (modified) (1 diff)
-
src/Service/Content/AbstractPostService.php (modified) (1 diff)
-
src/Service/Content/CustomTypeTrait.php (modified) (1 diff)
-
src/Service/CustomFields/CustomFieldsDecodeService.php (modified) (1 diff)
-
src/Service/CustomFields/CustomFieldsEncodeService.php (modified) (1 diff)
-
src/Service/CustomFields/CustomFieldsService.php (modified) (1 diff)
-
src/Service/CustomFields/CustomFieldsSettingsService.php (modified) (1 diff)
-
src/Service/FilterService.php (modified) (1 diff)
-
src/Service/LanguageService.php (modified) (1 diff)
-
src/Service/Migrate/MigrateService.php (modified) (1 diff)
-
src/Service/Migrate/UpdateService.php (modified) (1 diff)
-
src/Service/OptionsService.php (modified) (1 diff)
-
src/Service/PlaceholderService.php (modified) (1 diff)
-
src/Service/ShortcodeService.php (modified) (1 diff)
-
src/Service/TransformService.php (modified) (1 diff)
-
src/Service/TranslationPlugin/TranslationPluginProvider.php (modified) (1 diff)
-
src/Service/TranslationWorkflowService.php (modified) (2 diffs)
-
src/Utils/LogUtils.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
memsource-connector/trunk/memsource.php
r3437807 r3452798 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.7. 77 Version: 4.7.8 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.7. 7');20 define('MEMSOURCE_PLUGIN_VERSION', '4.7.8'); 21 21 define('MEMSOURCE_PLUGIN_DIR_URL', plugin_dir_url(__FILE__)); 22 22 define('MEMSOURCE_PLUGIN_REQUIERED_PHP_VERSION', '7.4'); -
memsource-connector/trunk/readme.txt
r3437807 r3452798 33 33 == Changelog == 34 34 35 = 4.7.8 = 36 *Release Date - 3 Feb 2026* 37 38 * Fixed shortcode encoding and enabled registration of shortcodes with numerical values. 39 * Fixed bug related repeated attributes in custom blocks. 40 35 41 = 4.7.7 = 36 42 *Release Date - 12 Jan 2026* -
memsource-connector/trunk/src/Controller/ContentController.php
r3056870 r3452798 21 21 ]; 22 22 23 /** @var \wpdb */ 24 private $wpdb; 25 26 /** @var OptionsService */ 27 private $optionsService; 28 29 /** @var AuthService */ 30 private $authService; 23 private \wpdb $wpdb; 24 private OptionsService $optionsService; 25 private AuthService $authService; 26 private DatabaseService $databaseService; 27 private MetaDao $metaDao; 31 28 32 29 /** @var array|IContentService[] */ 33 private $contentServices = []; 34 35 /** @var DatabaseService */ 36 private $databaseService; 37 38 /** @var MetaDao */ 39 private $metaDao; 30 private array $contentServices = []; 40 31 41 32 public function __construct( -
memsource-connector/trunk/src/Controller/UserController.php
r2870027 r3452798 10 10 class UserController 11 11 { 12 /** @var OptionsService */ 13 private $optionsService; 14 15 /** @var AuthService */ 16 private $authService; 17 18 /** @var LanguageService */ 19 private $languageService; 12 private OptionsService $optionsService; 13 private AuthService $authService; 14 private LanguageService $languageService; 20 15 21 16 public function __construct( -
memsource-connector/trunk/src/Dao/AbstractDao.php
r2870027 r3452798 7 7 class AbstractDao 8 8 { 9 /** @var wpdb */ 10 protected $wpdb; 9 protected wpdb $wpdb; 11 10 12 11 public function __construct() -
memsource-connector/trunk/src/Dao/ContentSettingsDao.php
r2870027 r3452798 8 8 class ContentSettingsDao extends AbstractDao 9 9 { 10 /** @var string */ 11 private $contentSettings; 10 private string $contentSettings; 12 11 13 12 public function __construct() -
memsource-connector/trunk/src/Dao/MetaDao.php
r2870027 r3452798 7 7 class MetaDao extends AbstractDao 8 8 { 9 /** @var string */ 10 private $postmeta; 9 private ?string $postmeta; 11 10 12 /** @var string */ 13 private $termmeta; 11 private ?string $termmeta; 14 12 15 13 public function __construct() -
memsource-connector/trunk/src/Dto/ContentSettingsDto.php
r2870027 r3452798 5 5 final class ContentSettingsDto extends AbstractDto 6 6 { 7 protected $id;8 protected $hash;9 protected $contentId;10 protected $contentType;11 protected $send;7 protected string $id; 8 protected string $hash; 9 protected string $contentId; 10 protected string $contentType; 11 protected string $send; 12 12 13 13 public function getId(): string -
memsource-connector/trunk/src/Dto/MetaKeyDto.php
r2870027 r3452798 11 11 public const TYPE_TERM = 'term'; 12 12 13 protected $id;14 protected $name;15 protected $value;16 protected $type;13 protected string $id; 14 protected string $name; 15 protected string $value; 16 protected string $type; 17 17 18 18 public function getId(): string -
memsource-connector/trunk/src/Page/AdvancedPage.php
r3426034 r3452798 8 8 class AdvancedPage extends AbstractPage 9 9 { 10 /** @var OptionsService */ 11 private $optionsService; 10 private OptionsService $optionsService; 12 11 13 12 public function __construct(OptionsService $optionsService) … … 21 20 } 22 21 23 public function renderPage() 22 public function renderPage() // phpcs:ignore 24 23 { 25 24 ?> … … 122 121 123 122 <?php 124 $pathFromRequest = htmlspecialchars($_GET['path'] ?? ''); 125 if (!isset($_GET['error'])) { 126 $pathFromRequest = ''; 127 } 123 $pathFromRequest = ''; 124 if (isset($_GET['error']) && isset($_GET['path'])) { 125 $pathFromRequest = sanitize_text_field( 126 wp_unslash($_GET['path']) 127 ); 128 } 128 129 ?> 129 130 <input type="checkbox" id="logFilePathToggle" name="logFilePathToggle" 130 <?php echo(!empty($this->optionsService->getLogFilePath()) || !empty($pathFromRequest) ? " checked" : "") ?> 131 onchange="if (document.getElementById('logFilePathSection').style.display === 'none') {document.getElementById('logFilePathSection').style.display = '';} else {document.getElementById('logFilePathSection').style.display = 'none';}"> 132 <?php $tooltip = 'By default, the logs are stored in the plugin folder. You can override this behavior by setting the path to a custom folder (folder must exist and must be writable).'; ?> 133 <label for="logFilePathToggle" class="memsource-tooltip" title="<?php _e($tooltip, 'memsource'); ?>"><?php _e('Save logs to a custom folder', 'memsource'); ?></label> 131 <?php echo !empty($this->optionsService->getLogFilePath()) || !empty($pathFromRequest) ? " checked" : "" ?> 132 onchange="if (document.getElementById('logFilePathSection').style.display === 'none') {document.getElementById('logFilePathSection').style.display = '';} else {document.getElementById('logFilePathSection').style.display = 'none';}"> 133 <?php 134 $tooltip = __( 135 'By default, the logs are stored in the plugin folder. You can override this behavior by setting the path to a custom folder (folder must exist and must be writable).', 136 'memsource' 137 ); 138 ?> <label for="logFilePathToggle" class="memsource-tooltip" 139 title="<?php echo esc_attr($tooltip); ?>"><?php _e('Save logs to a custom folder', 'memsource'); ?></label> 134 140 <div class="memsource-space-small"></div> 135 141 136 <div id="logFilePathSection" <?php if (empty($this->optionsService->getLogFilePath()) && empty($pathFromRequest)) { ?>style="display: none;"<?php } ?>> 142 <div id="logFilePathSection" 143 <?php if (empty($this->optionsService->getLogFilePath()) && empty($pathFromRequest)) { 144 ?>style="display: none;"<?php 145 } ?>> 137 146 <label for="logFilePath"><?php _e('Path to a custom folder where logs will be saved:', 'memsource'); ?></label> 138 <input id="logFilePath" type="text" name="logFilePath" size="60" value="<?php echo empty($pathFromRequest) ? $this->optionsService->getLogFilePath() : $pathFromRequest; ?>"/> 147 <input id="logFilePath" type="text" name="logFilePath" size="60" 148 value="<?php echo empty($pathFromRequest) ? $this->optionsService->getLogFilePath() : $pathFromRequest; ?>"/> 139 149 </div> 140 150 … … 144 154 <?php 145 155 if ($_GET['error'] === LogUtils::ERROR_LOG_PATH_NOT_WRITABLE) { 146 echo sprintf(__('Provided folder \'%s\' is not writable', 'memsource'), $pathFromRequest); 156 /* translators: %s: path to the log folder */ 157 echo sprintf(__('Provided folder \'%s\' is not writable', 'memsource'), esc_html($pathFromRequest)); 147 158 } elseif ($_GET['error'] === LogUtils::ERROR_LOG_PATH_NOT_DIRECTORY) { 148 echo sprintf(__('Provided folder \'%s\' does not exist', 'memsource'), $pathFromRequest); 159 /* translators: %s: path to the log folder */ 160 echo sprintf(__('Provided folder \'%s\' does not exist', 'memsource'), esc_html($pathFromRequest)); 149 161 } elseif ($_GET['error'] === LogUtils::ERROR_RELATIVE_PATH_NOT_ALLOWED) { 150 162 _e('Relative path is not allowed, use absolute path instead', 'memsource'); -
memsource-connector/trunk/src/Page/BlockPage.php
r3056870 r3452798 7 7 class BlockPage extends AbstractPage 8 8 { 9 /** @var BlockService */ 10 private $blockService; 9 private BlockService $blockService; 11 10 12 11 public function __construct(BlockService $blockService) -
memsource-connector/trunk/src/Page/ConnectorPage.php
r3056870 r3452798 9 9 class ConnectorPage extends AbstractPage 10 10 { 11 /** @var OptionsService */ 12 private $optionsService; 13 14 /** @var TranslationWorkflowService */ 15 private $translationWorkflowService; 16 17 /** @var AcfPlugin */ 18 private $acfPlugin; 11 private OptionsService $optionsService; 12 private TranslationWorkflowService $translationWorkflowService; 13 private AcfPlugin $acfPlugin; 19 14 20 15 public function __construct(OptionsService $optionsService, TranslationWorkflowService $translationWorkflowService, AcfPlugin $acfPlugin) -
memsource-connector/trunk/src/Page/CustomFieldsPage.php
r3056870 r3452798 11 11 private const PAGE_SIZE = 50; 12 12 13 /** @var CustomFieldsSettingsService */ 14 private $customFieldsSettingsService; 15 16 /** @var MetaDao */ 17 private $metaDao; 13 private CustomFieldsSettingsService $customFieldsSettingsService; 14 private MetaDao $metaDao; 18 15 19 16 public function __construct(CustomFieldsSettingsService $customFieldsSettingsService, MetaDao $metaDao) -
memsource-connector/trunk/src/Page/LanguageMappingPage.php
r3056870 r3452798 11 11 private const MENU_SLUG = 'memsource-connector-language-mapping'; 12 12 13 /** @var DatabaseService */ 14 private $databaseService; 15 16 /** @var ITranslationPlugin */ 17 private $translationPlugin; 13 private DatabaseService $databaseService; 14 private ITranslationPlugin $translationPlugin; 18 15 19 16 public function __construct(DatabaseService $databaseService, ITranslationPlugin $translationPlugin) -
memsource-connector/trunk/src/Page/ShortcodePage.php
r3056870 r3452798 7 7 class ShortcodePage extends AbstractPage 8 8 { 9 private $shortcodeService;9 private ShortcodeService $shortcodeService; 10 10 11 11 public function __construct(ShortcodeService $shortcodeService) … … 26 26 var shortCode = jQuery('#shortCode').val(); 27 27 var attributes = jQuery('#attributes').val(); 28 if (!/^[ a-zA-Z_-]+$/.test(shortCode)) {29 alert(' <?php _e('Invalid shortcode. Please make sure it contains only letters, underscores and hyphens.', 'memsource'); ?>');28 if (!/^[A-Za-z][A-Za-z0-9_-]*$/.test(shortCode)) { 29 alert('Invalid shortcode. Please start with a letter; subsequent characters may include letters, numbers, underscores, and hyphens.'); 30 30 } 31 31 else if (attributes && !/^[a-zA-Z0-9_,-]+$/.test(attributes)) { -
memsource-connector/trunk/src/Parser/BlockParser.php
r3437807 r3452798 13 13 private const MEMSOURCE_BLOCK_COMMENT = 'MEMSOURCE_BLOCK_COMMENT'; 14 14 15 /** @var ArrayUtils */ 16 private $arrayUtils; 17 18 /** @var AuthUtils */ 19 private $authUtils; 20 21 /** @var BlockService */ 22 private $blockService; 23 24 /** @var string */ 25 private $content; 15 private ArrayUtils $arrayUtils; 16 private AuthUtils $authUtils; 17 private BlockService $blockService; 18 private string $content; 26 19 27 20 public function __construct(ArrayUtils $arrayUtils, AuthUtils $authUtils, BlockService $blockService) … … 101 94 $value = $this->encodeValueForRegex($value); 102 95 103 $pattern = '/(<!-- wp:' . 96 // Try two regex variants to find the attribute value inside the block comment 97 $patterns = [ 98 // Variant 1: direct string value right after the attribute 99 '/(<!-- wp:' . 104 100 preg_quote($block, '/') . 105 101 '.*?"' . 106 102 preg_quote($attribute, '/') . 107 '" :.*?")(' .103 '"\s*:\s*\")(' . 108 104 $value . 109 ')(".*?-->)/smi'; 110 111 $token = $this->authUtils->generateRandomToken(); 105 ')(".*?-->)/smi', 106 107 // Variant 2: attribute appears earlier, value appears later 108 '/(<!-- wp:' . 109 preg_quote($block, '/') . 110 '.*?"' . 111 preg_quote($attribute, '/') . 112 '":.*?\")(' . 113 $value . 114 ')(".*?-->)/smi', 115 ]; 116 112 117 $replaced = false; 113 114 try { 115 preg_match($pattern, $this->content, $matches); 116 } catch (\Throwable $exception) { 117 LogUtils::error('Failed processing regex', $exception); 118 LogUtils::debug('Extracting text from block, failed to match regex for', [ 119 'block' => $block, 120 'attribute' => $attribute, 121 'isValueScalar' => $isValueScalar, 122 ]); 123 } 124 125 if (isset($matches[2]) && !$this->isHtmlUrl($matches[2])) { 126 $lastKey = key(array_slice($matches, -1, 1, true)); 127 $replacement = '${1}' . $this->quoteReplacement( 128 '--><div class="memsource-block-start memsource-id-' . $token . '"></div>' . 129 json_decode('"' . $matches[2] . '"') . 130 '<div class="memsource-block-end memsource-id-' . $token . '"></div><!--' . $matches[$lastKey] 131 ); 132 133 $this->content = preg_replace($pattern, $replacement, $this->content, 1, $replaced); 118 $matches = []; 119 120 foreach ($patterns as $pattern) { 121 try { 122 preg_match($pattern, $this->content, $matches); 123 } catch (\Throwable $exception) { 124 LogUtils::error('Failed processing regex', $exception); 125 continue; 126 } 127 128 if (isset($matches[2]) && !$this->isHtmlUrl($matches[2])) { 129 $token = $this->authUtils->generateRandomToken(); 130 $lastKey = key(array_slice($matches, -1, 1, true)); 131 $replacement = '${1}' . $this->quoteReplacement( 132 '--><div class="memsource-block-start memsource-id-' . $token . '"></div>' . 133 json_decode('"' . $matches[2] . '"') . 134 '<div class="memsource-block-end memsource-id-' . $token . '"></div><!--' . $matches[$lastKey] 135 ); 136 137 $this->content = preg_replace($pattern, $replacement, $this->content, 1, $replaced); 138 if ($replaced) { 139 break; 140 } 141 } 134 142 } 135 143 -
memsource-connector/trunk/src/Parser/ParserResult.php
r2643752 r3452798 5 5 class ParserResult 6 6 { 7 /** @var string */ 8 private $transformationResult; 9 10 /** @var array */ 11 private $placeholders; 12 13 /** @var string */ 14 private $preparedToStore; 7 private string $transformationResult; 8 private string $preparedToStore; 9 private array $placeholders; // phpcs:ignore 15 10 16 11 public function __construct(string $transformationResult = '', array $placeholders = [], string $preparedToStore = '') -
memsource-connector/trunk/src/Parser/ShortcodeParser.php
r3056870 r3452798 12 12 private const SHORTCODE_WRAPPING_POST_CONTENT = 'memsource_body'; 13 13 14 /** @var AuthUtils */ 15 private $authUtils; 16 17 /** @var PlaceholderService */ 18 private $placeholderService; 14 private AuthUtils $authUtils; 15 private PlaceholderService $placeholderService; 19 16 20 17 public function __construct(AuthUtils $authUtils, PlaceholderService $placeholderService) … … 40 37 41 38 $result = ""; 42 $shortcodePostponeCount = [];43 39 $placeholders = []; 40 $noChangeCounter = 0; 44 41 45 42 // load WpBakery shortcodes so that function strip_shortcodes() works properly … … 53 50 // post contains both shortcodes and plain text on the top level 54 51 $contentWithoutShortcodes = wp_strip_all_tags(strip_shortcodes($content)); 55 if (! empty(trim($contentWithoutShortcodes)) && $content !== $contentWithoutShortcodes) {52 if (!empty(trim($contentWithoutShortcodes)) && $content !== $contentWithoutShortcodes) { 56 53 $content = '[' . self::SHORTCODE_WRAPPING_POST_CONTENT . ']' . $content . '[/' . self::SHORTCODE_WRAPPING_POST_CONTENT . ']'; 57 54 $availableShortcodes[] = [ … … 66 63 } 67 64 68 while (!empty($availableShortcodes)) { 69 foreach ($availableShortcodes as $shortcodeKey => $shortcodeObject) { 65 $shortcodeList = $availableShortcodes; 66 while ($shortcodeList) { 67 $madeProgress = false; 68 foreach ($shortcodeList as $shortcodeKey => $shortcodeObject) { 70 69 $shortcode = $shortcodeObject['tag']; 70 if (!$this->contentHasShortcodeTag($content, $shortcode)) { 71 unset($availableShortcodes[$shortcodeKey]); 72 continue; 73 } 71 74 72 75 // 1) non-pair tags: [shortcode attribute="text"] … … 87 90 } else { 88 91 $content = $newContent; 92 $madeProgress = true; 89 93 } 90 94 $result .= '<div id="' . $attributeWithId . '" class="memsource-attribute">' . 91 95 $extractedText . 92 '<div class="memsource-attribute-end" data-delimiter="' . $delimiter. '"></div>' .96 '<div class="memsource-attribute-end" data-delimiter="' . htmlspecialchars($delimiter, ENT_QUOTES) . '"></div>' . 93 97 '</div>'; 94 98 } … … 98 102 99 103 // 2) pair tags: [shortcode]text[/shortcode] 100 if (! isset($shortcodeObject['ignore_body']) || !$shortcodeObject['ignore_body']) {104 if (!isset($shortcodeObject['ignore_body']) || !$shortcodeObject['ignore_body']) { 101 105 $parsedShortcode = true; 102 106 while ($parsedShortcode) { … … 105 109 $attributes = preg_replace("|]$|", "", $parsedShortcode[0]); 106 110 $extractedText = $parsedShortcode[1]; 107 // shortcode contains another (nested) shortcode - process them first, postpone the current one 108 if ($extractedText !== strip_shortcodes($extractedText)) { 109 if (isset($shortcodePostponeCount[$shortcodeKey])) { 110 $shortcodePostponeCount[$shortcodeKey]++; 111 } else { 112 $shortcodePostponeCount[$shortcodeKey] = 1; 113 } 114 if ($shortcodePostponeCount[$shortcodeKey] < self::SHORTCODE_MAX_NESTED_LEVEL) { 115 continue 2; 116 } else { 117 error_log("Too many nested available_shortcodes detected, skipping for [$shortcode]"); 118 } 111 // shortcode contains another nested shortcode pair - process them first, postpone the current one 112 if ($this->containsNestedPairShortcodes($extractedText, $shortcodeList)) { 113 continue 2; 119 114 } 120 115 $shortcodeWithId = $shortcode . ':' . $this->authUtils->generateRandomToken(); … … 130 125 } else { 131 126 $content = $newContent; 127 $madeProgress = true; 132 128 } 133 129 // detect Base64 encoded content in fusion_code tag, decode and mark it in end:tag … … 147 143 } 148 144 } 149 unset($availableShortcodes[$shortcodeKey]); 145 } 146 if ($madeProgress) { 147 $noChangeCounter = 0; 148 } else { 149 $noChangeCounter++; 150 if ($noChangeCounter >= self::SHORTCODE_MAX_NESTED_LEVEL) { 151 break; 152 } 150 153 } 151 154 } … … 260 263 $uniqueId = $match[2]; 261 264 $delimiter = '"'; 262 if (sizeof($match) >= 5 ) {263 $delimiter = $match[5];265 if (sizeof($match) >= 5 && !empty($match[5])) { 266 $delimiter = html_entity_decode($match[5], ENT_QUOTES); 264 267 } 265 268 $translatedText = html_entity_decode($match[3]); … … 280 283 return $storedContent; 281 284 } 285 286 /** 287 * Parse text for any pairs of any shortcodes in given array. 288 * 289 * Sample input: 290 * $content = '[tag id="1"]text[/tag]'; 291 * $shortCodeName = 'tag'; 292 * Output: 293 * true 294 * 295 * @param string $text Post, page or any other content. 296 * @param array $availableShortcodes Array of all available shortcodes. 297 * @return bool Returns boolean if text contains pair of any available shortcodes 298 */ 299 private function containsNestedPairShortcodes(string $text, array $availableShortcodes): bool 300 { 301 foreach ($availableShortcodes as $shortcode) { 302 $tag = preg_quote($shortcode['tag'], '#'); 303 // pair shortcode pattern: [tag ...] ... [/tag] 304 if (preg_match("#\\[{$tag}(\\s+[^\\]]*\\]|\\])(.*?)\\[/{$tag}\\]#sm", $text)) { 305 return true; 306 } 307 } 308 return false; 309 } 310 311 /** 312 * Parse content for shortcode tag and returns boolean. 313 * 314 * Sample input: 315 * $content = '[tag id="1"]text[/tag]'; 316 * $tag = 'tag'; 317 * Output: 318 * true 319 * 320 * @param string $content Post, page or any other content. 321 * @param string $tag Tag of shortcode. 322 * @return bool Returns boolean text contains given shortcode tag 323 */ 324 private function contentHasShortcodeTag(string $content, string $tag): bool 325 { 326 $pattern = '/' . get_shortcode_regex([$tag]) . '/s'; 327 return (bool) preg_match($pattern, $content); 328 } 282 329 } -
memsource-connector/trunk/src/Registry/AppRegistry.php
r2870027 r3452798 55 55 class AppRegistry 56 56 { 57 /** @var OptionsService */ 58 private $optionsService; 59 60 /** @var MigrateService */ 61 private $migrateService; 62 63 /** @var DatabaseService */ 64 private $databaseService; 65 66 /** @var LanguageService */ 67 private $languageService; 68 69 /** @var FilterService */ 70 private $filterService; 71 72 /** @var ShortcodeService */ 73 private $shortcodeService; 74 75 /** @var TranslationWorkflowService */ 76 private $translationWorkflowService; 77 78 /** @var TransformService */ 79 private $transformService; 80 81 /** @var BlockService */ 82 private $blockService; 83 84 /** @var CustomFieldsDecodeService */ 85 private $customFieldsDecodeService; 86 87 /** @var CustomFieldsService */ 88 private $customFieldsService; 89 90 /** @var ITranslationPlugin */ 91 private $translationPlugin; 92 93 /** @var UserController */ 94 private $userController; 95 96 /** @var ContentController */ 97 private $contentController; 98 99 /** @var BlockPage */ 100 private $blockPage; 101 102 /** @var ConnectorPage */ 103 private $connectorPage; 104 105 /** @var CustomFieldsPage */ 106 private $customFieldsPage; 107 108 /** @var AdvancedPage */ 109 private $advancedPage; 110 111 /** @var LanguageMappingPage */ 112 private $languageMappingPage; 113 114 /** @var ShortcodePage */ 115 private $shortcodePage; 116 117 /** @var MetaDao */ 118 private $metaDao; 57 private OptionsService $optionsService; 58 private MigrateService $migrateService; 59 private DatabaseService $databaseService; 60 private LanguageService $languageService; 61 private FilterService $filterService; 62 private ShortcodeService $shortcodeService; 63 private TranslationWorkflowService $translationWorkflowService; 64 private TransformService $transformService; 65 private BlockService $blockService; 66 private CustomFieldsDecodeService $customFieldsDecodeService; 67 private CustomFieldsService $customFieldsService; 68 private ITranslationPlugin $translationPlugin; 69 private UserController $userController; 70 private ContentController $contentController; 71 private BlockPage $blockPage; 72 private ConnectorPage $connectorPage; 73 private CustomFieldsPage $customFieldsPage; 74 private AdvancedPage $advancedPage; 75 private LanguageMappingPage $languageMappingPage; 76 private ShortcodePage $shortcodePage; 77 private MetaDao $metaDao; 119 78 120 79 public function __construct() -
memsource-connector/trunk/src/Service/AuthService.php
r3056870 r3452798 7 7 class AuthService 8 8 { 9 /** @var OptionsService */ 10 private $optionsService; 11 12 /** @var ITranslationPlugin */ 13 private $translationPlugin; 9 private OptionsService $optionsService; 10 private ITranslationPlugin $translationPlugin; 14 11 15 12 public function __construct(OptionsService $optionsService, ITranslationPlugin $translationPlugin) -
memsource-connector/trunk/src/Service/BlockService.php
r3056870 r3452798 13 13 private const MAX_EXPANSIONS = 100; 14 14 15 private $predefinedBlocks = []; 16 private $installedBlocks = []; 17 private $customBlocks = []; 18 private $allBlocks = []; 19 20 private $initialized = false; 15 private array $predefinedBlocks = []; // phpcs:ignore 16 private array $installedBlocks = []; // phpcs:ignore 17 private array $customBlocks = []; // phpcs:ignore 18 private array $allBlocks = []; // phpcs:ignore 19 private bool $initialized = false; 21 20 22 21 /** -
memsource-connector/trunk/src/Service/Content/AbstractContentService.php
r2870027 r3452798 11 11 abstract class AbstractContentService 12 12 { 13 /** @var LanguageService */ 14 protected $languageService; 15 16 /** @var ITranslationPlugin */ 17 protected $translationPlugin; 18 19 /** @var TransformService */ 20 protected $transformService; 21 22 /** @var CustomFieldsDecodeService */ 23 protected $customFieldsDecodeService; 13 protected LanguageService $languageService; 14 protected ITranslationPlugin $translationPlugin; 15 protected TransformService $transformService; 16 protected CustomFieldsDecodeService $customFieldsDecodeService; 24 17 25 18 public function __construct( -
memsource-connector/trunk/src/Service/Content/AbstractPostService.php
r3056870 r3452798 21 21 abstract class AbstractPostService extends AbstractContentService implements IContentService 22 22 { 23 /** @var OptionsService */ 24 protected $optionsService; 25 26 /** @var FilterService */ 27 private $filterService; 28 29 /** @var CustomFieldsService */ 30 private $customFieldsService; 31 32 /** @var TranslationWorkflowService */ 33 private $translationWorkflowService; 34 35 /** @var MetaDao */ 36 private $metaDao; 23 protected OptionsService $optionsService; 24 25 private FilterService $filterService; 26 private CustomFieldsService $customFieldsService; 27 private TranslationWorkflowService $translationWorkflowService; 28 private MetaDao $metaDao; 37 29 38 30 public function __construct( -
memsource-connector/trunk/src/Service/Content/CustomTypeTrait.php
r2870027 r3452798 5 5 trait CustomTypeTrait 6 6 { 7 /** @var string */ 8 protected $label; 9 10 /** @var string */ 11 protected $type; 7 protected string $label; 8 protected string $type; 12 9 13 10 public function setType(string $type) -
memsource-connector/trunk/src/Service/CustomFields/CustomFieldsDecodeService.php
r2870027 r3452798 9 9 class CustomFieldsDecodeService 10 10 { 11 /** @var AcfPlugin */ 12 private $acfPlugin; 13 14 /** @var ElementorPlugin */ 15 private $elementorPlugin; 16 17 /** @var SeoPlugin */ 18 private $seoPlugin; 11 private AcfPlugin $acfPlugin; 12 private ElementorPlugin $elementorPlugin; 13 private SeoPlugin $seoPlugin; 19 14 20 15 public function __construct( -
memsource-connector/trunk/src/Service/CustomFields/CustomFieldsEncodeService.php
r3056870 r3452798 16 16 private const RESULT_PLACEHOLDERS = 'placeholders'; 17 17 18 /** @var AcfPlugin */ 19 private $acfPlugin; 20 21 /** @var ElementorPlugin */ 22 private $elementorPlugin; 23 24 /** @var SeoPlugin */ 25 private $seoPlugin; 26 27 /** @var AuthUtils */ 28 private $authUtils; 29 30 /** @var PlaceholderService */ 31 private $placeholderService; 32 33 /** @var CustomFieldsSettingsService */ 34 private $customFieldsSettingsService; 35 36 /** @var CustomFieldsService */ 37 private $customFieldsService; 38 39 /** @var MetaDao */ 40 private $metaDao; 18 private AcfPlugin $acfPlugin; 19 private ElementorPlugin $elementorPlugin; 20 private SeoPlugin $seoPlugin; 21 private AuthUtils $authUtils; 22 private PlaceholderService $placeholderService; 23 private CustomFieldsSettingsService $customFieldsSettingsService; 24 private CustomFieldsService $customFieldsService; 25 private MetaDao $metaDao; 41 26 42 27 public function __construct( -
memsource-connector/trunk/src/Service/CustomFields/CustomFieldsService.php
r3056870 r3452798 11 11 class CustomFieldsService 12 12 { 13 /** @var SeoPlugin */ 14 private $seoPlugin; 15 16 /** @var TranslationWorkflowService */ 17 private $translationWorkflowService; 18 19 /** @var CustomFieldsSettingsService */ 20 private $customFieldsSettingsService; 21 22 /** @var MetaDao */ 23 private $metaDao; 13 private SeoPlugin $seoPlugin; 14 private TranslationWorkflowService $translationWorkflowService; 15 private CustomFieldsSettingsService $customFieldsSettingsService; 16 private MetaDao $metaDao; 24 17 25 18 public function __construct( -
memsource-connector/trunk/src/Service/CustomFields/CustomFieldsSettingsService.php
r2870027 r3452798 8 8 class CustomFieldsSettingsService 9 9 { 10 /** @var ContentSettingsDao */ 11 private $contentSettingsDao; 10 private ContentSettingsDao $contentSettingsDao; 12 11 13 12 public function __construct(ContentSettingsDao $contentSettingsDao) -
memsource-connector/trunk/src/Service/FilterService.php
r2870027 r3452798 10 10 class FilterService 11 11 { 12 /** @var ITranslationPlugin */ 13 private $translationPlugin; 12 private ITranslationPlugin $translationPlugin; 14 13 15 14 public function __construct(ITranslationPlugin $translationPlugin) -
memsource-connector/trunk/src/Service/LanguageService.php
r2870027 r3452798 7 7 class LanguageService 8 8 { 9 /** @var DatabaseService */ 10 private $databaseService; 9 private DatabaseService $databaseService; 11 10 12 /** @var ITranslationPlugin */ 13 private $translationPlugin; 11 private ITranslationPlugin $translationPlugin; 14 12 15 13 public function __construct(DatabaseService $databaseService, ITranslationPlugin $translationPlugin) -
memsource-connector/trunk/src/Service/Migrate/MigrateService.php
r2870027 r3452798 7 7 class MigrateService 8 8 { 9 /** 10 * @var SchemaService 11 */ 12 private $schemaService; 13 14 /** 15 * @var UpdateService 16 */ 17 private $updateService; 18 19 /** 20 * @var OptionsService 21 */ 22 private $optionsService; 9 private SchemaService $schemaService; 10 private UpdateService $updateService; 11 private OptionsService $optionsService; 23 12 24 13 public function __construct(SchemaService $schemaService, UpdateService $updateService, OptionsService $optionsService) -
memsource-connector/trunk/src/Service/Migrate/UpdateService.php
r3056870 r3452798 8 8 class UpdateService 9 9 { 10 private static $versionHistory = ['2.0']; 10 /** @var string[] */ 11 private static array $versionHistory = ['2.0']; 11 12 12 13 public function updateDatabase($lastVersion) -
memsource-connector/trunk/src/Service/OptionsService.php
r3056870 r3452798 17 17 public const OPTION_OFF = 'off'; 18 18 19 private $restNamespace = 'memsource/v1/connector';20 21 private $optionVersion = 'memsource_version';22 private $optionDbVersion = 'memsource_db_version';23 private $optionDebugMode = 'memsource_debug_mode';24 private $optionToken = 'memsource_token';25 private $optionAdminUser = 'memsource_admin_user';26 private $optionListStatus = 'memsource_list_status';27 private $optionInsertStatus = 'memsource_insert_status';28 private $optionUrlRewrite = 'memsource_url_rewrite';29 private $optionCopyPermalink = 'memsource_copy_permalink';30 private $optionTranslationWorkflow = 'memsource_translation_workflow';31 private $optionAutomationWidgetId = 'memsource_automation_widget_id';32 private $optionSourceLanguage = 'memsource_source_language';33 private $optionTargetLanguages = 'memsource_target_languages';34 private $optionMultilingualPlugin = 'memsource_multilingual_plugin';35 private $optionLogFilePath = 'memsource_log_file_path';19 private string $restNamespace = 'memsource/v1/connector'; 20 21 private string $optionVersion = 'memsource_version'; 22 private string $optionDbVersion = 'memsource_db_version'; 23 private string $optionDebugMode = 'memsource_debug_mode'; 24 private string $optionToken = 'memsource_token'; 25 private string $optionAdminUser = 'memsource_admin_user'; 26 private string $optionListStatus = 'memsource_list_status'; 27 private string $optionInsertStatus = 'memsource_insert_status'; 28 private string $optionUrlRewrite = 'memsource_url_rewrite'; 29 private string $optionCopyPermalink = 'memsource_copy_permalink'; 30 private string $optionTranslationWorkflow = 'memsource_translation_workflow'; 31 private string $optionAutomationWidgetId = 'memsource_automation_widget_id'; 32 private string $optionSourceLanguage = 'memsource_source_language'; 33 private string $optionTargetLanguages = 'memsource_target_languages'; 34 private string $optionMultilingualPlugin = 'memsource_multilingual_plugin'; 35 private string $optionLogFilePath = 'memsource_log_file_path'; 36 36 37 37 /** -
memsource-connector/trunk/src/Service/PlaceholderService.php
r3275856 r3452798 7 7 class PlaceholderService 8 8 { 9 /** @var AuthUtils */ 10 private $authUtils; 9 private AuthUtils $authUtils; 11 10 12 11 public function __construct(AuthUtils $authUtils) -
memsource-connector/trunk/src/Service/ShortcodeService.php
r3056870 r3452798 9 9 class ShortcodeService 10 10 { 11 private $shortcodeCache = [];12 private $shortcodeTypes = [];11 private array $shortcodeCache = []; // phpcs:ignore 12 private array $shortcodeTypes = []; // phpcs:ignore 13 13 14 14 public function init() -
memsource-connector/trunk/src/Service/TransformService.php
r3411119 r3452798 26 26 public const RESULT_EXCERPT = 'EXCERPT'; 27 27 28 /** @var ShortcodeService */ 29 private $shortcodeService; 30 31 /** @var ShortCodeParser */ 32 private $shortcodeParser; 33 34 /** @var BlockParser */ 35 private $blockParser; 36 37 /** @var ElementorPlugin */ 38 private $elementorPlugin; 39 40 /** @var CustomFieldsDecodeService */ 41 private $customFieldsDecodeService; 42 43 /** @var CustomFieldsEncodeService */ 44 private $customFieldsEncodeService; 45 46 /** @var AuthUtils */ 47 private $authUtils; 48 49 /** @var PlaceholderService */ 50 private $placeholderService; 51 52 /** @var ExcerptParser */ 53 private $excerptParser; 28 private ShortcodeService $shortcodeService; 29 private ShortCodeParser $shortcodeParser; 30 private BlockParser $blockParser; 31 private ElementorPlugin $elementorPlugin; 32 private CustomFieldsDecodeService $customFieldsDecodeService; 33 private CustomFieldsEncodeService $customFieldsEncodeService; 34 private AuthUtils $authUtils; 35 private PlaceholderService $placeholderService; 36 private ExcerptParser $excerptParser; 54 37 55 38 public function __construct( -
memsource-connector/trunk/src/Service/TranslationPlugin/TranslationPluginProvider.php
r2870027 r3452798 9 9 private const DEFAULT_TRANSLATION_PLUGIN = ''; 10 10 11 /** @var OptionsService */ 12 private $optionsService; 13 14 /** @var ITranslationPlugin[] */ 15 private $translationPlugins = []; 11 private OptionsService $optionsService; 12 private array $translationPlugins = []; // phpcs:ignore 16 13 17 14 public function __construct(OptionsService $optionsService) -
memsource-connector/trunk/src/Service/TranslationWorkflowService.php
r3067665 r3452798 16 16 public const FIELD_NAME_TARGET_LANGUAGES = 'field-name-target-languages'; 17 17 18 /** @var OptionsService */ 19 private $optionsService; 18 private OptionsService $optionsService; 19 private ?bool $customFieldExists = null; 20 private ITranslationPlugin $translationPlugin; 20 21 21 /** @var array|null */ 22 private $options = null; 23 24 /** @var bool|null */ 25 private $customFieldExists = null; 26 27 /** @var ITranslationPlugin */ 28 private $translationPlugin; 22 private ?array $options = null; // phpcs:ignore 29 23 30 24 public function __construct(OptionsService $optionsService, ITranslationPlugin $translationPlugin) … … 196 190 global $acf; 197 191 global $shortcode_tags; // phpcs:ignore 198 return isset($acf) || isset($shortcode_tags['acf']); 192 return isset($acf) || isset($shortcode_tags['acf']); // phpcs:ignore 199 193 } 200 194 } -
memsource-connector/trunk/src/Utils/LogUtils.php
r3056870 r3452798 13 13 public const LOG_EMAIL_RECIPIENT = 'integrations@phrase.com'; 14 14 15 public const ERROR_LOG_PATH_NOT_WRITABLE = 'LOG_PATH_NOT_WRITABLE'; 16 public const ERROR_LOG_PATH_NOT_DIRECTORY = 'LOG_PATH_NOT_DIRECTORY'; 17 public const ERROR_RELATIVE_PATH_NOT_ALLOWED = 'RELATIVE_PATH_NOT_ALLOWED'; 18 15 19 private const DEBUG = 'DEBUG'; 16 20 private const INFO = 'INFO'; … … 21 25 private const SIZE_MB = 1048576; 22 26 private const SIZE_GB = 1073741824; 23 24 const ERROR_LOG_PATH_NOT_WRITABLE = 'LOG_PATH_NOT_WRITABLE';25 const ERROR_LOG_PATH_NOT_DIRECTORY = 'LOG_PATH_NOT_DIRECTORY';26 const ERROR_RELATIVE_PATH_NOT_ALLOWED = 'RELATIVE_PATH_NOT_ALLOWED';27 27 28 28 public static function getLogFilePath(): string
Note: See TracChangeset
for help on using the changeset viewer.