PluginProbe
Responsive Menu – Create Mobile-Friendly Menu / 3.1.3
Responsive Menu – Create Mobile-Friendly Menu v3.1.3
4.7.3 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.10 4.1.11 4.1.12 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 All 90 releases
responsive-menu / config / twig.php

twig.php in Responsive Menu – Create Mobile-Friendly Menu 3.1.3, at config/twig.php

54 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 $twig = new Twig_Environment(new Twig_Loader_Filesystem([
4 dirname(dirname(__FILE__)) . '/views',
5 dirname(dirname(__FILE__)) . '/public',
6 ]), ['autoescape' => false]);
7
8 $twig->addFilter(new Twig_SimpleFilter('shortcode', function($string) {
9 return do_shortcode($string);
10 }));
11
12 $twig->addFilter(new Twig_SimpleFilter('translate', function($string, $key) {
13 $translated = apply_filters('wpml_translate_single_string', $string, 'Responsive Menu', $key);
14 $translated = function_exists('pll__') ? pll__($translated) : $translated;
15 return $translated;
16 }));
17
18 $twig->addFilter(new Twig_SimpleFilter('json_decode', function($string) {
19 return json_decode($string, true);
20 }));
21
22 $twig->addFunction(new Twig_SimpleFunction('header_bar_items', function($items) {
23 if(isset($items['button']))
24 unset($items['button']);
25 return $items;
26 }));
27
28 $twig->addFunction(new Twig_SimpleFunction('build_menu', function($env, $options) {
29
30 $translator = $env->getFilter('translate')->getCallable();
31 $menu = $translator($options['menu_to_use'], 'menu_to_use');
32 $walker = $options['custom_walker'] ? new $options['custom_walker']($options) : new ResponsiveMenu\Walkers\Walker($options);
33
34 return wp_nav_menu(
35 [
36 'container' => '',
37 'menu_id' => 'responsive-menu',
38 'menu_class' => null,
39 'menu' => $menu && !$options['theme_location_menu'] ? $menu : null,
40 'depth' => $options['menu_depth'] ? $options['menu_depth'] : 0,
41 'theme_location' => $options['theme_location_menu'] ? $options['theme_location_menu'] : null,
42 'walker' => $walker,
43 'echo' => false
44 ]
45 );
46
47 }, ['needs_environment' => true]));
48
49 $twig->addGlobal('search_url', function_exists('icl_get_home_url') ? icl_get_home_url() : get_home_url());
50 $twig->addGlobal('admin_url', get_admin_url());
51 $twig->addFunction(new Twig_SimpleFunction('current_page', function() {
52 return get_option('responsive_menu_current_page', 'initial-setup');
53 }));
54 return $twig;