From 9b8832902cc1a51b5c6e2e0890c576372a60e5e1 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Wed, 10 Mar 2021 16:13:52 +0100 Subject: Initial commit --- app/Site.php | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 app/Site.php (limited to 'app/Site.php') diff --git a/app/Site.php b/app/Site.php new file mode 100644 index 0000000..5e45535 --- /dev/null +++ b/app/Site.php @@ -0,0 +1,87 @@ + 'Main', + 'footer' => 'Footer', + ]); + } + + /** + * wp_enqueue_scripts callback + */ + public function enqueueScripts() + { + $this->enqueueStyle('theme', 'index.css'); + $this->enqueueScript('theme', 'index.js', ['jquery'], true); + } + + /** + * @param array $context + * + * @return mixed + */ + public function addToContext($context) + { + $context['site'] = $this; + + $context['menu'] = []; + foreach (get_registered_nav_menus() as $location => $name) { + $context['menu'][$location] = new Menu($location); + } + + return $context; + } + + /** + * @param Environment $twig + * + * @return Environment + */ + public function addToTwig(Environment $twig) + { + $twig->addExtension(new StringLoaderExtension()); + $twig->addFunction(new TwigFunction('assets_url', [$this, 'assetsUrl'])); + + return $twig; + } +} -- cgit v1.2.3