<?php
global $ref_link;
$ref_link = get_field('referral_link', 'option');
$sidebar = get_field('sidebar', 'option');
$top_nav = $sidebar['top_nav'];
?>

<?php
if ($top_nav) : ?>
    <div class="sidebar__quicklinks">
        <ul class="list sidebar__list">
            <?php foreach ($top_nav as $i => $row) :
                $icon = $row['icon'];
                $link = $row['link'];
            ?>
                <li>
                    <a href="<?php echo esc_url($ref_link); ?>">
                        <img width="23" src="<?php echo esc_url($icon['url']); ?>" alt="<?php echo esc_attr($icon['alt']); ?>" title="<?php echo esc_attr($icon['title']); ?>" />
                        <span><?php echo esc_html($link); ?></span>
                    </a>
                </li>
            <?php endforeach; ?>
        </ul>
    </div>
<?php endif; ?>