add escape twig functions as twig filters

This commit is contained in:
2026-03-01 06:22:24 +01:00
parent 17728e81d9
commit 02689f687f

View File

@@ -165,5 +165,10 @@ class TwigService
{ {
$this->twig->addFilter(new TwigFilter('wpautop', 'wpautop', ['is_safe' => ['html']])); $this->twig->addFilter(new TwigFilter('wpautop', 'wpautop', ['is_safe' => ['html']]));
$this->twig->addFilter(new TwigFilter('wp_kses_post', 'wp_kses_post', ['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']]));
} }
} }