| @@ -4,8 +4,9 @@ | ||
| 4 | 4 | dirname(dirname(__FILE__)) . '/views', |
| 5 | 5 | dirname(dirname(__FILE__)) . '/public', |
| 6 | 6 | ]), ['autoescape' => false, 'debug' => false]); |
| 7 | 7 | |
| 8 | +//$twig->addExtension(new Twig_Extension_Debug()); | |
| 8 | 9 | if(!is_admin()): |
| 9 | 10 | |
| 10 | 11 | $twig->addFilter(new Twig_SimpleFilter('shortcode', function($string) { |
| 11 | 12 | return do_shortcode($string); |
| @@ -22,17 +23,8 @@ | ||
| 22 | 23 | $translator = $env->getFilter('translate')->getCallable(); |
| 23 | 24 | $menu = $translator($options['menu_to_use'], 'menu_to_use'); |
| 24 | 25 | $walker = $options['custom_walker'] ? new $options['custom_walker']($options) : new ResponsiveMenu\Walkers\Walker($options); |
| 25 | 26 | |
| 26 | - /** Check menu is exist or not */ | |
| 27 | - $menu_arial_label = ''; | |
| 28 | - foreach( get_terms('nav_menu') as $nav_menu ) { | |
| 29 | - if ( $nav_menu->slug === $menu ) { | |
| 30 | - $menu_arial_label = $menu; | |
| 31 | - break; | |
| 32 | - } | |
| 33 | - } | |
| 34 | - | |
| 35 | 27 | return wp_nav_menu( |
| 36 | 28 | [ |
| 37 | 29 | 'container' => '', |
| 38 | 30 | 'menu_id' => 'responsive-menu', |
| @@ -40,9 +32,8 @@ | ||
| 40 | 32 | 'menu' => $menu && !$options['theme_location_menu'] ? $menu : null, |
| 41 | 33 | 'depth' => $options['menu_depth'] ? $options['menu_depth'] : 0, |
| 42 | 34 | 'theme_location' => $options['theme_location_menu'] ? $options['theme_location_menu'] : null, |
| 43 | 35 | 'walker' => $walker, |
| 44 | - 'items_wrap' => '<ul id="%1$s" role="menubar" aria-label="'. $menu_arial_label .'" >%3$s</ul>', | |
| 45 | 36 | 'echo' => false |
| 46 | 37 | ] |
| 47 | 38 | ); |
| 48 | 39 | |
| @@ -67,24 +58,18 @@ | ||
| 67 | 58 | })); |
| 68 | 59 | |
| 69 | 60 | $twig->addFunction(new Twig_SimpleFunction('menu_items', function($options) { |
| 70 | 61 | |
| 71 | - $menu = ''; | |
| 72 | - if( $options['theme_location_menu'] ) { | |
| 62 | + if($options['theme_location_menu']) | |
| 73 | 63 | $menu = get_term(get_nav_menu_locations()[$options['theme_location_menu']], 'nav_menu')->name; |
| 74 | - } elseif( $options['menu_to_use'] ) { | |
| 64 | + elseif($options['menu_to_use']) | |
| 75 | 65 | $menu = $options['menu_to_use']; |
| 76 | - } elseif( ! empty( get_terms('nav_menu')[0]->slug ) ) { | |
| 66 | + else | |
| 77 | 67 | $menu = get_terms('nav_menu')[0]->slug; |
| 78 | - } | |
| 79 | 68 | |
| 80 | 69 | return wp_get_nav_menu_items($menu); |
| 81 | 70 | })); |
| 82 | 71 | |
| 83 | - $twig->addFunction(new Twig_SimpleFunction('all_pages', function() { | |
| 84 | - return get_pages(); | |
| 85 | - })); | |
| 86 | - | |
| 87 | 72 | $twig->addFunction(new Twig_SimpleFunction('font_icons', function($array) { |
| 88 | 73 | $new_array = []; |
| 89 | 74 | for($i=0; $i < count($array['id']); $i++): |
| 90 | 75 | $new_array[$i] = [ |
| @@ -98,43 +83,10 @@ | ||
| 98 | 83 | |
| 99 | 84 | $twig->addGlobal('admin_url', get_admin_url()); |
| 100 | 85 | $twig->addGlobal('shortcode', '[responsive_menu]'); |
| 101 | 86 | |
| 102 | - $twig->addFunction(new Twig_SimpleFunction('get_available_themes', function() { | |
| 103 | - $theme_folder_path = wp_upload_dir()['basedir'] . '/responsive-menu-themes'; | |
| 104 | - $theme_folders = glob($theme_folder_path . '/*' , GLOB_ONLYDIR); | |
| 105 | - | |
| 106 | - $themes = []; | |
| 107 | - foreach($theme_folders as $theme_folder): | |
| 108 | - $config = json_decode(file_get_contents($theme_folder . '/config.json'), true); | |
| 109 | - $themes[basename($theme_folder)]['version'] = $config['version']; | |
| 110 | - $themes[basename($theme_folder)]['name'] = $config['name']; | |
| 111 | - endforeach; | |
| 112 | - | |
| 113 | - return $themes; | |
| 114 | - })); | |
| 115 | - | |
| 116 | - $twig->addGlobal('themes_folder_url', wp_upload_dir()['baseurl'] . '/responsive-menu-themes/'); | |
| 117 | - $twig->addGlobal('themes_folder_dir', wp_upload_dir()['basedir'] . '/responsive-menu-themes/'); | |
| 118 | - | |
| 119 | 87 | $twig->addFunction(new Twig_SimpleFunction('hide_pro_options', function() { |
| 120 | 88 | return get_option('hide_pro_options', 'no'); |
| 121 | - })); | |
| 122 | - | |
| 123 | - $twig->addFunction(new Twig_SimpleFunction('nav_menus', function() { | |
| 124 | - $menus_array = []; | |
| 125 | - foreach(get_terms('nav_menu') as $menu) | |
| 126 | - $menus_array[$menu->slug] = $menu->name; | |
| 127 | - | |
| 128 | - return $menus_array; | |
| 129 | - })); | |
| 130 | - | |
| 131 | - $twig->addFunction(new Twig_SimpleFunction('location_menus', function() { | |
| 132 | - $location_menus = ['' => 'None']; | |
| 133 | - foreach(get_registered_nav_menus() as $location => $menu) | |
| 134 | - $location_menus[$location] = $menu; | |
| 135 | - | |
| 136 | - return $location_menus; | |
| 137 | 89 | })); |
| 138 | 90 | |
| 139 | 91 | endif; |
| 140 | 92 | |