From 02689f687f6cbae567568b991a2f0f3a54553d0f Mon Sep 17 00:00:00 2001 From: magdev Date: Sun, 1 Mar 2026 06:22:24 +0100 Subject: [PATCH] add escape twig functions as twig filters --- inc/Twig/TwigService.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/inc/Twig/TwigService.php b/inc/Twig/TwigService.php index f4a81eb..7d0bac4 100644 --- a/inc/Twig/TwigService.php +++ b/inc/Twig/TwigService.php @@ -165,5 +165,10 @@ class TwigService { $this->twig->addFilter(new TwigFilter('wpautop', 'wpautop', ['is_safe' => ['html']])); $this->twig->addFilter(new TwigFilter('wp_kses_post', 'wp_kses_post', ['is_safe' => ['html']])); + + // Escaping filters — same functions registered above, but as filters for |esc_html syntax. + $this->twig->addFilter(new TwigFilter('esc_html', 'esc_html', ['is_safe' => ['html']])); + $this->twig->addFilter(new TwigFilter('esc_attr', 'esc_attr', ['is_safe' => ['html']])); + $this->twig->addFilter(new TwigFilter('esc_url', 'esc_url', ['is_safe' => ['html']])); } }