/** * A function for rendering a template through calling the TwigPress Class * * @param array $vals An array of variables to be rendered with the template, defaults to an empty array * @param string $template The name of the template to be rendered, if users want to override the default action, defaults to false * @param bool $echo A boolean indicating whether to echo or return the rendered template, defaults to true * * @return string The rendered template */ function twigpress_render_twig_template($vals = array(), $template = false, $echo = true) { $TwigPress = TwigPress::get_instance(); # If no template has been specified, look for {PHP Template Filename}.twig if (false == $template) { $template = pathinfo(basename($TwigPress::$template), PATHINFO_FILENAME) . '.twig'; } # Check whether we are echoing or returning if (true == $echo) { echo $TwigPress->render_template($template, $vals); } else { return $TwigPress->render_template($template, $vals); } }
/** * This function simply stores, in $template, the filename of the template being used * * It also returns the template name so WordPress can keep using it, as the filename is retrieved from a filter * * @since 1.0.0 */ public function get_chosen_template_name($template) { return self::$template = $template; }