<?php
$categories = get_categories(array(
    'include' => EN_PARTS,
    'orderby' => 'name',
    'order'   => 'ASC',
    'hide_empty' => false
));


$firstElement = array_shift($categories);
array_push($categories, $firstElement);

foreach ($categories as $category) {
    if ($category->slug === 'uncategorized') continue;

    $icon = get_field('icon', 'category_' . $category->term_id);
    $bg_image = get_field('bg_image', 'category_' . $category->term_id);
    $category_link = get_category_link($category->term_id);
?>
    <a href="<?php echo esc_url($category_link); ?>" class="menu-link">
        <div class="menu-link__bg">
            <?php if ($bg_image) : ?>
                <img src="<?php echo esc_url($bg_image['url']); ?>" alt="<?php echo esc_attr($category->name); ?>" />
            <?php endif; ?>
        </div>
        <div class="menu-link__icon">
            <?php if ($icon) : ?>
                <img src="<?php echo esc_url($icon); ?>" alt="<?php echo esc_attr($category->name); ?>" />
            <?php endif; ?>
        </div>
        <span class="menu-link__text"><?php echo esc_html($category->name); ?></span>
    </a>
<?php
}
?>