Translate content
-
-
-
-
-
Please wait...
-
-
- New Job
- Existing Job
- = $isBulkSubmitPage ? '' : 'Clone '?>
-
-
-
-
- Existing jobs
-
-
-
-
-
-
- Name
-
-
-
- Description
-
-
-
- Due Date
-
-
-
- Authorize Job
- getAutoAuthorize() ? 'checked="checked"' : '' ?>/>
-
-
-
- getTargetLocales();
- ArrayHelper::sortLocales($locales);
- ?>
-
- Target Locales
-
-
- = WPAbstract::checkUncheckBlock($widgetName) ?>
-
-
- isEnabled()) {
- continue;
- }
-
- $localeList[] = $locale->getBlogId();
- ?>
-
- = WPAbstract::localeSelectionCheckboxBlock(
- $widgetName,
- $locale->getBlogId(),
- $locale->getLabel(),
- false,
- true,
- '',
- [
- 'data-smartling-locale' => $locale->getSmartlingLocale(),
- ]
- ) ?>
-
-
-
-
-
-
-
- Related content
-
- = HtmlTagGeneratorHelper::tag(
- 'select',
- HtmlTagGeneratorHelper::renderSelectOptions(
- GlobalSettingsManager::getRelatedContentSelectState(),
+
+
Please wait...
+
+
+ New Job
+ Existing Job
+ = $isBulkSubmitPage ? '' : 'Clone '?>
+
+
+
+
+ Existing jobs
+
+
+
+
+
+
+ Name
+
+
+
+ Description
+
+
+
+ Due Date
+
+
+
+ Authorize Job
+ getAutoAuthorize() ? 'checked="checked"' : '' ?>/>
+
+
+
+ getTargetLocales();
+ ArrayHelper::sortLocales($locales);
+ ?>
+
+ Target Locales
+
+
+ = WPAbstract::checkUncheckBlock($widgetName) ?>
+
+
+ isEnabled()) {
+ continue;
+ }
+
+ $localeList[] = $locale->getBlogId();
+ ?>
+
+ = WPAbstract::localeSelectionCheckboxBlock(
+ $widgetName,
+ $locale->getBlogId(),
+ $locale->getLabel(),
+ false,
+ true,
+ '',
[
- 0 => 'Don\'t send related content',
- 1 => 'Send related content one level deep',
- 2 => 'Send related content two levels deep',
+ 'data-smartling-locale' => $locale->getSmartlingLocale(),
]
- ),
- [
- 'id' => 'depth',
- 'name' => 'depth',
- ],
- )?>
-
-
-
- Related content to be uploaded:
-
-
-
-
-
-
-
-
- Create Job
-
- Add to selected Job
-
- Clone
-
-
-
-
-
-
-
-
-
-
-
+ ) ?>
+
+
+
+
+
+
+
+ Related content
+
+ = HtmlTagGeneratorHelper::tag(
+ 'select',
+ HtmlTagGeneratorHelper::renderSelectOptions(
+ GlobalSettingsManager::getRelatedContentSelectState(),
+ [
+ 0 => 'Don\'t send related content',
+ 1 => 'Send related content one level deep',
+ 2 => 'Send related content two levels deep',
+ ]
+ ),
+ [
+ 'id' => 'depth',
+ 'name' => 'depth',
+ ],
+ )?>
+
+
+
+ Related content to be uploaded:
+
+
+
+
+
+
+
+
+ Create Job
+
+ Add to selected Job
+
+ Clone
+
+
+
+
-
-
resolveTemplate(true);
+ $this->assertDivBalanced($html, 'taxonomy edit screen ($needWrapper=true)');
+ }
+
+ public function testHtmlDivTagsBalanceOnPostEditScreen(): void
+ {
+ $html = $this->resolveTemplate(false);
+ $this->assertDivBalanced($html, 'post edit screen ($needWrapper=false)');
+ }
+
+ public function testHtmlDivTagsBalanceOnBulkSubmitScreen(): void
+ {
+ $html = $this->resolveTemplate(false, true);
+ $this->assertDivBalanced($html, 'bulk submit screen ($isBulkSubmitPage=true)');
+ }
+
+ public function testHiddenWrapperHasClosingTag(): void
+ {
+ $html = $this->resolveTemplate(false);
+
+ $this->assertSame(
+ 1,
+ preg_match(
+ '#
#i',
+ $html,
+ $matches,
+ PREG_OFFSET_CAPTURE
+ ),
+ 'Hidden display:none wrapper opening
should exist'
+ );
+
+ $tail = substr($html, $matches[0][1]);
+ $opens = preg_match_all('#
#i', $tail);
+
+ $this->assertSame(
+ $opens,
+ $closes,
+ 'Hidden display:none wrapper must have a matching closing
' .
+ '(an unclosed wrapper here is what caused WP-1004).'
+ );
+ }
+
+ private function resolveTemplate(bool $needWrapper, bool $isBulkSubmitPage = false): string
+ {
+ $source = $this->stripNonHtml(file_get_contents(self::VIEW_FILE));
+
+ $source = preg_replace_callback(
+ '#<\?php\s+if\s*\(\s*\$needWrapper\s*\)\s*:\s*\?>((?:(?!<\?php\s+endif).)*)<\?php\s+endif\s*;\s*\?>#s',
+ static fn(array $m): string => $needWrapper ? $m[1] : '',
+ $source
+ );
+
+ $source = preg_replace_callback(
+ '#<\?php\s.*?if\s*\(\s*!\$isBulkSubmitPage\s*\)\s*:\s*\?>((?:(?!<\?php\s+endif).)*)<\?php\s+endif\s*;\s*\?>#s',
+ static fn(array $m): string => $isBulkSubmitPage ? '' : $m[1],
+ $source
+ );
+
+ $source = preg_replace('#<\?(?:php|=).*?\?>#s', '', $source);
+
+ return $source;
+ }
+
+ private function stripNonHtml(string $source): string
+ {
+ $source = preg_replace('##is', '', $source);
+ $source = preg_replace('##is', '', $source);
+
+ return $source;
+ }
+
+ private function assertDivBalanced(string $html, string $context): void
+ {
+ $opens = preg_match_all('#
#i', $html);
+
+ $this->assertSame(
+ $opens,
+ $closes,
+ sprintf(
+ 'Unbalanced
tags on %s: %d opens vs %d closes. ' .
+ 'A mismatch here is what caused WP-1004 (postboxes below the Smartling box refusing to open).',
+ $context,
+ $opens,
+ $closes
+ )
+ );
+ }
+}