From cc4b0801d24f21401755fa93708f5dd17b800807 Mon Sep 17 00:00:00 2001 From: Eric Teubert Date: Sat, 26 Oct 2024 22:27:26 +0200 Subject: [PATCH] fix(twig): allow accessing wp post properties --- lib/template/twig_sandbox.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/template/twig_sandbox.php b/lib/template/twig_sandbox.php index 5e1bdd0e..8a73cebe 100644 --- a/lib/template/twig_sandbox.php +++ b/lib/template/twig_sandbox.php @@ -142,6 +142,30 @@ class TwigSandbox 'timezone_names', ]; + public static $wp_post_props = ['WP_Post' => [ + 'ID', + 'post_author', + 'post_date', + 'post_date_gmt', + 'post_content', + 'post_title', + 'post_excerpt', + 'post_status', + 'comment_status', + 'ping_status', + 'post_name', + 'to_ping', + 'pinged', + 'post_modified', + 'post_modified_gmt', + 'post_parent', + 'guid', + 'menu_order', + 'post_type', + 'post_mime_type', + 'comment_count' + ]]; + public static function getSecurityPolicy() { $filters = array_merge( @@ -149,7 +173,7 @@ public static function getSecurityPolicy() self::$allowed_custom_filters ); $methods = self::get_podlove_template_methods(); - $properties = []; + $properties = self::$wp_post_props; $functions = array_merge( self::$twig_functions, TwigFilter::$template_tags,