Skip to content

Instantly share code, notes, and snippets.

@mintplugins
Last active April 30, 2019 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mintplugins/e5dcb6883094b4bda3d2e4c20494c579 to your computer and use it in GitHub Desktop.
Save mintplugins/e5dcb6883094b4bda3d2e4c20494c579 to your computer and use it in GitHub Desktop.
If javascript is disabled, hide everything on the page and show a message.
function my_prefix_hide_everything_if_javascript_disabled() {
?>
<noscript id="javascript_test">
<style type="text/css">
body > * {display:none!important;}
#javascript_test{
display:block!important;
}
</style>
<div class="noscriptmsg">
<?php echo __( 'You don\'t have javascript enabled. Check your browser extensions to see if any might be disabling it.', 'text_domain_here' ); ?>
</div>
</noscript>
<?php
}
add_action( 'wp_footer', 'my_prefix_hide_everything_if_javascript_disabled' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment