Skip to content

Commit

Permalink
fix(twig): allow accessing wp post properties
Browse files Browse the repository at this point in the history
  • Loading branch information
eteubert committed Oct 26, 2024
1 parent d0f8c32 commit cc4b080
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion lib/template/twig_sandbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,38 @@ 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(
self::$twig_filters,
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,
Expand Down

0 comments on commit cc4b080

Please sign in to comment.