diff --git a/wp-content/themes/cosmopet/modules/header/module-controller.php b/wp-content/themes/cosmopet/modules/header/module-controller.php index 09f52bd..b59c312 100644 --- a/wp-content/themes/cosmopet/modules/header/module-controller.php +++ b/wp-content/themes/cosmopet/modules/header/module-controller.php @@ -79,6 +79,11 @@ add_filter('timber/context', function($context) { if (SITE_DOMAIN == 'AE'){ $context['front_url_en'] = "/"; } + + $current_language = pll_current_language(); // Получаем текущий язык + $menu_items = wp_get_nav_menu_items('main_menu_' . $current_language); // Получаем элементы меню для текущего языка + + $context['menu_items'] = $menu_items; return $context; }); diff --git a/wp-content/themes/cosmopet/temp-functions/menu-logic.php b/wp-content/themes/cosmopet/temp-functions/menu-logic.php index ebac216..72b628a 100644 --- a/wp-content/themes/cosmopet/temp-functions/menu-logic.php +++ b/wp-content/themes/cosmopet/temp-functions/menu-logic.php @@ -8,4 +8,111 @@ function register_custom_menus() { 'dogs-menu' => 'Меню для собак', ]); } -add_action('after_setup_theme', 'register_custom_menus'); \ No newline at end of file +add_action('after_setup_theme', 'register_custom_menus'); + + +class Custom_Walker_Nav_Menu extends Walker_Nav_Menu { + // Открытие уровня подменю + function start_lvl( &$output, $depth = 0, $args = null ) { + $output .= '
'; + } + + // Открытие элемента меню + function start_el( &$output, $item, $depth = 0, $args = null, $id = 0 ) { + // Для родительского элемента меню + if ($depth === 0) { + $output .= ' '; // Закрытие .header-pc-menu__item + } else { + // Закрытие для дочернего элемента + $output .= ''; + } + } +} + + +function get_custom_menu($location) { + // Используем wp_nav_menu с нужными параметрами + ob_start(); // Начинаем буферизацию вывода + wp_nav_menu(array( + 'theme_location' => $location, + 'menu_class' => '', // Не добавляем класс к ul + 'container' => false, // Без контейнера + 'depth' => 2, // Уровень вложенности + 'walker' => new Custom_Walker_Nav_Menu(), // Используем кастомный walker + )); + $menu_html = ob_get_clean(); // Получаем HTML меню + + return $menu_html; +} + + + +class Custom_Header_Phone_Menu_Walker extends Walker_Nav_Menu { + // Открытие подменю (если есть) + function start_lvl( &$output, $depth = 0, $args = null ) { + $output .= ' '; + } + + // Открытие элемента меню + function start_el( &$output, $item, $depth = 0, $args = null, $id = 0 ) { + if ($depth === 0) { + // Для родительского элемента + $output .= '' . esc_html($item->title) . ''; + } else { + // Для дочерних элементов + $output .= '