<?php get_template_part('templates/master/head');
global $wp_query; ?>
<header class="header">
    <div class="main">
        <?php $site_logo = yc_get_option('site_logo');
        $site_logo = (!empty($site_logo)) ? wp_get_attachment_image_url($site_logo, 'full') : THEME_TEMPLATE_URL . '/assets/front/img/logo.png'; ?>
        <a href="<?php echo SITE_URL; ?>"><img src="<?php echo $site_logo; ?>" class="logo right"></a>
        <a href="#" class="search-btn right rt-ddd rt-50px"><i class="fa fa-search right rt-21"></i></a>
        <ul class="rt-menu right rt-14 rt-align">
            <li class="rt-relative"><a href="<?php echo SITE_URL; ?>" class="rt-fff">خانه</a></li>
            <?php $genres = get_terms(
                array(
                    'taxonomy' => array("genre"),
                    'hide_empty' => false,
                )
            ); ?>
            <li class="rt-relative"><a href="<?php echo SITE_URL . '/movies'; ?>" class="rt-fff">فیلم <i class="fa fa-angle-down rt-op left rt-14"></i></a>
                <?php if (!empty($genres)) : ?>
                    <ul class="right rt-absolute rt-8px rt-13 rt-color2">
                        <?php foreach ($genres as $genre) : ?>
                            <li class="right"><a class="rt rt-fff rt-8px" href="<?php echo add_query_arg(array('ad-s' => '1', 'type' => 'movies', 'genr' => (!empty($genre->name)) ? $genre->name : ""), SITE_URL); ?>" rel="tag"><?php echo (!empty($genre->name)) ? $genre->name : ""; ?></a></li>
                        <?php endforeach; ?>
                    </ul>
                <?php endif; ?>
            </li>
            <li class="rt-relative"><a href="<?php echo SITE_URL . '/series'; ?>" class="rt-fff">سریال <i class="fa fa-angle-down rt-op left rt-14"></i></a>
                <?php if (!empty($genres)) : ?>
                    <ul class="right rt-absolute rt-8px rt-13 rt-color2">
                        <?php foreach ($genres as $genre) : ?>
                            <li class="right"><a class="rt rt-fff rt-8px" href="<?php echo add_query_arg(array('ad-s' => '1', 'type' => 'series', 'genr' => (!empty($genre->name)) ? $genre->name : ""), SITE_URL); ?>" rel="tag"><?php echo (!empty($genre->name)) ? $genre->name : ""; ?></a></li>
                        <?php endforeach; ?>
                    </ul>
                <?php endif; ?>
            </li>
            <li class="rt-relative"><a href="<?php echo SITE_URL . "/blog"; ?>" class="rt-fff">وبلاگ</a></li>
        </ul>
        <div class="dokme-ha left">
            <?php $vip_active = yascode_vip::is_active(); ?>
            <?php if ($vip_active) : ?><a href="<?php echo PANEL_URL . "/plans"; ?>" class="btn right rt-bold plans rt-13 rt-8px"><i class="fa fa-star right rt-16"></i> خرید اشتراک</a><?php endif; ?>

            <?php if (!is_user_logged_in()) : ?>
                <a href="<?php echo LOGIN_URL; ?>" class="btn right rt-bold rt-ddd rt-13 rt-8px"><i class="fa fa-user right rt-16"></i> ورود<span> و ثبت نام</span></a>
            <?php else :
                $user_id = get_current_user_id();
                $user_profile = get_user_profile($user_id); ?>
                <div class="h-uspro">
                    <figure><?php echo $user_profile; ?></figure>
                    <ul class="h-menu">
                        <?php if ($vip_active) :
                            $user_vip = yascode_vip::get_user_vip_status($user_id);
                            $days = (!empty($user_vip['days_left'])) ? $user_vip['days_left'] . ' روز' : 'نامحدود'; ?>
                            <div class="vip-info">
                                <img src="<?php echo THEME_TEMPLATE_URL . "/assets/front/img/vip.svg"; ?>" alt="vip">
                                <span class="status <?php echo ($user_vip['status'] == true) ? 'is-vip' : 'no-vip'; ?>"><?php echo ($user_vip['status'] == true) ? 'اشتراک باقی مانده : ' . '<span class="days">' . $days . '</span>' : 'شما اشتراک فعالی ندارید !'; ?></span>
                            </div>
                        <?php endif; ?>
                        <li class="item">
                            <a href="<?php echo PANEL_URL; ?>">
                                <span class="t">پیشخوان کاربری</span>
                                <i class="fa fa-user"></i>
                            </a>
                        </li>
                        <?php if ($vip_active) : ?>
                            <li class="item">
                                <a href="<?php echo PANEL_URL . '/plans'; ?>">
                                    <span class="t">اشتراک ویژه</span>
                                    <i class="fa fa-star"></i>
                                </a>
                            </li>
                        <?php endif; ?>
                        <li class="item">
                            <a href="<?php echo PANEL_URL . '/watch-list'; ?>">
                                <span class="t">ذخیره شده ها</span>
                                <i class="fa fa-bookmark"></i>
                            </a>
                        </li>
                        <li class="item">
                            <a href="<?php echo PANEL_URL . '/edit-profile'; ?>">
                                <span class="t">ویرایش پروفایل</span>
                                <i class="fa fa-cog"></i>
                            </a>
                        </li>
                        <li class="item">
                            <a href="<?php echo wp_logout_url(SITE_URL); ?>">
                                <span class="t">خروج</span>
                                <i class="fa fa-sign-out"></i>
                            </a>
                        </li>
                    </ul>
                </div>
            <?php endif; ?>
        </div>
    </div>
</header>
<form action="<?php echo SITE_URL; ?>" class="search-form none">
    <div class="bg"></div>
    <div class="form-ss">
        <input type="text" name="s" placeholder="جستجو..." />
        <button type="submit" class="submit rt-pointer"><i class="fa fa-search right rt-21"></i></button>
    </div>
</form>
<main>