From 5ee846e63d0cc3927da77f622cc08b97d130eeaf Mon Sep 17 00:00:00 2001 From: Jan-Niclas Loosen Date: Mon, 19 Oct 2026 20:45:01 +0200 Subject: [PATCH] =?UTF-8?q?docs/test:=20S36-Hinweise=20abgel=C3=B6st=20(X5?= =?UTF-8?q?);=20loopFields()=20in=20VariableRef=20gepinnt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 --- .../Divi/Pages/DiviDynamicSourcesAbility.php | 4 +-- .../Divi/Pages/DynamicContentMapTest.php | 32 ++++++++++++++++++- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/Integrations/Divi/Pages/DiviDynamicSourcesAbility.php b/src/Integrations/Divi/Pages/DiviDynamicSourcesAbility.php index 4189f13..a959d82 100644 --- a/src/Integrations/Divi/Pages/DiviDynamicSourcesAbility.php +++ b/src/Integrations/Divi/Pages/DiviDynamicSourcesAbility.php @@ -22,8 +22,8 @@ defined('ABSPATH') || exit; /** * lit/divi-dynamic-sources (spec §5.7, E12): Divi's dynamic content options for a post type * (DynamicContentOptions::get_options with a sample entry of the type the user may edit, else 0; - * no loop_* – S36; via DynamicContentMap::options()) with the placeholder that writes each, and - * the fields of the type usable as {{field:}}. + * no loop_* – they need a node in a Divi loop, ruling X6; via DynamicContentMap::options()) with the + * placeholder that writes each, and the fields of the type usable as {{field:}}. * * Answer F4: only text-like fields are offered; relation/file fields show IDs in Divi (F26), Pods * table storage is not post meta, protected keys never (S12), unknown types not (ruling P9) – each diff --git a/tests/Unit/Integrations/Divi/Pages/DynamicContentMapTest.php b/tests/Unit/Integrations/Divi/Pages/DynamicContentMapTest.php index 152d0bd..48c734f 100644 --- a/tests/Unit/Integrations/Divi/Pages/DynamicContentMapTest.php +++ b/tests/Unit/Integrations/Divi/Pages/DynamicContentMapTest.php @@ -101,7 +101,7 @@ final class DynamicContentMapTest extends TestCase // enable_html stays forbidden even though the registry lists it. $html = $ref('post_meta_key', ['enable_html' => 'on']); self::assertRejected(static fn () => $references->canonical($html, $sanitizer), 'enable_html'); - // Loop content: Divi offers it only inside loops – never through the tools. + // Loop content needs a Divi loop of its kind (ruling X5) – this VariableRef has none. $loop = $ref('loop_post_title', []); self::assertRejected(static fn () => $references->canonical($loop, $sanitizer), 'Schleifen'); } @@ -276,6 +276,36 @@ final class DynamicContentMapTest extends TestCase self::assertArrayNotHasKey('loop_post_meta_key_manual_custom_field', $map->loopFields(LoopScope::USER)); } + /** The map a loop composition builds (Task 4): forPost() + loopFields() of the loop's kind. */ + public function testLoopFieldsWorkInVariableRefInsideALoopOfTheirKind(): void + { + $map = new DynamicContentMap(static fn (int $id): array => DiviFixtures::dynamicContentRegistry()); + $terms = LoopScope::ofQueryType('post_taxonomies'); + $references = new VariableRef( + DiviFixtures::designSystem(), + (array) $map->forPost(831) + $map->loopFields((string) $terms->kind(), 831), + $terms + ); + $sanitizer = ComposeFixture::sanitizer(); + $ref = static fn (string $name, array $settings): string => VariableRef::serialize('content', $name, $settings); + + $name = $ref('loop_term_name', ['before' => 'Kategorie: ', 'after' => '', 'loop_position' => '']); + self::assertSame($name, $references->canonical($name, $sanitizer)); + $title = $ref('post_title', ['before' => '', 'after' => '']); + self::assertSame($title, $references->canonical($title, $sanitizer)); + self::assertRejected( + static fn () => $references->canonical($ref('loop_post_title', []), $sanitizer), + 'passt nicht zur Schleife dieses Elements (Typ: Terme)' + ); + self::assertRejected( + static fn () => $references->canonical( + $ref('loop_term_meta_key_manual_custom_field', ['enable_html' => 'on']), + $sanitizer + ), + 'enable_html' + ); + } + public function testLoopFieldsReadTheRegistryOfThePostAndAreEmptyWithoutIt(): void { $seen = [];