public static function get_context()
{
if (empty(self::$context_cache)) {
self::$context_cache['http_host'] = URLHelper::get_scheme() . '://' . URLHelper::get_host();
self::$context_cache['wp_title'] = Helper::get_wp_title();
self::$context_cache['wp_head'] = Helper::function_wrapper('wp_head');
self::$context_cache['wp_footer'] = Helper::function_wrapper('wp_footer');
self::$context_cache['body_class'] = implode(' ', get_body_class());
self::$context_cache['site'] = new Site();
self::$context_cache['request'] = new Request();
$user = new User();
self::$context_cache['user'] = $user->ID ? $user : false;
self::$context_cache['theme'] = self::$context_cache['site']->theme;
//Not yet! but this will soon be the default...
//self::$context_cache['posts'] = new PostQuery();
self::$context_cache['posts'] = Timber::query_posts();
self::$context_cache = apply_filters('timber_context', self::$context_cache);
self::$context_cache = apply_filters('timber/context', self::$context_cache);
}
return self::$context_cache;
}
<?php require_once __DIR__ . '/app/bootstrap.php'; use Timber\Timber; use Timber\User; /** @var $timber Timber */ $timber = $container->get('timber'); $context = Timber::get_context(); $context['posts'] = Timber::get_posts(); if (isset($wp_query->query_vars['author'])) { $author = new User($wp_query->query_vars['author']); $context['author'] = $author; $context['title'] = 'Author Archives: ' . $author->name(); } $timber::render(['author.html.twig', 'archive.html.twig'], $context);