Add an Emergency Exit Site Button
This snippet adds a floating Emergency Exit button to your website, providing a quick exit for visitors by instantly redirecting them to a safe external page such as weather.com. The button is fixed to the side of the screen for easy access, making it ideal for sites that handle sensitive content or environments where users may need to leave quickly. When activated, it fades out the page and clears localStorage and sessionStorage, helping protect user data during the exit.
The snippet also includes JavaScript functionality to trigger the quick exit when users press the Escape key, giving visitors a fast, keyboard-accessible way to leave the site. This makes it particularly useful for private forums, work dashboards, or any website where site users may require a rapid, discreet way to navigate away while maintaining privacy and security.
/**
* Emergency Exit.
*/
add_action( 'wp_footer', function() {
echo '<button class="theme-button wpex-hidden wpex-md-block emergency-exit-button wpex-fixed wpex-right-0 wpex-top-50 wpex-z-overlay wpex-translate-y-50 wpex-origin-bottom-right wpex-rounded-0-b wpex-rounded-md-t wpex-px-20 wpex-py-10 wpex-font-bold" style="transform: rotate(270deg);">quick exit</button>';
echo '<script>const exitAction=()=>{document.body.style.opacity="0";localStorage.clear();sessionStorage.clear();setTimeout(()=>{window.location.replace("https://weather.com");},300);};document.querySelector(".emergency-exit-button").addEventListener("click",exitAction);document.addEventListener("keydown",e=>{if(e.key==="Escape"&&!document.documentElement.classList.contains("html-noscroll"))exitAction();});</script>';
} );We recommend Code Snippets (100% Free) or WPCode (sponsored)