/** * Determine the context that will be used by the content() method */ public function context() { global $wp_query; $context = Maera()->cache->get_context(); $post = new TimberPost(); $context['post'] = $post; $context['posts'] = Timber::get_posts(); // Compatibility hack or plugins that change the content. if ($this->plugins_compatibility()) { $context['content'] = maera_get_echo('the_content'); } if (is_singular()) { $context['wp_title'] .= ' - ' . $post->title(); } if (is_search()) { $context['title'] = __('Search results for ', 'maera') . get_search_query(); } if (is_archive() || is_home()) { $context['posts'] = Timber::query_posts(false, 'TimberPost'); $context['title'] = get_the_archive_title(); if (is_author()) { $author = new TimberUser($wp_query->query_vars['author']); $context['author'] = $author; } } if (class_exists('WooCommerce')) { global $product; $context['product'] = $product; } return $context; }
/** * Get the list of replacements and perform a str_replace for them to the rendered HTML of the page * replacing all defined replacements with their respective rendered twig elements from the active shell. */ function do_twig_replacements($content) { $replacements = $this->replacements(); foreach ($replacements as $replacement => $value) { if (false !== strpos($content, '[' . $value . ']')) { $replaced = maera_get_echo('maera_helper_get_replacements', $value); $content = str_replace('[' . $value . ']', $replaced, $content); } } return $content; }
/** * Return the rendered twig file. */ function maera_get_twig($file) { $value = maera_get_echo('_maera_get_twig', $file); return $value; }
<?php Maera()->views->dependencies(); $context = Maera()->cache->get_context(); $post = Timber::query_post(); $context['post'] = $post; $context['content'] = maera_get_echo('the_content'); Maera()->views->header(); Maera()->views->render('bp.twig', $context); Maera()->views->footer();