📁 File Manager
Editing:
/home/wvl7mof7402e/public_html/chem/header.php
<?php /** * Pure Chemical - Premium Responsive Header * File: /header.php * * Features: * - Dynamic database settings, logo and menu * - Contact Us and Blogs menu fallback * - Premium slogan and contact information bar * - Dropdown arrows and nested mobile accordion * - No Get In Touch button * - No separate call button */ declare(strict_types=1); /* ========================================================= DATABASE CONNECTION ========================================================= */ $pdo = $pdo ?? null; if (!$pdo instanceof PDO) { require_once __DIR__ . '/admin/includes/db.php'; } /* ========================================================= HELPERS ========================================================= */ if (!function_exists('e')) { function e(?string $value): string { return htmlspecialchars( $value ?? '', ENT_QUOTES, 'UTF-8' ); } } if (!function_exists('frontend_url')) { function frontend_url(?string $url, string $baseUrl = ''): string { $url = trim((string) $url); if ($url === '' || $url === '#') { return '#'; } if (preg_match( '~^(https?:)?//|^(mailto:|tel:|javascript:)~i', $url )) { return $url; } $url = ltrim($url, '/'); $baseUrl = trim($baseUrl, '/'); $decodedUrl = rawurldecode($url); $decodedBase = rawurldecode($baseUrl); if ( $decodedBase !== '' && strncasecmp( $decodedUrl, $decodedBase . '/', strlen($decodedBase) + 1 ) === 0 ) { $url = substr( $decodedUrl, strlen($decodedBase) + 1 ); } $encodedPath = implode( '/', array_map('rawurlencode', explode('/', $url)) ); return '/' . ($baseUrl !== '' ? $baseUrl . '/' : '') . $encodedPath; } } /* ========================================================= CURRENT PATH ========================================================= */ $currentPath = parse_url( $_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH ); $currentPath = '/' . trim((string) $currentPath, '/'); if ($currentPath === '//') { $currentPath = '/'; } /* ========================================================= SITE SETTINGS ========================================================= */ $siteSettings = []; try { if (!$pdo instanceof PDO) { throw new RuntimeException('Database connection unavailable.'); } $settingsStmt = $pdo->query(" SELECT setting_key, setting_value FROM site_settings WHERE status = 1 "); foreach ($settingsStmt->fetchAll(PDO::FETCH_ASSOC) as $setting) { $siteSettings[$setting['setting_key']] = $setting['setting_value']; } } catch (Throwable $ex) { error_log('[Pure Chemical Header] Settings Error: ' . $ex->getMessage()); } /* ========================================================= WEBSITE INFORMATION ========================================================= */ $siteName = $siteSettings['site_name'] ?? 'Pure Chemicals'; $sitePhone = trim((string) ( $siteSettings['phone'] ?? $siteSettings['contact_phone'] ?? '' )); if ($sitePhone === '') { $sitePhone = '+91 7428 465 992'; } $siteEmail = trim((string) ( $siteSettings['email'] ?? $siteSettings['contact_email'] ?? '' )); if ($siteEmail === '') { $siteEmail = 'V.Kumar1087@gmail.com'; } /* ========================================================= PROJECT ROOT AND BASE URL ========================================================= */ $headerDir = realpath(__DIR__) ?: __DIR__; $projectRootPath = $headerDir; for ($i = 0; $i < 6; $i++) { if (is_file( $projectRootPath . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'logo.png' )) { break; } $parent = dirname($projectRootPath); if ($parent === $projectRootPath) { break; } $projectRootPath = $parent; } $documentRoot = realpath( $_SERVER['DOCUMENT_ROOT'] ?? '' ) ?: ''; $projectBaseUrl = ''; if ($documentRoot !== '') { $normalizedRoot = str_replace('\\', '/', $projectRootPath); $normalizedDocRoot = rtrim( str_replace('\\', '/', $documentRoot), '/' ); if ( strncasecmp( $normalizedRoot, $normalizedDocRoot . '/', strlen($normalizedDocRoot) + 1 ) === 0 || strcasecmp($normalizedRoot, $normalizedDocRoot) === 0 ) { $relativeProject = substr( $normalizedRoot, strlen($normalizedDocRoot) ); $projectBaseUrl = rtrim( implode( '/', array_map( 'rawurlencode', array_filter(explode('/', $relativeProject), 'strlen') ) ), '/' ); } } /* ========================================================= LOGO ========================================================= */ $siteLogo = trim((string) ($siteSettings['site_logo'] ?? '')); if ($siteLogo === '') { $siteLogo = 'uploads/logo.png'; } $siteLogo = str_replace('\\', '/', $siteLogo); if (!preg_match('~^(https?:)?//|^data:~i', $siteLogo)) { $savedLogoPath = preg_replace( '~^/?pure(?:%20| )chemical/~i', '', $siteLogo ); $savedLogoPath = ltrim((string) $savedLogoPath, '/'); $savedLogoFile = $projectRootPath . DIRECTORY_SEPARATOR . str_replace( '/', DIRECTORY_SEPARATOR, rawurldecode($savedLogoPath) ); if (is_file($savedLogoFile)) { $siteLogo = $savedLogoPath; } else { $siteLogo = 'uploads/logo.png'; } } if (!function_exists('site_asset_url')) { function site_asset_url(string $path, string $baseUrl = ''): string { $path = trim(str_replace('\\', '/', $path)); if ($path === '') { return ''; } if (preg_match('~^(https?:)?//|^data:~i', $path)) { return $path; } $path = ltrim($path, '/'); $basePath = trim(rawurldecode(trim($baseUrl, '/')), '/'); $decodedPath = rawurldecode($path); if ( $basePath !== '' && strncasecmp( $decodedPath, $basePath . '/', strlen($basePath) + 1 ) === 0 ) { $path = substr($decodedPath, strlen($basePath) + 1); } else { $path = $decodedPath; } $encodedPath = implode( '/', array_map('rawurlencode', explode('/', $path)) ); return '/' . ($baseUrl !== '' ? trim($baseUrl, '/') . '/' : '') . $encodedPath; } } $siteLogo = site_asset_url($siteLogo, $projectBaseUrl); $homeUrl = '/' . trim($projectBaseUrl, '/') . '/'; if ($homeUrl === '//') { $homeUrl = '/'; } $contactUrl = frontend_url('contact-us.php', $projectBaseUrl); $blogsUrl = frontend_url('blogs.php', $projectBaseUrl); /* ========================================================= DYNAMIC MENU ========================================================= */ $headerMenu = null; $menuItems = []; $menuChildren = []; try { if (!$pdo instanceof PDO) { throw new RuntimeException('Database connection unavailable.'); } $menuStmt = $pdo->prepare(" SELECT * FROM menus WHERE status = 1 AND ( location = :location OR name = :name OR slug = :slug ) ORDER BY CASE WHEN location = 'header' THEN 1 WHEN name = 'Header' THEN 2 WHEN slug = 'header' THEN 3 ELSE 4 END, id ASC LIMIT 1 "); $menuStmt->execute([ ':location' => 'header', ':name' => 'Header', ':slug' => 'header', ]); $headerMenu = $menuStmt->fetch(PDO::FETCH_ASSOC); if ($headerMenu) { $itemStmt = $pdo->prepare(" SELECT * FROM menu_items WHERE menu_id = ? AND status = 1 ORDER BY sort_order ASC, id ASC "); $itemStmt->execute([$headerMenu['id']]); $menuItems = $itemStmt->fetchAll(PDO::FETCH_ASSOC); foreach ($menuItems as $item) { $parentId = (int) ($item['parent_id'] ?? 0); if ($parentId > 0) { $menuChildren[$parentId][] = $item; } } } } catch (Throwable $ex) { error_log('[Pure Chemical Header] Menu Error: ' . $ex->getMessage()); } /* ========================================================= ACTIVE MENU HELPER ========================================================= */ if (!function_exists('is_menu_active')) { function is_menu_active(array $item, string $currentPath): bool { $url = trim((string) ( $item['url'] ?? $item['link'] ?? $item['path'] ?? '' )); if ( $url === '' || str_starts_with($url, '#') || preg_match('~^(https?:)?//~i', $url) ) { return false; } $menuPath = parse_url($url, PHP_URL_PATH); $menuPath = '/' . trim((string) $menuPath, '/'); if ($menuPath === '//') { $menuPath = '/'; } $base = trim( rawurldecode($GLOBALS['projectBaseUrl'] ?? ''), '/' ); if ($base !== '') { $menuPath = preg_replace( '~^/' . preg_quote($base, '~') . '(?=/|$)~i', '', $menuPath ) ?: '/'; } $currentPath = preg_replace( '~^/' . preg_quote($base, '~') . '(?=/|$)~i', '', $currentPath ) ?: '/'; return strcasecmp( rawurldecode($menuPath), rawurldecode($currentPath) ) === 0; } } /* ========================================================= MENU ICON HELPER ========================================================= */ if (!function_exists('menu_icon')) { function menu_icon(array $item): string { $icon = trim((string) ($item['icon'] ?? '')); if ( $icon === '' || !preg_match('/^[a-zA-Z0-9 _-]+$/', $icon) ) { return ''; } return '<i class="' . e($icon) . '" aria-hidden="true"></i>'; } } /* ========================================================= CONTACT AND BLOG MENU FALLBACKS ========================================================= */ $hasContactMenu = false; $hasBlogsMenu = false; foreach ($menuItems as $item) { if ((int) ($item['parent_id'] ?? 0) !== 0) { continue; } $name = strtolower(trim((string) ( $item['name'] ?? $item['title'] ?? '' ))); $slug = strtolower(trim((string) ($item['slug'] ?? ''))); $url = strtolower(trim((string) ( $item['url'] ?? $item['link'] ?? $item['path'] ?? '' ))); if ( in_array($name, ['contact', 'contact us', 'contact-us'], true) || in_array($slug, ['contact', 'contact-us', 'contact_us'], true) || str_contains($url, 'contact-us.php') ) { $hasContactMenu = true; } if ( in_array($name, ['blog', 'blogs'], true) || in_array($slug, ['blog', 'blogs'], true) || str_contains($url, 'blogs.php') ) { $hasBlogsMenu = true; } } /* ========================================================= PAGE TITLE ========================================================= */ $pageTitle = $siteName; if (!empty($page_title)) { $pageTitle = $page_title . ' | ' . $siteName; } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="theme-color" content="#071a33"> <title><?= e($pageTitle) ?></title> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700;800&family=Manrope:wght@500;600;700;800&display=swap" rel="stylesheet" > <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" > <style> :root { --pc-navy: #071a33; --pc-navy-light: #0c2d51; --pc-blue: #087fc0; --pc-cyan: #13b9dc; --pc-text: #20334b; --pc-muted: #6e8198; --pc-border: #e5edf5; --pc-white: #fff; --pc-soft: #f1f8fc; } .pc-header-wrap, .pc-header-wrap *, .pc-mobile-panel, .pc-mobile-panel * { box-sizing: border-box; } .pc-header-wrap { position: relative; z-index: 1000; width: 100%; font-family: "DM Sans", sans-serif; } .pc-header-wrap a, .pc-mobile-panel a { text-decoration: none; } /* PREMIUM SLOGAN STRIP */ .pc-slogan-strip { position: relative; overflow: hidden; color: #fff; background: radial-gradient(circle at 15% 50%, rgba(20,184,223,.18), transparent 30%), linear-gradient(110deg, #06162d 0%, #0b2b52 55%, #07517a 100%); } .pc-slogan-inner { width: min(1380px, calc(100% - 44px)); min-height: 44px; margin: auto; display: flex; align-items: center; justify-content: space-between; gap: 22px; } .pc-slogan { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 11px; font-weight: 700; letter-spacing: .35px; } .pc-slogan-mark { display: inline-flex; align-items: center; justify-content: center; width: 25px; height: 25px; flex: 0 0 25px; border: 1px solid rgba(20,184,223,.4); border-radius: 8px; color: #56e0f4; background: rgba(20,184,223,.12); } .pc-slogan-highlight { color: #65e2f5; } .pc-top-contacts { display: flex; align-items: center; justify-content: flex-end; gap: 21px; } .pc-top-contact { display: inline-flex; align-items: center; gap: 8px; min-width: 0; color: rgba(255,255,255,.9); font-size: 11px; font-weight: 600; transition: color .2s ease; } .pc-top-contact:hover { color: #6be5f6; } .pc-top-contact-icon { display: inline-flex; align-items: center; justify-content: center; width: 25px; height: 25px; flex: 0 0 25px; border-radius: 7px; color: #66e2f5; background: rgba(255,255,255,.09); font-size: 11px; } .pc-top-contact-text { overflow-wrap: anywhere; } /* MAIN HEADER */ .pc-main-header { position: sticky; top: 0; z-index: 1000; background: rgba(255,255,255,.98); border-bottom: 1px solid rgba(7,26,51,.07); box-shadow: 0 7px 24px rgba(7,26,51,.045); transition: box-shadow .25s ease; } .pc-main-header.is-scrolled { box-shadow: 0 12px 35px rgba(7,26,51,.12); } .pc-main-inner { width: min(1380px, calc(100% - 44px)); min-height: 86px; margin: auto; display: flex; align-items: center; justify-content: space-between; gap: 22px; } /* BRAND */ .pc-brand { display: inline-flex; align-items: center; gap: 11px; flex: 0 0 auto; min-width: 190px; color: var(--pc-navy); } .pc-brand-logo { display: block; width: 61px; height: 61px; flex: 0 0 61px; object-fit: contain; } .pc-brand-copy { display: flex; flex-direction: column; gap: 5px; } .pc-brand-name { color: var(--pc-navy); font-family: "Manrope", sans-serif; font-size: 17px; font-weight: 800; letter-spacing: -.55px; line-height: 1.15; } .pc-brand-tagline { color: var(--pc-blue); font-size: 8px; font-weight: 800; letter-spacing: 1.25px; line-height: 1.4; } /* DESKTOP MENU */ .pc-desktop-nav { flex: 1; display: flex; justify-content: center; min-width: 0; } .pc-desktop-menu { display: flex; align-items: center; justify-content: center; gap: 0; padding: 0; margin: 0; list-style: none; } .pc-desktop-menu > li { position: relative; } .pc-nav-link { position: relative; min-height: 86px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 12px; color: var(--pc-text); font-size: 12px; font-weight: 750; white-space: nowrap; transition: color .2s ease; } .pc-nav-link::after { content: ""; position: absolute; right: 12px; bottom: 0; left: 12px; height: 3px; border-radius: 5px 5px 0 0; background: linear-gradient(90deg, var(--pc-blue), var(--pc-cyan)); transform: scaleX(0); transition: transform .2s ease; } .pc-nav-link:hover, .pc-nav-link.is-active { color: var(--pc-blue); } .pc-nav-link:hover::after, .pc-nav-link.is-active::after { transform: scaleX(1); } .pc-nav-link .pc-arrow { color: #8092a7; font-size: 9px; transition: transform .2s ease; } .pc-desktop-menu > li:hover > .pc-nav-link .pc-arrow { transform: rotate(180deg); } /* DROPDOWNS */ .pc-submenu { position: absolute; top: calc(100% - 1px); left: 0; z-index: 20; min-width: 235px; max-width: min(760px, calc(100vw - 30px)); padding: 8px; margin: 0; list-style: none; border: 1px solid var(--pc-border); border-radius: 13px; background: #fff; box-shadow: 0 20px 55px rgba(7,26,51,.15); opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(8px); transition: opacity .2s ease, visibility .2s ease, transform .2s ease; } .pc-desktop-menu > li:hover > .pc-submenu, .pc-desktop-menu > li:focus-within > .pc-submenu { opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0); } .pc-submenu li { position: relative; } .pc-submenu-link { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; padding: 10px 12px; border-radius: 8px; color: #354860; font-size: 12px; font-weight: 650; line-height: 1.45; overflow-wrap: anywhere; transition: color .2s ease, background .2s ease; } .pc-submenu-link:hover, .pc-submenu-link.is-active { color: var(--pc-blue); background: #eff8fd; } .pc-arrow-right { flex: 0 0 auto; color: #8a9db1; font-size: 9px; } .pc-submenu .pc-submenu { top: -8px; left: calc(100% + 7px); transform: translateX(8px); } .pc-submenu li:hover > .pc-submenu, .pc-submenu li:focus-within > .pc-submenu { opacity: 1; visibility: visible; pointer-events: auto; transform: translateX(0); } .pc-submenu.pc-mega-menu { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px 8px; width: min(730px, calc(100vw - 30px)); } /* MOBILE BUTTON */ .pc-mobile-toggle { display: none; align-items: center; justify-content: center; width: 43px; height: 43px; flex: 0 0 43px; border: 1px solid var(--pc-border); border-radius: 10px; color: var(--pc-navy); background: #fff; cursor: pointer; } .pc-mobile-toggle i { font-size: 18px; } /* MOBILE OVERLAY AND PANEL */ .pc-mobile-overlay { display: none; position: fixed; z-index: 1001; inset: 0; background: rgba(5,19,37,.4); backdrop-filter: blur(3px); } .pc-mobile-overlay.is-visible { display: block; } .pc-mobile-panel { display: none; position: fixed; z-index: 1002; top: 132px; right: 14px; left: 14px; max-height: calc(100dvh - 145px); overflow-y: auto; padding: 10px 15px 16px; border: 1px solid var(--pc-border); border-radius: 16px; background: #fff; box-shadow: 0 25px 70px rgba(7,26,51,.2); overscroll-behavior: contain; } .pc-mobile-panel.is-open { display: block; } .pc-mobile-list, .pc-mobile-list ul { margin: 0; padding: 0; list-style: none; } .pc-mobile-list > li { border-bottom: 1px solid #edf1f6; } .pc-mobile-list > li:last-child { border-bottom: 0; } .pc-mobile-row { display: flex; align-items: stretch; gap: 8px; } .pc-mobile-link { display: flex; align-items: center; flex: 1; min-width: 0; min-height: 46px; gap: 9px; padding: 10px 4px; color: var(--pc-text); font-size: 13px; font-weight: 750; overflow-wrap: anywhere; } .pc-mobile-link:hover, .pc-mobile-link.is-active { color: var(--pc-blue); } .pc-mobile-item-icon { display: inline-flex; align-items: center; justify-content: center; width: 20px; flex: 0 0 20px; color: var(--pc-blue); font-size: 12px; } .pc-mobile-expand { display: inline-flex; align-items: center; justify-content: center; align-self: center; width: 38px; height: 36px; flex: 0 0 38px; border: 1px solid #e7eef5; border-radius: 8px; color: #667a91; background: #f7fafc; cursor: pointer; } .pc-mobile-expand[aria-expanded="true"] { color: #fff; background: var(--pc-blue); } .pc-mobile-expand i { font-size: 11px; transition: transform .2s ease; } .pc-mobile-expand[aria-expanded="true"] i { transform: rotate(180deg); } .pc-mobile-submenu { display: none; padding: 0 0 7px 17px !important; } .pc-mobile-submenu.is-open { display: block; } .pc-mobile-submenu .pc-mobile-link { min-height: 38px; color: #60738a; font-size: 12px; font-weight: 650; } .pc-mobile-submenu .pc-mobile-link:hover, .pc-mobile-submenu .pc-mobile-link.is-active { color: var(--pc-blue); } .pc-mobile-submenu .pc-mobile-expand { width: 32px; height: 31px; flex-basis: 32px; } /* RESPONSIVE */ @media (max-width: 1250px) { .pc-main-inner { gap: 12px; } .pc-brand { min-width: 165px; gap: 8px; } .pc-brand-logo { width: 53px; height: 53px; flex-basis: 53px; } .pc-brand-name { font-size: 15px; } .pc-nav-link { padding: 0 8px; font-size: 11px; } .pc-nav-link::after { right: 8px; left: 8px; } } @media (max-width: 1000px) { .pc-desktop-nav { display: none; } .pc-mobile-toggle { display: inline-flex; } .pc-main-inner { min-height: 76px; } .pc-brand { margin-right: auto; } } @media (max-width: 640px) { .pc-slogan-inner, .pc-main-inner { width: calc(100% - 28px); } .pc-slogan-inner { min-height: 39px; justify-content: center; } .pc-slogan { gap: 7px; font-size: 9px; letter-spacing: 0; } .pc-slogan-mark { width: 22px; height: 22px; flex-basis: 22px; font-size: 10px; } .pc-top-contacts { display: none; } .pc-main-inner { min-height: 68px; gap: 8px; } .pc-brand { gap: 7px; min-width: 0; } .pc-brand-logo { width: 44px; height: 44px; flex-basis: 44px; } .pc-brand-name { font-size: 13px; letter-spacing: -.3px; } .pc-brand-tagline { font-size: 7px; letter-spacing: .8px; } .pc-mobile-panel { top: 112px; right: 10px; left: 10px; max-height: calc(100dvh - 125px); } } @media (prefers-reduced-motion: reduce) { .pc-header-wrap *, .pc-mobile-panel *, .pc-header-wrap *::before, .pc-mobile-panel *::before { transition-duration: .01ms !important; } } </style> </head> <body> <div class="pc-header-wrap"> <!-- PREMIUM SLOGAN + CONTACT BAR --> <div class="pc-slogan-strip"> <div class="pc-slogan-inner"> <div class="pc-slogan"> <span class="pc-slogan-mark"> <i class="fa-solid fa-flask" aria-hidden="true"></i> </span> <span> Chemistry for a Better Tomorrow <span class="pc-slogan-highlight">| Quality • Trust • Innovation</span> </span> </div> <div class="pc-top-contacts"> <?php if ($sitePhone !== ''): ?> <a href="tel:<?= e(preg_replace('/[^\d+]/', '', $sitePhone)) ?>" class="pc-top-contact" > <span class="pc-top-contact-icon"> <i class="fa-solid fa-mobile-screen-button" aria-hidden="true"></i> </span> <span class="pc-top-contact-text"><?= e($sitePhone) ?></span> </a> <?php endif; ?> <?php if ($siteEmail !== ''): ?> <a href="mailto:<?= e($siteEmail) ?>" class="pc-top-contact" > <span class="pc-top-contact-icon"> <i class="fa-solid fa-envelope" aria-hidden="true"></i> </span> <span class="pc-top-contact-text"><?= e($siteEmail) ?></span> </a> <?php endif; ?> </div> </div> </div> <!-- MAIN HEADER --> <header class="pc-main-header" id="pcMainHeader"> <div class="pc-main-inner"> <!-- LOGO AND BRAND --> <a href="<?= e($homeUrl) ?>" class="pc-brand" aria-label="<?= e($siteName) ?> Home" > <?php if ($siteLogo !== ''): ?> <img src="<?= e($siteLogo) ?>" alt="<?= e($siteName) ?>" class="pc-brand-logo" > <?php endif; ?> <span class="pc-brand-copy"> <span class="pc-brand-name">OPPULENT CHEMICALLS</span> <span class="pc-brand-tagline">EXCELLENCE IN INNOVATION</span> </span> </a> <!-- DESKTOP NAVIGATION --> <nav class="pc-desktop-nav" aria-label="Main navigation"> <ul class="pc-desktop-menu"> <?php foreach ($menuItems as $item): ?> <?php if ((int) ($item['parent_id'] ?? 0) !== 0) { continue; } $itemId = (int) ($item['id'] ?? 0); $children = $menuChildren[$itemId] ?? []; $hasChildren = !empty($children); $itemTitle = (string) ( $item['title'] ?? $item['name'] ?? 'Menu' ); $itemUrl = frontend_url( $item['url'] ?? $item['link'] ?? $item['path'] ?? '#', $projectBaseUrl ); $active = is_menu_active($item, $currentPath); $isIndustry = strtolower(trim($itemTitle)) === 'industry'; ?> <li> <a href="<?= e($itemUrl) ?>" class="pc-nav-link <?= $active ? 'is-active' : '' ?>" <?= (($item['target'] ?? '') === '_blank') ? 'target="_blank" rel="noopener noreferrer"' : '' ?> > <?= menu_icon($item) ?> <span><?= e($itemTitle) ?></span> <?php if ($hasChildren): ?> <i class="fa-solid fa-chevron-down pc-arrow" aria-hidden="true"></i> <?php endif; ?> </a> <?php if ($hasChildren): ?> <ul class="pc-submenu <?= $isIndustry ? 'pc-mega-menu' : '' ?>"> <?php foreach ($children as $child): ?> <?php $childId = (int) ($child['id'] ?? 0); $grandChildren = $menuChildren[$childId] ?? []; $hasGrandChildren = !empty($grandChildren); $childTitle = (string) ( $child['title'] ?? $child['name'] ?? 'Submenu' ); $childUrl = frontend_url( $child['url'] ?? $child['link'] ?? $child['path'] ?? '#', $projectBaseUrl ); $childActive = is_menu_active($child, $currentPath); ?> <li> <a href="<?= e($childUrl) ?>" class="pc-submenu-link <?= $childActive ? 'is-active' : '' ?>" <?= (($child['target'] ?? '') === '_blank') ? 'target="_blank" rel="noopener noreferrer"' : '' ?> > <span><?= e($childTitle) ?></span> <?php if ($hasGrandChildren): ?> <i class="fa-solid fa-chevron-right pc-arrow-right" aria-hidden="true"></i> <?php endif; ?> </a> <?php if ($hasGrandChildren): ?> <ul class="pc-submenu"> <?php foreach ($grandChildren as $grandChild): ?> <?php $grandTitle = (string) ( $grandChild['title'] ?? $grandChild['name'] ?? 'Submenu' ); $grandUrl = frontend_url( $grandChild['url'] ?? $grandChild['link'] ?? $grandChild['path'] ?? '#', $projectBaseUrl ); $grandActive = is_menu_active( $grandChild, $currentPath ); ?> <li> <a href="<?= e($grandUrl) ?>" class="pc-submenu-link <?= $grandActive ? 'is-active' : '' ?>" <?= (($grandChild['target'] ?? '') === '_blank') ? 'target="_blank" rel="noopener noreferrer"' : '' ?> > <span><?= e($grandTitle) ?></span> </a> </li> <?php endforeach; ?> </ul> <?php endif; ?> </li> <?php endforeach; ?> </ul> <?php endif; ?> </li> <?php endforeach; ?> <!-- CONTACT US FALLBACK --> <?php if (!$hasContactMenu): ?> <li> <a href="<?= e($contactUrl) ?>" class="pc-nav-link <?= is_menu_active(['url' => 'contact-us.php'], $currentPath) ? 'is-active' : '' ?>" > <i class="fa-regular fa-paper-plane" aria-hidden="true"></i> <span>Contact Us</span> </a> </li> <?php endif; ?> <!-- BLOGS FALLBACK --> <?php if (!$hasBlogsMenu): ?> <li> <a href="<?= e($blogsUrl) ?>" class="pc-nav-link <?= is_menu_active(['url' => 'blogs.php'], $currentPath) ? 'is-active' : '' ?>" > <i class="fa-regular fa-newspaper" aria-hidden="true"></i> <span>Blogs</span> </a> </li> <?php endif; ?> </ul> </nav> <!-- MOBILE MENU TOGGLE ONLY --> <button type="button" class="pc-mobile-toggle" id="pcMobileToggle" aria-label="Open navigation menu" aria-expanded="false" aria-controls="pcMobilePanel" > <i class="fa-solid fa-bars" aria-hidden="true"></i> </button> </div> </header> </div> <!-- MOBILE OVERLAY --> <div class="pc-mobile-overlay" id="pcMobileOverlay"></div> <!-- MOBILE NAVIGATION --> <nav class="pc-mobile-panel" id="pcMobilePanel" aria-label="Mobile navigation" aria-hidden="true" > <ul class="pc-mobile-list"> <?php foreach ($menuItems as $item): ?> <?php if ((int) ($item['parent_id'] ?? 0) !== 0) { continue; } $itemId = (int) ($item['id'] ?? 0); $children = $menuChildren[$itemId] ?? []; $hasChildren = !empty($children); $itemTitle = (string) ( $item['title'] ?? $item['name'] ?? 'Menu' ); $itemUrl = frontend_url( $item['url'] ?? $item['link'] ?? $item['path'] ?? '#', $projectBaseUrl ); $active = is_menu_active($item, $currentPath); ?> <li> <div class="pc-mobile-row"> <a href="<?= e($itemUrl) ?>" class="pc-mobile-link <?= $active ? 'is-active' : '' ?>" <?= $hasChildren ? 'data-mobile-parent-link="true"' : '' ?> <?= (($item['target'] ?? '') === '_blank') ? 'target="_blank" rel="noopener noreferrer"' : '' ?> > <span class="pc-mobile-item-icon"><?= menu_icon($item) ?></span> <span><?= e($itemTitle) ?></span> </a> <?php if ($hasChildren): ?> <button type="button" class="pc-mobile-expand" aria-expanded="false" aria-label="Expand <?= e($itemTitle) ?> submenu" > <i class="fa-solid fa-chevron-down" aria-hidden="true"></i> </button> <?php endif; ?> </div> <?php if ($hasChildren): ?> <ul class="pc-mobile-submenu"> <?php foreach ($children as $child): ?> <?php $childId = (int) ($child['id'] ?? 0); $grandChildren = $menuChildren[$childId] ?? []; $hasGrandChildren = !empty($grandChildren); $childTitle = (string) ( $child['title'] ?? $child['name'] ?? 'Submenu' ); $childUrl = frontend_url( $child['url'] ?? $child['link'] ?? $child['path'] ?? '#', $projectBaseUrl ); $childActive = is_menu_active($child, $currentPath); ?> <li> <div class="pc-mobile-row"> <a href="<?= e($childUrl) ?>" class="pc-mobile-link <?= $childActive ? 'is-active' : '' ?>" <?= $hasGrandChildren ? 'data-mobile-parent-link="true"' : '' ?> <?= (($child['target'] ?? '') === '_blank') ? 'target="_blank" rel="noopener noreferrer"' : '' ?> > <span><?= e($childTitle) ?></span> </a> <?php if ($hasGrandChildren): ?> <button type="button" class="pc-mobile-expand" aria-expanded="false" aria-label="Expand <?= e($childTitle) ?> submenu" > <i class="fa-solid fa-chevron-down" aria-hidden="true"></i> </button> <?php endif; ?> </div> <?php if ($hasGrandChildren): ?> <ul class="pc-mobile-submenu"> <?php foreach ($grandChildren as $grandChild): ?> <?php $grandTitle = (string) ( $grandChild['title'] ?? $grandChild['name'] ?? 'Submenu' ); $grandUrl = frontend_url( $grandChild['url'] ?? $grandChild['link'] ?? $grandChild['path'] ?? '#', $projectBaseUrl ); $grandActive = is_menu_active( $grandChild, $currentPath ); ?> <li> <a href="<?= e($grandUrl) ?>" class="pc-mobile-link <?= $grandActive ? 'is-active' : '' ?>" <?= (($grandChild['target'] ?? '') === '_blank') ? 'target="_blank" rel="noopener noreferrer"' : '' ?> > <span><?= e($grandTitle) ?></span> </a> </li> <?php endforeach; ?> </ul> <?php endif; ?> </li> <?php endforeach; ?> </ul> <?php endif; ?> </li> <?php endforeach; ?> <!-- CONTACT US MOBILE FALLBACK --> <?php if (!$hasContactMenu): ?> <li> <div class="pc-mobile-row"> <a href="<?= e($contactUrl) ?>" class="pc-mobile-link <?= is_menu_active(['url' => 'contact-us.php'], $currentPath) ? 'is-active' : '' ?>" > <span class="pc-mobile-item-icon"> <i class="fa-regular fa-paper-plane" aria-hidden="true"></i> </span> <span>Contact Us</span> </a> </div> </li> <?php endif; ?> <!-- BLOGS MOBILE FALLBACK --> <?php if (!$hasBlogsMenu): ?> <li> <div class="pc-mobile-row"> <a href="<?= e($blogsUrl) ?>" class="pc-mobile-link <?= is_menu_active(['url' => 'blogs.php'], $currentPath) ? 'is-active' : '' ?>" > <span class="pc-mobile-item-icon"> <i class="fa-regular fa-newspaper" aria-hidden="true"></i> </span> <span>Blogs</span> </a> </div> </li> <?php endif; ?> </ul> </nav> <script> (function () { 'use strict'; const header = document.getElementById('pcMainHeader'); const toggle = document.getElementById('pcMobileToggle'); const panel = document.getElementById('pcMobilePanel'); const overlay = document.getElementById('pcMobileOverlay'); /* Sticky header shadow */ function updateHeader() { if (header) { header.classList.toggle('is-scrolled', window.scrollY > 8); } } updateHeader(); window.addEventListener('scroll', updateHeader, { passive: true }); /* Close mobile navigation */ function closeMobileMenu() { if (!toggle || !panel || !overlay) { return; } panel.classList.remove('is-open'); overlay.classList.remove('is-visible'); panel.setAttribute('aria-hidden', 'true'); toggle.setAttribute('aria-expanded', 'false'); toggle.setAttribute('aria-label', 'Open navigation menu'); const icon = toggle.querySelector('i'); if (icon) { icon.classList.remove('fa-xmark'); icon.classList.add('fa-bars'); } } /* Toggle mobile navigation */ if (toggle && panel && overlay) { toggle.addEventListener('click', function () { const isOpen = !panel.classList.contains('is-open'); panel.classList.toggle('is-open', isOpen); overlay.classList.toggle('is-visible', isOpen); panel.setAttribute('aria-hidden', isOpen ? 'false' : 'true'); toggle.setAttribute('aria-expanded', isOpen ? 'true' : 'false'); toggle.setAttribute( 'aria-label', isOpen ? 'Close navigation menu' : 'Open navigation menu' ); const icon = toggle.querySelector('i'); if (icon) { icon.classList.toggle('fa-bars', !isOpen); icon.classList.toggle('fa-xmark', isOpen); } }); overlay.addEventListener('click', closeMobileMenu); document.addEventListener('keydown', function (event) { if (event.key === 'Escape') { closeMobileMenu(); } }); window.addEventListener('resize', function () { if (window.innerWidth > 1000) { closeMobileMenu(); } }); /* Close panel when a real page link is selected */ panel.querySelectorAll('a').forEach(function (link) { link.addEventListener('click', function () { if (link.getAttribute('href') !== '#') { closeMobileMenu(); } }); }); } /* Nested mobile accordion */ document.querySelectorAll( '#pcMobilePanel .pc-mobile-expand' ).forEach(function (button) { button.addEventListener('click', function () { const row = button.closest('.pc-mobile-row'); if (!row) { return; } const submenu = row.nextElementSibling; if ( !submenu || !submenu.classList.contains('pc-mobile-submenu') ) { return; } const isOpen = !submenu.classList.contains('is-open'); submenu.classList.toggle('is-open', isOpen); button.setAttribute('aria-expanded', isOpen ? 'true' : 'false'); /* Close other submenus at this level */ const parentList = row.parentElement.parentElement; if (!parentList) { return; } Array.from(parentList.children).forEach(function (sibling) { if (sibling === row.parentElement) { return; } const siblingRow = sibling.querySelector( ':scope > .pc-mobile-row' ); if (!siblingRow) { return; } const siblingButton = siblingRow.querySelector( ':scope > .pc-mobile-expand' ); const siblingSubmenu = siblingRow.nextElementSibling; if ( siblingButton && siblingSubmenu && siblingSubmenu.classList.contains('pc-mobile-submenu') ) { siblingSubmenu.classList.remove('is-open'); siblingButton.setAttribute('aria-expanded', 'false'); } }); }); }); /* Parent links with # open their submenu */ document.querySelectorAll( '#pcMobilePanel [data-mobile-parent-link="true"]' ).forEach(function (link) { link.addEventListener('click', function (event) { if (link.getAttribute('href') !== '#') { return; } event.preventDefault(); const row = link.closest('.pc-mobile-row'); const button = row ? row.querySelector(':scope > .pc-mobile-expand') : null; if (button) { button.click(); } }); }); })(); </script>
Save
Cancel