hesabixWpTheme/inc/header-nav.php

1012 lines
47 KiB
PHP

<?php
/**
* ناوبری هدر — مگامنو، دراپ‌داون، موبایل آکاردئونی
*
* @package Hesabix2
*/
if (!defined('ABSPATH')) {
exit;
}
/**
* آدرس صفحه حامیان مالی / حمایت.
*
* @return string
*/
function hesabix2_sponsors_page_url() {
$pages = get_pages(
array(
'meta_key' => '_wp_page_template',
'meta_value' => 'page-sponsors.php',
'number' => 1,
)
);
if (!empty($pages)) {
return get_permalink($pages[0]->ID);
}
return home_url('/sponsors/');
}
/**
* آدرس صفحهٔ همدلی و اتحاد.
*
* @return string
*/
function hesabix2_hamdeli_page_url() {
$pages = get_pages(
array(
'meta_key' => '_wp_page_template',
'meta_value' => 'page-hamdeli.php',
'number' => 1,
)
);
if (!empty($pages)) {
return get_permalink($pages[0]->ID);
}
return home_url('/hamdeli/');
}
/**
* کلاس لینک فعال در ناوبری
*
* @param string $url
* @return string
*/
function hesabix2_header_link_current_class($url) {
$url = untrailingslashit((string) $url);
if ($url === '') {
return '';
}
if (function_exists('hesabix2_development_page_url')
&& is_page_template('page-development.php')
&& $url === untrailingslashit(hesabix2_development_page_url())
) {
return ' is-current';
}
if (function_exists('hesabix2_versions_compare_url')
&& is_page_template('page-arc-shadoman.php')
&& $url === untrailingslashit(hesabix2_versions_compare_url())
) {
return ' is-current';
}
if (function_exists('hesabix2_sponsors_page_url')
&& is_page_template('page-sponsors.php')
&& $url === untrailingslashit(hesabix2_sponsors_page_url())
) {
return ' is-current';
}
if (function_exists('hesabix2_hamdeli_page_url')
&& is_page_template('page-hamdeli.php')
&& $url === untrailingslashit(hesabix2_hamdeli_page_url())
) {
return ' is-current';
}
if (function_exists('hesabix2_android_page_url')
&& is_page_template('page-android.php')
&& $url === untrailingslashit(hesabix2_android_page_url())
) {
return ' is-current';
}
if (function_exists('hesabix2_windows_page_url')
&& is_page_template('page-windows.php')
&& $url === untrailingslashit(hesabix2_windows_page_url())
) {
return ' is-current';
}
if (function_exists('hesabix2_helo_page_url')
&& is_page_template('page-helo-hesabix.php')
&& $url === untrailingslashit(hesabix2_helo_page_url())
) {
return ' is-current';
}
if (function_exists('hesabix2_is_bbpress_page') && hesabix2_is_bbpress_page()
&& function_exists('hesabix2_bbpress_root_url')
&& $url === untrailingslashit(hesabix2_bbpress_root_url())
) {
return ' is-current';
}
if (function_exists('hesabix2_is_anspress_page') && hesabix2_is_anspress_page()
&& function_exists('hesabix2_anspress_base_url')
&& $url === untrailingslashit(hesabix2_anspress_base_url())
) {
return ' is-current';
}
if (function_exists('hesabix2_wc_is_shop_nav_active') && hesabix2_wc_is_shop_nav_active()
&& function_exists('hesabix2_wc_shop_url')
&& $url === untrailingslashit(hesabix2_wc_shop_url())
) {
return ' is-current';
}
if (class_exists('Shabake_Tamin_Public_Catalog', false)
&& Shabake_Tamin_Public_Catalog::is_request()
&& method_exists('Shabake_Tamin_Public_Catalog', 'catalog_url')
&& $url === untrailingslashit(Shabake_Tamin_Public_Catalog::catalog_url())
) {
return ' is-current';
}
if (function_exists('hwiki_is_wiki_request') && hwiki_is_wiki_request()
&& function_exists('hwiki_hub_url')
&& $url === untrailingslashit(hwiki_hub_url())
) {
return ' is-current';
}
if (function_exists('hhelp_is_help') && hhelp_is_help()
&& function_exists('hhelp_hub_url')
&& $url === untrailingslashit(hhelp_hub_url())
) {
return ' is-current';
}
if (function_exists('hesabix2_is_module_page') && hesabix2_is_module_page()) {
$key = get_post_meta(get_queried_object_id(), '_hesabix_module_key', true);
if ($key && function_exists('hesabix2_module_page_url')
&& $url === untrailingslashit(hesabix2_module_page_url((string) $key))
) {
return ' is-current';
}
}
if (is_page_template('page-about.php')
&& function_exists('hesabix2_about_page_url')
&& $url === untrailingslashit(hesabix2_about_page_url())
) {
return ' is-current';
}
if (is_page_template('page-brand.php')
&& function_exists('hesabix2_brand_page_url')
&& $url === untrailingslashit(hesabix2_brand_page_url())
) {
return ' is-current';
}
if (is_page() && !is_front_page()) {
$permalink = untrailingslashit((string) get_permalink());
if ($permalink && $permalink === $url) {
return ' is-current';
}
}
$blog_id = (int) get_option('page_for_posts');
if ($blog_id) {
$blog_url = untrailingslashit((string) get_permalink($blog_id));
if ($blog_url && $blog_url === $url && (is_home() || is_singular('post') || is_category() || is_tag() || is_author() || is_date())) {
return ' is-current';
}
}
return '';
}
/**
* آیا از منوی سفارشی وردپرس در هدر استفاده شود؟ (پیش‌فرض: مگامنؤ کد)
*/
function hesabix2_header_use_custom_menu() {
return (bool) apply_filters('hesabix2_header_use_custom_menu', false);
}
/**
* «درباره ما» همیشه آخرین آیتم سطح اول منو (بعد از فیلترها).
*
* @param array<int, array<string, mixed>> $tree
* @return array<int, array<string, mixed>>
*/
function hesabix2_header_nav_company_last(array $tree) {
$company = null;
$ordered = array();
foreach ($tree as $node) {
if (!is_array($node)) {
continue;
}
if (isset($node['id']) && 'company' === $node['id']) {
$company = $node;
continue;
}
$ordered[] = $node;
}
if (null !== $company) {
$ordered[] = $company;
}
return $ordered;
}
/**
* درخت ناوبری هدر (سطح اول + مگا/دراپ‌داون)
*
* سطح اول خلوت:
* - محصول: مگامنوی ماژول‌های آرک
* - بازار: فروشگاه و شبکهٔ تأمین (اگر خالی باشد حذف می‌شود)
* - منابع: آموزش، دانشنامه، API، انجمن
* - درباره: شرکت، تماس، برند، وبلاگ (آخر منو)
*
* @return array<int, array<string, mixed>>
*/
function hesabix2_header_nav_tree() {
$home = home_url('/');
$arc = function_exists('hesabix2_fp_arc_url') ? hesabix2_fp_arc_url() : 'https://arc.hesabix.ir';
$compare = function_exists('hesabix2_versions_compare_url')
? hesabix2_versions_compare_url()
: home_url('/arc-shadoman/');
$blog_id = (int) get_option('page_for_posts');
$blog = $blog_id ? get_permalink($blog_id) : home_url('/blog/');
$dev = function_exists('hesabix2_development_page_url')
? hesabix2_development_page_url()
: home_url('/development/');
$api = function_exists('hesabix2_api_docs_page_url') ? hesabix2_api_docs_page_url() : home_url('/api/');
$wiki = function_exists( 'hwiki_hub_url' ) ? hwiki_hub_url() : home_url( '/docs/' );
$help = function_exists( 'hesabix2_help_hub_url' ) ? hesabix2_help_hub_url() : ( function_exists( 'hhelp_hub_url' ) ? hhelp_hub_url() : home_url( '/help/' ) );
$mp = function_exists('hesabix2_module_page_url') ? 'hesabix2_module_page_url' : '';
$mod = static function ($key, $fallback = '/') use ($mp, $home) {
if ($mp && function_exists($mp)) {
return call_user_func($mp, $key);
}
return $home . ltrim($fallback, '/');
};
$enterprise = function_exists('hesabix2_enterprise_support_url')
? hesabix2_enterprise_support_url()
: home_url('/professional-support/');
$contact = function_exists('hesabix2_contact_page_url')
? hesabix2_contact_page_url()
: home_url('/contact/');
$about = function_exists('hesabix2_about_page_url')
? hesabix2_about_page_url()
: home_url('/about/');
$community = function_exists('hesabix2_community_url')
? hesabix2_community_url()
: home_url('/forums/');
$sponsors = function_exists('hesabix2_sponsors_page_url')
? hesabix2_sponsors_page_url()
: home_url('/sponsors/');
$hamdeli = function_exists('hesabix2_hamdeli_page_url')
? hesabix2_hamdeli_page_url()
: home_url('/hamdeli/');
$brand = function_exists('hesabix2_brand_page_url')
? hesabix2_brand_page_url()
: home_url('/brand/');
$chatgpt = function_exists('hesabix2_fp_chatgpt_url')
? hesabix2_fp_chatgpt_url()
: home_url('/chatgpt-hesabix/');
$market_items = array();
if (function_exists('hesabix2_is_woocommerce_active') && hesabix2_is_woocommerce_active() && function_exists('hesabix2_wc_shop_url')) {
$market_items[] = array(
'label' => __('فروشگاه', 'hesabix2'),
'description' => __('افزونه‌ها، لایسنس و محصولات دیجیتال', 'hesabix2'),
'url' => hesabix2_wc_shop_url(),
'icon' => 'shop',
);
}
$tree = array(
array(
'id' => 'product',
'label' => __('محصول', 'hesabix2'),
'type' => 'mega',
'columns' => array(
array(
'title' => __('مالی', 'hesabix2'),
'items' => array(
array(
'label' => __('حسابداری و گزارش', 'hesabix2'),
'description' => __('اسناد، تراز و داشبورد مالی', 'hesabix2'),
'url' => $mod('accounting'),
'icon' => 'finance',
),
array(
'label' => __('دریافت و پرداخت', 'hesabix2'),
'description' => __('چک، صندوق، بانک و تنخواه', 'hesabix2'),
'url' => $mod('treasury'),
'icon' => 'finance',
),
array(
'label' => __('یکپارچه‌سازی مودیان', 'hesabix2'),
'description' => __('صورتحساب الکترونیک و پیگیری وضعیت ارسال', 'hesabix2'),
'url' => $mod('tax-moudian'),
'icon' => 'tax',
'badge' => __('انطباق', 'hesabix2'),
),
array(
'label' => __('حقوق و دستمزد', 'hesabix2'),
'description' => __('فیش، کسور قانونی و سند مالی', 'hesabix2'),
'url' => $mod('payroll'),
'icon' => 'finance',
),
),
),
array(
'title' => __('فروش و CRM', 'hesabix2'),
'items' => array(
array(
'label' => __('فاکتور و فروش', 'hesabix2'),
'description' => __('صورتحساب، پیش‌فاکتور و چرخه فروش', 'hesabix2'),
'url' => $mod('invoicing'),
'icon' => 'invoice',
),
array(
'label' => __('CRM و مشتریان', 'hesabix2'),
'description' => __('مخاطب، فرصت فروش و پرونده', 'hesabix2'),
'url' => $mod('crm'),
'icon' => 'crm',
),
array(
'label' => __('باشگاه مشتریان', 'hesabix2'),
'description' => __('امتیاز، سطح‌بندی و وفاداری', 'hesabix2'),
'url' => $mod('loyalty'),
'icon' => 'loyalty',
),
array(
'label' => __('کسب‌وکار آنلاین', 'hesabix2'),
'description' => __('چت سایت، CRM و فروش یکپارچه', 'hesabix2'),
'url' => $mod('online-business'),
'icon' => 'online',
),
),
),
array(
'title' => __('عملیات', 'hesabix2'),
'items' => array(
array(
'label' => __('انبار و موجودی', 'hesabix2'),
'description' => __('چند انبار و گردش کالا', 'hesabix2'),
'url' => $mod('inventory'),
'icon' => 'warehouse',
),
array(
'label' => __('پخش مویرگی', 'hesabix2'),
'description' => __('ویزیت، مسیر، توزیع و وصول', 'hesabix2'),
'url' => $mod('distribution'),
'icon' => 'supply',
),
array(
'label' => __('تولید و BOM', 'hesabix2'),
'description' => __('فرمول ساخت و سفارش تولید', 'hesabix2'),
'url' => $mod('production'),
'icon' => 'warehouse',
),
array(
'label' => __('یکپارچه‌سازی', 'hesabix2'),
'description' => __('ووکامرس، API و افزونه‌ها', 'hesabix2'),
'url' => $mod('integrations'),
'icon' => 'integration',
),
),
),
array(
'title' => __('هوشمندسازی', 'hesabix2'),
'items' => array(
array(
'label' => __('ورک‌فلو و اتوماسیون', 'hesabix2'),
'description' => __('قوانین خودکار بین ماژول‌ها', 'hesabix2'),
'url' => $mod('workflow'),
'icon' => 'workflow',
),
array(
'label' => __('هوش مصنوعی', 'hesabix2'),
'description' => __('تحلیل، پیشنهاد و دستیار', 'hesabix2'),
'url' => $mod('ai'),
'icon' => 'ai',
),
array(
'label' => __('ایجنت و MCP', 'hesabix2'),
'description' => __('ChatGPT، Claude و اقدام با نقش شما', 'hesabix2'),
'url' => $mod('agents'),
'icon' => 'ai',
'badge' => __('MCP', 'hesabix2'),
),
),
),
),
'footer' => array(
array(
'label' => __('مقایسه آرک و شادمان', 'hesabix2'),
'url' => $compare,
),
array(
'label' => __('همهٔ امکانات پلتفرم', 'hesabix2'),
'url' => $mod('platform'),
),
array(
'label' => __('شروع رایگان — آرک', 'hesabix2'),
'url' => $arc,
'external' => true,
'entry' => 'arc',
'class' => 'hesabix-header-mega__footer-cta',
),
),
),
array(
'id' => 'scope',
'label' => __('کسب‌وکار شما', 'hesabix2'),
'type' => 'mega',
'columns' => array(
array(
'title' => __('مقیاس و کانال', 'hesabix2'),
'items' => array(
array(
'label' => __('مغازه و صنف', 'hesabix2'),
'description' => __('فاکتور و موجودی از روز اول', 'hesabix2'),
'url' => $mod('for-shop'),
'icon' => 'shop',
),
array(
'label' => __('خرده‌فروشی', 'hesabix2'),
'description' => __('شعبه، باشگاه و صندوق', 'hesabix2'),
'url' => $mod('for-retail'),
'icon' => 'shop',
),
array(
'label' => __('فروش آنلاین', 'hesabix2'),
'description' => __('ووکامرس و مارکت‌پلیس', 'hesabix2'),
'url' => $mod('for-online'),
'icon' => 'online',
),
array(
'label' => __('خدمات و تعمیرگاه', 'hesabix2'),
'description' => __('پذیرش، قطعه و گارانتی', 'hesabix2'),
'url' => $mod('for-services'),
'icon' => 'chat',
),
array(
'label' => __('هلدینگ و سازمان بزرگ', 'hesabix2'),
'description' => __('چند شرکت، نقش و MCP', 'hesabix2'),
'url' => $mod('for-holding'),
'icon' => 'enterprise',
),
),
),
array(
'title' => __('صنعت', 'hesabix2'),
'items' => array(
array(
'label' => __('پخش و عمده', 'hesabix2'),
'description' => __('ویزیت، مسیر و وصول', 'hesabix2'),
'url' => $mod('for-pakhsh'),
'icon' => 'supply',
),
array(
'label' => __('کارخانه و تولید', 'hesabix2'),
'description' => __('BOM، مواد و بهای تمام‌شده', 'hesabix2'),
'url' => $mod('for-factory'),
'icon' => 'warehouse',
),
array(
'label' => __('صنایع غذایی', 'hesabix2'),
'description' => __('تولید تا پخش سرد و گرم', 'hesabix2'),
'url' => $mod('for-food'),
'icon' => 'warehouse',
),
array(
'label' => __('دارو و تجهیزات', 'hesabix2'),
'description' => __('موجودی حساس و انطباق', 'hesabix2'),
'url' => $mod('for-pharma'),
'icon' => 'tax',
),
array(
'label' => __('انرژی و پتروشیمی', 'hesabix2'),
'description' => __('دارایی، پروژه و چند ارز', 'hesabix2'),
'url' => $mod('for-energy'),
'icon' => 'enterprise',
),
),
),
),
'footer' => array(
array(
'label' => __('همهٔ موقعیت‌های کسب‌وکار', 'hesabix2'),
'url' => $mod('platform') . '#scope',
),
array(
'label' => __('شروع رایگان — آرک', 'hesabix2'),
'url' => $arc,
'external' => true,
'entry' => 'arc',
'class' => 'hesabix-header-mega__footer-cta',
),
),
),
array(
'id' => 'market',
'label' => __('بازار', 'hesabix2'),
'type' => 'dropdown',
'items' => $market_items,
),
array(
'id' => 'resources',
'label' => __('منابع', 'hesabix2'),
'type' => 'dropdown',
'items' => array(
array(
'label' => __('راهنمای جامع', 'hesabix2'),
'description' => __('آموزش درختی آرک؛ رایگان و اختصاصی', 'hesabix2'),
'url' => $help,
'icon' => 'guide',
),
array(
'label' => __('دانشنامه', 'hesabix2'),
'description' => __('مستندات فنی و ویکی', 'hesabix2'),
'url' => $wiki,
'icon' => 'wiki',
),
array(
'label' => __('مرجع API', 'hesabix2'),
'description' => __('OpenAPI و یکپارچه‌سازی', 'hesabix2'),
'url' => $api,
'icon' => 'api',
),
array(
'label' => __('اتصال ChatGPT', 'hesabix2'),
'description' => __('سرور MCP حسابیکس برای دستیارها', 'hesabix2'),
'url' => $chatgpt,
'icon' => 'ai',
'badge' => __('MCP', 'hesabix2'),
),
array(
'label' => __('انجمن', 'hesabix2'),
'description' => __('گفت‌وگو با کاربران و تیم', 'hesabix2'),
'url' => $community,
'icon' => 'forum',
),
array(
'label' => __('وضعیت توسعه', 'hesabix2'),
'description' => __('به‌روزرسانی‌ها و نقشه راه', 'hesabix2'),
'url' => $dev,
'icon' => 'dev',
),
array(
'label' => __('پشتیبانی اختصاصی', 'hesabix2'),
'description' => __('قرارداد سازمانی و همراهی حرفه‌ای', 'hesabix2'),
'url' => $enterprise,
'icon' => 'enterprise',
),
),
),
array(
'id' => 'company',
'label' => __('درباره', 'hesabix2'),
'type' => 'dropdown',
'items' => array(
array(
'label' => __('داستان حسابیکس', 'hesabix2'),
'description' => __('ماموریت، آرک و جامعهٔ متن‌باز', 'hesabix2'),
'url' => $about,
'icon' => 'about',
),
array(
'label' => __('تماس با ما', 'hesabix2'),
'description' => __('پشتیبانی، فروش و همکاری', 'hesabix2'),
'url' => $contact,
'icon' => 'contact',
),
array(
'label' => __('دستورالعمل برند', 'hesabix2'),
'description' => __('نام، نشان و قوانین استفاده', 'hesabix2'),
'url' => $brand,
'icon' => 'brand',
),
array(
'label' => __('وبلاگ', 'hesabix2'),
'description' => __('مقالات و اخبار محصول', 'hesabix2'),
'url' => $blog,
'icon' => 'blog',
),
array(
'label' => __('حامیان مالی', 'hesabix2'),
'description' => __('حمایت از توسعهٔ متن‌باز حسابیکس', 'hesabix2'),
'url' => $sponsors,
'icon' => 'sponsors',
),
array(
'label' => __('یک تن باشیم', 'hesabix2'),
'description' => __('پیام همدلی و اتحاد از تیم حسابیکس', 'hesabix2'),
'url' => $hamdeli,
'icon' => 'heart',
),
),
),
);
$tree = apply_filters('hesabix2_header_nav_tree', $tree);
$tree = hesabix2_header_nav_company_last($tree);
$tree = array_values(
array_filter(
$tree,
static function ($node) {
if (!is_array($node)) {
return false;
}
$type = isset($node['type']) ? (string) $node['type'] : '';
if ('dropdown' === $type && isset($node['id']) && 'market' === $node['id']) {
return !empty($node['items']) && is_array($node['items']);
}
return true;
}
)
);
return $tree;
}
/**
* لینک‌های اصلی (سازگاری با فیلترهای قدیمی)
*
* @return array<int, array<string, mixed>>
*/
function hesabix2_header_primary_links() {
$links = array();
foreach (hesabix2_header_nav_tree() as $node) {
if (isset($node['type']) && 'link' === $node['type'] && !empty($node['url'])) {
$links[] = array(
'label' => $node['label'],
'url' => $node['url'],
);
}
}
return apply_filters('hesabix2_header_primary_links', $links);
}
/**
* لینک‌های بیشتر (سازگاری — خالی؛ محتوا در درخت است)
*
* @return array<int, array<string, mixed>>
*/
function hesabix2_header_more_links() {
return apply_filters('hesabix2_header_more_links', array());
}
/**
* ویژگی‌های data برای لینک ورود آرک/شادمان
*
* @param array<string, mixed> $item
* @return string
*/
function hesabix2_header_nav_entry_attrs($item) {
if (empty($item['entry']) || !function_exists('hesabix2_entry_link_attrs')) {
return '';
}
$url = isset($item['url']) ? (string) $item['url'] : '';
return hesabix2_entry_link_attrs((string) $item['entry'], $url);
}
/**
* آیکن SVG منو
*
* @param string $icon
* @return string
*/
function hesabix2_header_nav_icon_svg($icon) {
$paths = array(
'finance' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 7h6m0 10v-3m-3 3h.01M9 17h.01M9 14h.01M12 14h.01M15 11h.01M12 11h.01M9 11h.01M7 21h10a2 2 0 002-2V5a2 2 0 00-2-2H7a2 2 0 00-2 2v14a2 2 0 002 2z"/>',
'tax' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>',
'invoice' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>',
'crm' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0z"/>',
'loyalty' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v13m0-13V6a2 2 0 112 2h-2zm0 0V5.5A2.5 2.5 0 109.5 8H12zm-7 4h14M5 12a2 2 0 110-4h14a2 2 0 110 4M5 12v7a2 2 0 002 2h10a2 2 0 002-2v-7"/>',
'warehouse' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"/>',
'chat' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"/>',
'integration' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/>',
'workflow' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 5a1 1 0 011-1h14a1 1 0 011 1v2a1 1 0 01-1 1H5a1 1 0 01-1-1V5zM4 13a1 1 0 011-1h6a1 1 0 011 1v6a1 1 0 01-1 1H5a1 1 0 01-1-1v-6zM16 13a1 1 0 011-1h2a1 1 0 011 1v6a1 1 0 01-1 1h-2a1 1 0 01-1-1v-6z"/>',
'ai' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 3v4M3 5h4M6 17v4m-2-2h4m5-16l2.286 6.857L21 12l-5.714 2.143L13 21l-2.286-6.857L5 12l5.714-2.143L13 3z"/>',
'online' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"/>',
'enterprise' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"/>',
'about' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"/>',
'brand' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21a4 4 0 01-4-4V5a2 2 0 012-2h4a2 2 0 012 2v12a4 4 0 01-4 4zm0 0h12a2 2 0 002-2v-4a2 2 0 00-2-2h-2.343M11 7.343l1.657-1.657a2 2 0 012.828 0l2.829 2.829a2 2 0 010 2.828l-8.486 8.485M7 17h.01"/>',
'heart' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"/>',
'contact' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/>',
'shop' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z"/>',
'supply' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"/>',
'wiki' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"/>',
'api' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"/>',
'faq' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>',
'guide' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"/>',
'dev' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"/>',
'mobile' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 18h.01M8 21h8a2 2 0 002-2V5a2 2 0 00-2-2H8a2 2 0 00-2 2v14a2 2 0 002 2z"/>',
'desktop' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/>',
'sponsors' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"/>',
'code' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>',
'forum' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 8h2a2 2 0 012 2v6a2 2 0 01-2 2h-2v4l-4-4H9a1.994 1.994 0 01-1.414-.586m0 0L11 14h4a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2v4l.586-.586z"/>',
'blog' => '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 20H5a2 2 0 01-2-2V6a2 2 0 012-2h10a2 2 0 012 2v1m2 13a2 2 0 01-2-2V7m2 13a2 2 0 002-2V9a2 2 0 00-2-2h-2m-4-3H9M7 16h6M7 8h6v4H7V8z"/>',
);
$path = isset($paths[$icon]) ? $paths[$icon] : $paths['guide'];
return '<svg class="hesabix-nav-icon" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" aria-hidden="true">' . $path . '</svg>';
}
/**
* رندر یک لینک منو (دسکتاپ)
*
* @param array<string, mixed> $item
* @param string $class_base
*/
function hesabix2_header_nav_render_desktop_item($item, $class_base = 'hesabix-header-nav__card') {
$url = isset($item['url']) ? (string) $item['url'] : '#';
$ext = !empty($item['external']);
$icon = isset($item['icon']) ? (string) $item['icon'] : 'guide';
$cls = $class_base . hesabix2_header_link_current_class($url);
if (!empty($item['class'])) {
$cls .= ' ' . esc_attr((string) $item['class']);
}
$current = hesabix2_header_link_current_class($url) ? ' aria-current="page"' : '';
?>
<a
href="<?php echo esc_url($url); ?>"
class="<?php echo esc_attr(trim($cls)); ?>"
<?php echo $ext ? 'target="_blank" rel="noopener noreferrer"' : ''; ?>
<?php echo hesabix2_header_nav_entry_attrs($item); ?>
<?php echo $current; ?>
>
<span class="hesabix-header-nav__card-icon"><?php echo hesabix2_header_nav_icon_svg($icon); ?></span>
<span class="hesabix-header-nav__card-text">
<span class="hesabix-header-nav__card-label-row">
<span class="hesabix-header-nav__card-label"><?php echo esc_html($item['label']); ?></span>
<?php if (!empty($item['badge'])) : ?>
<span class="hesabix-header-nav__card-badge"><?php echo esc_html($item['badge']); ?></span>
<?php endif; ?>
</span>
<?php if (!empty($item['description'])) : ?>
<span class="hesabix-header-nav__card-desc"><?php echo esc_html($item['description']); ?></span>
<?php endif; ?>
</span>
</a>
<?php
}
/**
* رندر منوی دسکتاپ
*/
function hesabix2_render_header_desktop_nav() {
if (hesabix2_header_use_custom_menu()) {
wp_nav_menu(
array(
'theme_location' => 'primary',
'container' => false,
'menu_class' => 'hesabix-header-nav__list hesabix-header-nav__list--wp',
'fallback_cb' => false,
)
);
return;
}
$tree = hesabix2_header_nav_tree();
?>
<ul class="hesabix-header-nav__list hesabix-header-nav__list--mega" role="list">
<?php
foreach ($tree as $node) :
if (empty($node['label'])) {
continue;
}
$id = !empty($node['id']) ? sanitize_html_class((string) $node['id']) : 'nav-item';
$type = !empty($node['type']) ? (string) $node['type'] : 'link';
if ('link' === $type && !empty($node['url'])) :
$cls = 'hesabix-header-nav__link' . hesabix2_header_link_current_class($node['url']);
if (!empty($node['class'])) {
$cls .= ' ' . esc_attr((string) $node['class']);
}
?>
<li class="hesabix-header-nav__item">
<a href="<?php echo esc_url($node['url']); ?>" class="<?php echo esc_attr(trim($cls)); ?>"<?php echo hesabix2_header_link_current_class($node['url']) ? ' aria-current="page"' : ''; ?>><?php echo esc_html($node['label']); ?></a>
</li>
<?php
continue;
endif;
if ('mega' === $type && !empty($node['columns'])) :
$panel_id = 'hesabix-nav-mega-' . $id;
$col_n = count($node['columns']);
?>
<li class="hesabix-header-nav__item hesabix-header-dropdown" data-header-dropdown>
<button
type="button"
class="hesabix-header-nav__link hesabix-header-dropdown__trigger"
aria-expanded="false"
aria-haspopup="true"
aria-controls="<?php echo esc_attr($panel_id); ?>"
id="<?php echo esc_attr($panel_id); ?>-btn"
>
<?php echo esc_html($node['label']); ?>
<svg class="hesabix-header-dropdown__chevron" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M19 9l-7 7-7-7"/></svg>
</button>
<div
id="<?php echo esc_attr($panel_id); ?>"
class="hesabix-header-mega__panel<?php echo 'product' === $id ? ' hesabix-header-mega__panel--arc' : ''; ?>"
role="region"
aria-labelledby="<?php echo esc_attr($panel_id); ?>-btn"
hidden
>
<div class="hesabix-header-mega__grid" data-cols="<?php echo (int) $col_n; ?>">
<?php foreach ($node['columns'] as $column) : ?>
<div class="hesabix-header-mega__col">
<?php if (!empty($column['title'])) : ?>
<p class="hesabix-header-mega__col-title"><?php echo esc_html($column['title']); ?></p>
<?php endif; ?>
<?php
if (!empty($column['items']) && is_array($column['items'])) :
foreach ($column['items'] as $item) :
hesabix2_header_nav_render_desktop_item($item);
endforeach;
endif;
?>
</div>
<?php endforeach; ?>
</div>
<?php if (!empty($node['footer']) && is_array($node['footer'])) : ?>
<div class="hesabix-header-mega__footer">
<?php foreach ($node['footer'] as $foot) :
$fcls = 'hesabix-header-mega__footer-link' . hesabix2_header_link_current_class($foot['url']);
if (!empty($foot['class'])) {
$fcls .= ' ' . esc_attr((string) $foot['class']);
}
$fext = !empty($foot['external']);
?>
<a
href="<?php echo esc_url($foot['url']); ?>"
class="<?php echo esc_attr(trim($fcls)); ?>"
<?php echo $fext ? 'target="_blank" rel="noopener noreferrer"' : ''; ?>
<?php echo hesabix2_header_nav_entry_attrs($foot); ?>
><?php echo esc_html($foot['label']); ?></a>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
</li>
<?php
continue;
endif;
if (in_array($type, array('dropdown', 'menu'), true) && !empty($node['items']) && is_array($node['items'])) :
$panel_id = 'hesabix-nav-drop-' . $id;
?>
<li class="hesabix-header-nav__item hesabix-header-dropdown" data-header-dropdown>
<button
type="button"
class="hesabix-header-nav__link hesabix-header-dropdown__trigger"
aria-expanded="false"
aria-haspopup="true"
aria-controls="<?php echo esc_attr($panel_id); ?>"
id="<?php echo esc_attr($panel_id); ?>-btn"
>
<?php echo esc_html($node['label']); ?>
<svg class="hesabix-header-dropdown__chevron" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M19 9l-7 7-7-7"/></svg>
</button>
<div
id="<?php echo esc_attr($panel_id); ?>"
class="hesabix-header-drop__panel"
role="region"
aria-labelledby="<?php echo esc_attr($panel_id); ?>-btn"
hidden
>
<?php foreach ($node['items'] as $item) :
hesabix2_header_nav_render_desktop_item($item, 'hesabix-header-drop__link');
endforeach; ?>
</div>
</li>
<?php
endif;
endforeach;
?>
</ul>
<?php
}
/**
* رندر لینک موبایل
*
* @param array<string, mixed> $item
*/
function hesabix2_header_nav_render_mobile_link($item) {
$url = isset($item['url']) ? (string) $item['url'] : '#';
$ext = !empty($item['external']);
$cls = 'hesabix-mobile-link' . hesabix2_header_link_current_class($url);
if (!empty($item['class'])) {
$cls .= ' ' . esc_attr((string) $item['class']);
}
?>
<a
href="<?php echo esc_url($url); ?>"
class="<?php echo esc_attr(trim($cls)); ?>"
<?php echo $ext ? 'target="_blank" rel="noopener noreferrer"' : ''; ?>
<?php echo hesabix2_header_nav_entry_attrs($item); ?>
<?php echo hesabix2_header_link_current_class($url) ? ' aria-current="page"' : ''; ?>
><?php echo esc_html($item['label']); ?><?php if (!empty($item['badge'])) : ?><span class="hesabix-mobile-link__badge"><?php echo esc_html($item['badge']); ?></span><?php endif; ?></a>
<?php
}
/**
* رندر منوی موبایل (آکاردئون)
*/
function hesabix2_render_header_mobile_nav() {
if (hesabix2_header_use_custom_menu()) {
wp_nav_menu(
array(
'theme_location' => 'primary',
'container' => false,
'menu_class' => 'hesabix-header-mobile__list hesabix-header-mobile__list--wp',
'fallback_cb' => false,
)
);
return;
}
$tree = hesabix2_header_nav_tree();
echo '<div class="hesabix-mobile-nav-groups">';
foreach ($tree as $node) {
if (empty($node['label'])) {
continue;
}
$type = !empty($node['type']) ? (string) $node['type'] : 'link';
$id = !empty($node['id']) ? sanitize_html_class((string) $node['id']) : 'mnav';
if ('link' === $type && !empty($node['url'])) {
hesabix2_header_nav_render_mobile_link(
array(
'label' => $node['label'],
'url' => $node['url'],
'class' => !empty($node['class']) ? (string) $node['class'] : '',
)
);
continue;
}
$panel_id = 'hesabix-mnav-' . $id;
?>
<div class="hesabix-mobile-nav-group" data-mobile-nav-group>
<button
type="button"
class="hesabix-mobile-nav-group__trigger"
aria-expanded="false"
aria-controls="<?php echo esc_attr($panel_id); ?>"
>
<span><?php echo esc_html($node['label']); ?></span>
<svg class="hesabix-mobile-nav-group__chevron" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M19 9l-7 7-7-7"/></svg>
</button>
<div id="<?php echo esc_attr($panel_id); ?>" class="hesabix-mobile-nav-group__panel" hidden>
<?php
if ('mega' === $type && !empty($node['columns'])) {
foreach ($node['columns'] as $column) {
if (!empty($column['title'])) {
echo '<p class="hesabix-mobile-nav-group__subtitle">' . esc_html($column['title']) . '</p>';
}
if (!empty($column['items']) && is_array($column['items'])) {
foreach ($column['items'] as $item) {
hesabix2_header_nav_render_mobile_link($item);
}
}
}
if (!empty($node['footer']) && is_array($node['footer'])) {
echo '<div class="hesabix-mobile-nav-group__footer">';
foreach ($node['footer'] as $foot) {
hesabix2_header_nav_render_mobile_link($foot);
}
echo '</div>';
}
} elseif (!empty($node['items']) && is_array($node['items'])) {
foreach ($node['items'] as $item) {
hesabix2_header_nav_render_mobile_link($item);
}
}
?>
</div>
</div>
<?php
}
echo '</div>';
}