diff --git a/Handler/TwigHandler.php b/Handler/TwigHandler.php index 1d0eb30..f9746ea 100644 --- a/Handler/TwigHandler.php +++ b/Handler/TwigHandler.php @@ -36,6 +36,7 @@ public function addToTwig($twig) { $twig->addExtension(new StringLoaderExtension()); $twig->addFunction(new Twig_Function('acti_get_svg', [$this, 'svgUrlGetContent'])); + $twig->addFunction(new Twig_Function('acti_get_current_url', [$this, 'getCurrentUrl'])); $twig->addFunction(new Twig_Function('acti_picture', '\ActiTimberPackage\Helper\PictureHelper::create')); return $twig; @@ -49,4 +50,13 @@ public function svgUrlGetContent($svg) return $iconfile->saveHTML($iconfile->getElementsByTagName('svg')[0]); } + + public function getCurrentUrl() + { + global $wp; + + $currentUrl = home_url(add_query_arg(array($_GET), $wp->request)); + + return $currentUrl; + } }