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']);