fix(4e-review clean-code): eine sanitize_key-Nachbildung (LoopScope::sanitizeKey) statt dreier; Docblock zur strengeren LoopContext::enabled()

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Jan-Niclas Loosen
2026-10-20 00:41:33 +02:00
co-authored by Claude Sonnet 5.5
parent 71ffbdbf59
commit 410e773d28
4 changed files with 29 additions and 11 deletions
@@ -105,4 +105,14 @@ final class LoopScopeTest extends TestCase
self::assertFalse(LoopScope::ofQueryType('repeater_team')->fits('loop_post_title'));
self::assertTrue(LoopScope::ofQueryType('current_page')->fits('loop_post_title'));
}
/** The one reading of Divi's sanitize_key() (LoopUtils.php:725-731) the loop checks share. */
public function testSanitizeKeyReadsLikeDivi(): void
{
self::assertSame('userbb_roles', LoopScope::sanitizeKey(' User<b></b>_Roles '));
self::assertSame('on', LoopScope::sanitizeKey('o n'));
self::assertSame('1', LoopScope::sanitizeKey(true));
self::assertSame('', LoopScope::sanitizeKey(null));
self::assertSame('', LoopScope::sanitizeKey(['on']));
}
}