Skip to content

Commit

Permalink
json_readable_encode: register hook only if module loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
plepe committed Mar 19, 2018
1 parent f0a7931 commit 8adaf00
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions json_readable_encode/json_readable_encode.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@ function json_readable_encode($in, $indent_string = " ", $indent = 0, Closure
return $out;
}

register_hook("twig_init", function() {
global $twig;

$twig->addFilter(new Twig_SimpleFilter('json_readable_encode', function($data) {
return json_readable_encode($data);
}));
});
if(function_exists('register_hook')) {
register_hook("twig_init", function() {
global $twig;

$twig->addFilter(new Twig_SimpleFilter('json_readable_encode', function($data) {
return json_readable_encode($data);
}));
});
}

0 comments on commit 8adaf00

Please sign in to comment.