feat: {{link:ID}} placeholder via Divi's post_link_url dynamic content
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -421,11 +421,11 @@ final class VariableRefTest extends TestCase
|
||||
);
|
||||
self::assertSame(
|
||||
self::content('post_link_url_page', '{"post_id":"12"}'),
|
||||
$ref->canonical(self::content('post_link_url_page', '{"post_id":"12"}'), $sanitizer)
|
||||
$ref->canonical(self::content('post_link_url_page', '{"post_id":"12"}'), $sanitizer, true)
|
||||
);
|
||||
self::assertSame(
|
||||
self::content('post_link_url_page', '{"post_id":12}'),
|
||||
$ref->canonical(self::content('post_link_url_page', '{"post_id":12}'), $sanitizer)
|
||||
$ref->canonical(self::content('post_link_url_page', '{"post_id":12}'), $sanitizer, true)
|
||||
);
|
||||
|
||||
$rejected = [
|
||||
@@ -440,12 +440,25 @@ final class VariableRefTest extends TestCase
|
||||
];
|
||||
foreach ($rejected as $case => [$value, $fragment]) {
|
||||
try {
|
||||
$ref->canonical($value, $sanitizer);
|
||||
// URL mode: internal links (post_link_url_*) are allowed only there (E13a).
|
||||
$ref->canonical($value, $sanitizer, true);
|
||||
self::fail('Accepted: ' . $case);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
self::assertStringContainsString($fragment, $e->getMessage(), $case);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** E13a: an internal link (post_link_url_<type>) is a URL – refused in every other field. */
|
||||
public function testInternalLinksOnlyInUrlFields(): void
|
||||
{
|
||||
$ref = self::ref(['post_link_url_page' => ['post_id' => 'select_post']]);
|
||||
$link = self::content('post_link_url_page', '{"post_id":"12"}');
|
||||
|
||||
self::assertSame($link, $ref->canonical($link, ComposeFixture::sanitizer(), true));
|
||||
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('nur in Link- und URL-Feldern');
|
||||
$ref->canonical($link, ComposeFixture::sanitizer());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user