<?php

$menu_location = 'footer-bottom';
$locations = get_nav_menu_locations();
$menu_id = $locations[$menu_location];
$menu_items = wp_get_nav_menu_items($menu_id);

$privacyPolicy = get_field('privacy_policy', 'option');


foreach ($menu_items ?? [] as $menu_item) {

    if($privacyPolicy) {

        if($menu_item->post_name === 'politika-konfidenczialnosti') $file = $privacyPolicy['file']['url'];

        if($menu_item->post_name === 'svidetelstvo-o-registraczii-elektronnogo-smi') $file = $privacyPolicy['file_certificate']['url'];

        echo "<a href='" . esc_url($file) . "' class='footer-bottom__text footer-bottom__link' target='_blank'>" . $menu_item->title . "</a>";
    } else {
         echo "<a href='" . esc_url($menu_item->url) . "' class='footer-bottom__text footer-bottom__link' target='_blank'>" . $menu_item->title . "</a>";
    }

}
