(function() {
const body = document.body;
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)');
// ๐งน Hapus dulu class default dari tema biar nggak ke-lock di dark
body.classList.remove('dark-theme', 'light-theme');
function applyTheme(mode) {
if (mode === 'dark') {
body.classList.add('dark-theme');
body.classList.remove('light-theme');
} else {
body.classList.add('light-theme');
body.classList.remove('dark-theme');
}
updateLogos(mode);
}
function updateLogos(mode) {
document.querySelectorAll('.logo-light, .logo-dark').forEach(img => {
img.style.display = 'none';
});
if (mode === 'dark') {
document.querySelectorAll('.logo-dark').forEach(img => img.style.display = 'inline');
} else {
document.querySelectorAll('.logo-light').forEach(img => img.style.display = 'inline');
}
}
// ๐ฅ Terapkan tema default sesuai preferensi OS/device
applyTheme(prefersDark.matches ? 'dark' : 'light');
// ๐ Dengar perubahan realtime dari sistem (tanpa reload)
prefersDark.addEventListener('change', e => {
applyTheme(e.matches ? 'dark' : 'light');
});
// ๐ฒ๏ธ Tombol toggle manual (tanpa localStorage)
const toggleBtn = document.querySelector('#theme-toggle');
if (toggleBtn) {
toggleBtn.addEventListener('click', () => {
const isDark = body.classList.contains('dark-theme');
applyTheme(isDark ? 'light' : 'dark');
});
}
})();
Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the fast-indexing-api domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/metp5898/public_html/fokus.co.id/wp-includes/functions.php on line 6121
Warning: Cannot modify header information - headers already sent by (output started at /home/metp5898/public_html/fokus.co.id/wp-content/plugins/dark-mode-logo-switcher/dark-mode-logo-switcher.php:1) in /home/metp5898/public_html/fokus.co.id/wp-includes/feed-rss2-comments.php on line 8
Komentar di: Mengenal Belalang Kembara dan Familinya – Dunia Hewan
https://fokus.co.id/mengenal-belalang-kembara-dan-familinya-dunia-hewan
Media Berita Terbaru Terpopuler Hari IniSun, 26 Jan 2025 17:16:21 +0000
hourly
1 https://wordpress.org/?v=6.8.3