<?php
defined('ABSPATH') || exit('No Access!');

global $user_id, $options, $labels;
$header_menu_custom_items = $options->get_option('header-menu-custom-items');
?>
<div class="header-btn">
    <?php if (intval($user_id)): ?>
        <a href="#" class="dropdown-toggle">
            <span class="checked"></span>
        </a>
        <div class="dropdown-menu">
            <ul class="account-navigation">
                <li class="first-item clearfix">
                    <?php echo get_avatar($user_id, 32); ?>
                    <div class="user-info">
                        <p class="user-name"><?php echo get_userdata($user_id)->display_name; ?></p>
                        <a href="<?php echo esc_url($options->get_option('account-url')); ?>" class="profile-link"><?php echo esc_html($labels->get_label('view-account')); ?></a>
                    </div>
                </li>
                <?php
                if (is_array($header_menu_custom_items) && count($header_menu_custom_items)) {
                    foreach ($header_menu_custom_items as $custom_item) {
                        if (!strpos($custom_item, '@')) {
                            continue;
                        }
                        list($title, $url) = explode('@', $custom_item);
                        echo '<li class="woocommerce-MyAccount-navigation-link"><a href="' . esc_attr($url) . '">' . esc_html(irk_translated_string($title)) . '</a></li>';
                    }
                }
                ?>
                <?php if ($options->get_option('account-menu-items')): ?>
                    <?php if (irk_is_woo_active()): ?>
                        <?php if (!irk_is_user_seller($user_id) || !function_exists('dokan_dashboard_nav')): ?>
                            <?php foreach (wc_get_account_menu_items() as $endpoint => $label) : ?>
                                <li class="<?php echo wc_get_account_menu_item_classes($endpoint); ?>">
                                    <a href="<?php echo esc_url(wc_get_account_endpoint_url($endpoint)); ?>"><?php echo esc_html($label); ?></a>
                                </li>
                            <?php endforeach; ?>
                        <?php else: ?>
                            <?php echo function_exists('dokan_dashboard_nav') ? irk_dokan_dashboard_nav() : ''; ?>
                        <?php endif; ?>
                    <?php else: ?>

                    <?php endif; ?>
                <?php endif; ?>
            </ul>
        </div>
    <?php else: ?>
        <a href="<?php echo esc_url($options->get_option('login-url')); ?>" class="login-btn"><?php echo esc_html($labels->get_label('login-account')); ?></a>
    <?php endif; ?>
</div>