Skip to content

Commit

Permalink
Add get current url twig function
Browse files Browse the repository at this point in the history
  • Loading branch information
torink74 committed Aug 19, 2020
1 parent ae7d2b2 commit d6b753f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Handler/TwigHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
}

0 comments on commit d6b753f

Please sign in to comment.