| 1 |
<?php |
| 2 |
|
| 3 |
namespace ResponsiveMenu\ViewModels\Components\Menu; |
| 4 |
|
| 5 |
use ResponsiveMenu\ViewModels\Components\ViewComponent as ViewComponent; |
| 6 |
use ResponsiveMenu\Collections\OptionsCollection as OptionsCollection; |
| 7 |
use ResponsiveMenu\Walkers\WpWalker as Walker; |
| 8 |
|
| 9 |
class Menu implements ViewComponent { |
| 10 |
|
| 11 |
public function render(OptionsCollection $options) { |
| 12 |
|
| 13 |
$menu = apply_filters('wpml_translate_single_string', $options['menu_to_use']->getValue(), 'Responsive Menu', 'menu_to_use'); |
| 14 |
|
| 15 |
/* |
| 16 |
Add Polylang Support */ |
| 17 |
if(function_exists('pll__')) |
| 18 |
$menu = pll__($menu); |
| 19 |
|
| 20 |
return wp_nav_menu( |
| 21 |
[ |
| 22 |
'container' => '', |
| 23 |
'menu_id' => 'responsive-menu', |
| 24 |
'menu_class' => null, |
| 25 |
'menu' => $menu && !$options['theme_location_menu']->getValue() ? $menu : null, |
| 26 |
'depth' => $options['menu_depth']->getValue() ? $options['menu_depth']->getValue() : 0, |
| 27 |
'theme_location' => $options['theme_location_menu']->getValue() ? $options['theme_location_menu']->getValue() : null, |
| 28 |
'walker' => $options['custom_walker']->getValue() ? new $options['custom_walker']($options) : new Walker($options), |
| 29 |
'echo' => false |
| 30 |
] |
| 31 |
); |
| 32 |
|
| 33 |
} |
| 34 |
|
| 35 |
} |
| 36 |
|