Welcome to WordPress. This is your first post. Edit or delete it, then start writing!
// This script is designed to forcefully keep the site header visible
// and fixed against aggressive theme JavaScript that tries to hide it.
// --- FINAL FIX: Uses !important overrides and targets transform property ---
document.addEventListener('DOMContentLoaded', function() {
// 1. Define all possible elements that the theme might be hiding.
const targetSelectors = [
// Primary header elements (usually fixed to top)
'.site-header',
'#masthead',
'header#masthead',
// Secondary/Internal navigation wrappers (often collapsed)
'#main-navigation',
'.main-navigation-wrapper',
'.menu-container',
'.header-main' // Common element in themes like Inspiro
];
// Find all potential elements on the page
const targets = [];
targetSelectors.forEach(selector => {
const found = document.querySelector(selector);
if (found) {
// Only add unique elements to the array
if (!targets.some(t => t === found)) {
targets.push(found);
}
}
});
if (targets.length === 0) {
console.warn('JS Fix: Could not find any potential header/navigation elements to target.');
return;
}
// 2. Define the aggressive style function to force visibility.
function forceHeaderVisibility() {
targets.forEach((target, index) => {
// === FORCE VISIBILITY USING !IMPORTANT TO BEAT ALL THEME CSS ===
// Standard visibility overrides
target.style.setProperty('display', 'block', 'important');
target.style.setProperty('opacity', '1', 'important');
target.style.setProperty('visibility', 'visible', 'important');
// Critical Overrides: Prevent the element from collapsing its height
target.style.setProperty('height', 'auto', 'important');
target.style.setProperty('max-height', 'none', 'important');
// NEW: Override transform, which is used to slide the header off-screen
target.style.setProperty('transform', 'none', 'important');
// Re-apply critical positioning for the main header element
if (index === 0) { // Assume the first target found is the main header
target.style.setProperty('position', 'fixed', 'important');
target.style.setProperty('top', '0', 'important');
target.style.setProperty('z-index', '99999', 'important');
}
});
}
// 3. Set up the "Fighter" interval to run every 50 milliseconds.
setInterval(forceHeaderVisibility, 50);
console.info(`Header visibility fix (with !important) activated on ${targets.length} elements.`);
});