<?php

$menu_location = 'socials';
$locations = get_nav_menu_locations();
$menu_id = $locations[$menu_location];
$menu_items = wp_get_nav_menu_items($menu_id);

foreach ($menu_items ?? [] as $menu_item) {
    $icon = get_field('icon', $menu_item); // Получаем URL иконки из ACF
    $title = $menu_item->title;
    $url = $menu_item->url;

    echo "<a href='" . esc_url($url) . "' class='social-link' target='_blank'>";
    if (!empty($icon)) {
        echo "<img src='" . esc_url($icon) . "' alt='" . esc_attr($title) . "' />";
    }
    echo "</a>";
}
