Files
LiveCartaWP/htdocs/wp-content/themes/lawcarta/header.php

92 lines
3.4 KiB
PHP

<?php
require_once 'inc/walker-nav-menu.php';
$urlParts = parse_url(home_url());
$scheme = isset($urlParts['scheme']) ? $urlParts['scheme'] . '://' : '';
$host = isset($urlParts['host']) ? $urlParts['host'] : '';
if (defined('LAWCARTA_SUBDOMAIN')) {
$hostParts = explode('.', $host);
if (count($hostParts) === 3) {
array_shift($hostParts);
}
if (!empty(LAWCARTA_SUBDOMAIN)) {
array_unshift($hostParts, LAWCARTA_SUBDOMAIN);
}
$host = implode('.', $hostParts);
}
$port = isset($urlParts['port']) ? $urlParts['port'] : '';
if (defined('LAWCARTA_PORT')) {
$port = LAWCARTA_PORT;
}
if (!empty($port)) {
$port = ':' . $port;
}
$lawCartaUrl = "$scheme$host$port";
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo('charset'); ?>">
<link rel="apple-touch-icon" sizes="60x60" href="<?= get_theme_file_uri('/assets/img/favicon/apple-touch-icon.png'); ?>">
<link rel="icon" type="image/png" sizes="32x32" href="<?= get_theme_file_uri('/assets/img/favicon/favicon-32x32.png'); ?>">
<link rel="icon" type="image/png" sizes="16x16" href="<?= get_theme_file_uri('/assets/img/favicon/favicon-16x16.png'); ?>">
<link rel="manifest" href="<?= get_theme_file_uri('/assets/img/favicon/site.webmanifest'); ?>">
<link rel="mask-icon" href="<?= get_theme_file_uri('/assets/img/favicon/safari-pinned-tab.svg'); ?>" color="#5bbad5">
<link rel="shortcut icon" href="<?= get_theme_file_uri('/assets/img/favicon/favicon.ico'); ?>" type="image/x-icon">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-config" content="<?= get_theme_file_uri('/assets/img/favicon/browserconfig.xml'); ?>">
<meta name="theme-color" content="#ffffff">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<div class="wrapper">
<header>
<div id="header-menu" class="cont">
<a href="<?= site_url(); ?>" class="main-logo"><img src="<?= get_theme_file_uri('/assets/img/logo.png'); ?>"></a>
<?php
if (has_nav_menu('top')) {
wp_nav_menu([
'menu' => 'top',
'menu_class' => 'navTab nav',
'container' => 'div',
'container_class' => 'header-menu',
'depth' => 1,
'walker' => new LawCarta_Walker_Nav_Menu(),
'icon_wrap' => 'i',
'theme_location' => 'top',
]);
}
?>
</div>
<iframe src="<?= $lawCartaUrl ?>/menu" style="display: none;"></iframe>
<script type="application/javascript">
var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
var eventer = window[eventMethod];
var messageEvent = eventMethod === "attachEvent" ? "onmessage" : "message";
eventer(messageEvent, function (ev) {
if (ev.origin.indexOf('<?= $lawCartaUrl ?>') !== -1) {
document.getElementById('header-menu').insertAdjacentHTML('beforeend', ev.data);
if ($('#is-guest').text() == 'true') {
$('.guest-data').show();
} else {
$('.home-label').text('Dashboard').attr('href', '<?= $lawCartaUrl?>/dashboard');
}
}
});
</script>
</header>