From ae994ad7bdbe6524ca5af49185dad28189047983 Mon Sep 17 00:00:00 2001 From: Jan-Niclas Loosen Date: Sun, 27 Sep 2026 04:20:44 +0200 Subject: [PATCH] fix: lit/divi-dynamic-sources offers no {{link:}} for attachments (M-9) Also none for internal post types (post_link_url__et_pb_speculation). Co-Authored-By: Claude Opus 5.5 (1M context) --- .../Divi/Pages/DiviDynamicSourcesAbility.php | 9 ++++++++- .../Divi/Pages/DiviDynamicSourcesAbilityTest.php | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Integrations/Divi/Pages/DiviDynamicSourcesAbility.php b/src/Integrations/Divi/Pages/DiviDynamicSourcesAbility.php index 056109e..9863548 100644 --- a/src/Integrations/Divi/Pages/DiviDynamicSourcesAbility.php +++ b/src/Integrations/Divi/Pages/DiviDynamicSourcesAbility.php @@ -205,7 +205,14 @@ final class DiviDynamicSourcesAbility implements Ability return '{{post:' . $post . '}}'; } - return str_starts_with($name, 'post_link_url_') ? '{{link:}}' : null; + if (! str_starts_with($name, 'post_link_url_')) { + return null; + } + + // Review M-9: {{link:}} refuses attachments (status inherit); internal types ("_…") are no link targets. + $type = substr($name, strlen('post_link_url_')); + + return $type === 'attachment' || str_starts_with($type, '_') ? null : '{{link:}}'; } /** diff --git a/tests/Unit/Integrations/Divi/Pages/DiviDynamicSourcesAbilityTest.php b/tests/Unit/Integrations/Divi/Pages/DiviDynamicSourcesAbilityTest.php index b6726da..8eabe10 100644 --- a/tests/Unit/Integrations/Divi/Pages/DiviDynamicSourcesAbilityTest.php +++ b/tests/Unit/Integrations/Divi/Pages/DiviDynamicSourcesAbilityTest.php @@ -80,6 +80,22 @@ final class DiviDynamicSourcesAbilityTest extends TestCase self::assertSame('lit/divi-dynamic-sources', $this->ability()->name()); } + /** Review M-9: {{link:}} refuses attachments (status inherit), so their link sources get no hint. */ + public function testNoLinkHintForAttachmentsOrInternalTypes(): void + { + $registry = DiviFixtures::dynamicContentRegistry(); + foreach (['post_link_url_attachment', 'post_link_url__et_pb_speculation'] as $name) { + $registry[$name] = $registry['post_link_url_page']; + $registry[$name]['id'] = $name; + } + + $sources = array_column($this->ability([], 'meta', $registry)->execute(['post_type' => 'page'])['sources'], null, 'name'); + + self::assertSame('{{link:}}', $sources['post_link_url_page']['placeholder']); + self::assertNull($sources['post_link_url_attachment']['placeholder']); + self::assertNull($sources['post_link_url__et_pb_speculation']['placeholder']); + } + public function testOffersTextLikeFieldsAndNamesTheOthers(): void { $result = $this->ability()->execute(['post_type' => 'page']);