
function mars_b2b_get_home_icon_categories() {
    $cache_key = 'mars_b2b_home_icon_categories_v1';
    $cached = get_transient($cache_key);
    if (false !== $cached) {
        return $cached;
    }

    $preferred_slugs = [
        'battery',
        'lcd-oled',
        'lcd',
        'oled',
        'display',
        'charging-port',
        'port',
        'camera',
        'flex',
        'housing',
        'ic-parts',
        'tools',
    ];

    $terms = get_terms([
        'taxonomy'   => 'product_cat',
        'hide_empty' => true,
        'slug'       => $preferred_slugs,
    ]);

    if (is_wp_error($terms) || empty($terms)) {
        $terms = get_terms([
            'taxonomy'   => 'product_cat',
            'hide_empty' => true,
            'parent'     => 0,
            'number'     => 8,
        ]);
        if (is_wp_error($terms)) {
            $terms = [];
        }
    } else {
        $ordered = [];
        foreach ($preferred_slugs as $slug) {
            foreach ($terms as $term) {
                if ($term->slug === $slug) {
                    $ordered[] = $term;
                    break;
                }
            }
        }
        $terms = $ordered;
    }

    set_transient($cache_key, $terms, 6 * HOUR_IN_SECONDS);
    return $terms;
}
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://marsmobile.my/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://marsmobile.my/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>https://marsmobile.my/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://marsmobile.my/wp-sitemap-posts-product-1.xml</loc></sitemap><sitemap><loc>https://marsmobile.my/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://marsmobile.my/wp-sitemap-taxonomies-product_cat-1.xml</loc></sitemap><sitemap><loc>https://marsmobile.my/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
