/** * Enables theme supports */ public function addThemeSupports() { load_theme_textdomain('novusopress', $this->paths->getBaseLanguageDir()); add_theme_support('title-tag'); add_theme_support('automatic-feed-links'); add_theme_support('post-thumbnails'); add_theme_support('html5', ['search-form', 'comment-form', 'comment-list', 'gallery', 'caption']); register_nav_menus(['main-menu' => __('Main Menu', 'novusopress')]); if ($this->getThemeOption('clean_document_head')) { $this->cleanDocumentHead(); } if (file_exists(sprintf('%s/css/editor-style.css', $this->paths->getThemeAssetsDir()))) { add_editor_style('assets/css/editor-style.css'); } }
/** * Renders a view * * @param string $template The template name * * @return string */ public function render($template) { $debug = defined('WP_DEBUG') ? WP_DEBUG : false; if (is_writable('/tmp')) { if (!is_dir(self::CACHE_DIR)) { mkdir(self::CACHE_DIR); } $cache = self::CACHE_DIR; } else { $cache = null; } Twig_Autoloader::register(); $loader = new Twig_Loader_Filesystem([$this->paths->getThemeViewsDir(), $this->paths->getBaseViewsDir()]); $twig = new Twig_Environment($loader, ['auto_reload' => $debug, 'cache' => $cache, 'charset' => 'UTF-8', 'debug' => $debug, 'strict_variables' => $debug]); $view = $twig->loadTemplate(sprintf('%s.html.twig', $template)); return $view->render(['view' => new ViewModel($template), 'posts' => new PostIterator(), 'wp' => new WordPressProxy()]); }