105 lines
4.3 KiB
PHP
105 lines
4.3 KiB
PHP
<!DOCTYPE html>
|
|
<html <?php language_attributes(); ?>>
|
|
<head>
|
|
<meta charset="<?php bloginfo( 'charset' ); ?>">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<?php wp_head(); ?>
|
|
</head>
|
|
<body <?php body_class(); ?>>
|
|
|
|
<header class="site-header">
|
|
<div class="container header-container">
|
|
<div class="site-branding">
|
|
<a href="<?php echo esc_url( home_url( '/' ) ); ?>" class="logo-link">
|
|
<?php
|
|
$header_logo = get_option('edukarsa_header_logo');
|
|
if ( ! empty( $header_logo ) ) :
|
|
?>
|
|
<img src="<?php echo esc_url( $header_logo ); ?>" alt="<?php bloginfo( 'name' ); ?>" style="max-height: 52px; object-fit: contain;">
|
|
<?php else : ?>
|
|
<h1 class="site-title"><?php bloginfo( 'name' ); ?></h1>
|
|
<?php endif; ?>
|
|
</a>
|
|
</div>
|
|
|
|
<!-- Area Navigasi & Bilingual -->
|
|
<div class="header-nav-wrap">
|
|
<nav class="main-navigation" id="site-navigation">
|
|
<?php
|
|
wp_nav_menu( array(
|
|
'theme_location' => 'menu-utama',
|
|
'menu_id' => 'primary-menu',
|
|
'fallback_cb' => false,
|
|
'container' => false,
|
|
'menu_class' => 'nav-menu-custom'
|
|
) );
|
|
?>
|
|
</nav>
|
|
|
|
<!-- BILINGUAL SWITCHER (ID | EN) -->
|
|
<?php if ( get_option( 'edukarsa_tampil_bilingual', 1 ) == 1 ) : ?>
|
|
<div class="edukarsa-lang-switcher" id="lang-switcher">
|
|
<button type="button" class="lang-btn active" data-lang="id" title="Bahasa Indonesia">ID</button>
|
|
<span class="lang-divider">|</span>
|
|
<button type="button" class="lang-btn" data-lang="en" title="English">EN</button>
|
|
</div>
|
|
<div id="google_translate_element" style="display:none;"></div>
|
|
<?php endif; ?>
|
|
|
|
<!-- Tombol Hamburger Mobile -->
|
|
<button class="menu-toggle" id="mobile-menu-toggle" aria-label="Buka Menu Navigasi">
|
|
<span></span>
|
|
<span></span>
|
|
<span></span>
|
|
</button>
|
|
</div>
|
|
|
|
</div>
|
|
</header>
|
|
|
|
<?php if ( get_option( 'edukarsa_tampil_bilingual', 1 ) == 1 ) : ?>
|
|
<!-- SKRIP NATIVE TRANSLATE CONTROLLER -->
|
|
<script type="text/javascript">
|
|
function googleTranslateElementInit() {
|
|
new google.translate.TranslateElement({
|
|
pageLanguage: 'id',
|
|
includedLanguages: 'en,id',
|
|
autoDisplay: false
|
|
}, 'google_translate_element');
|
|
}
|
|
|
|
function changeLanguage(lang) {
|
|
var host = window.location.hostname;
|
|
var cookieVal = '/id/' + lang;
|
|
if (lang === 'id') {
|
|
document.cookie = "googtrans=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; domain=" + host;
|
|
document.cookie = "googtrans=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
|
|
} else {
|
|
document.cookie = "googtrans=" + cookieVal + "; path=/; domain=" + host;
|
|
document.cookie = "googtrans=" + cookieVal + "; path=/;";
|
|
}
|
|
window.location.reload();
|
|
}
|
|
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
// Cek status bahasa aktif dari cookie
|
|
var match = document.cookie.match(/googtrans=\/id\/([a-z]{2})/i);
|
|
var activeLang = match ? match[1].toLowerCase() : 'id';
|
|
|
|
var buttons = document.querySelectorAll('.lang-btn');
|
|
buttons.forEach(function(btn) {
|
|
if (btn.getAttribute('data-lang') === activeLang) {
|
|
btn.classList.add('active');
|
|
} else {
|
|
btn.classList.remove('active');
|
|
}
|
|
btn.addEventListener('click', function() {
|
|
var selected = this.getAttribute('data-lang');
|
|
changeLanguage(selected);
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
|
|
<?php endif; ?>
|