Skip to content

Instantly share code, notes, and snippets.

@Langmans
Created May 16, 2019 06:58
Show Gist options
  • Save Langmans/0e5958923b6fd149b01200a314f02d3e to your computer and use it in GitHub Desktop.
Save Langmans/0e5958923b6fd149b01200a314f02d3e to your computer and use it in GitHub Desktop.
{% if js is not defined or not js %}
<script>
document.cookie = "js=1";
location.reload(true); //Refreshes the page
</script>
{% endif %}
{% if js is not defined or js %}
<noscript>
<meta http-equiv="Set-Cookie" content="js=0">
<meta http-equiv="Refresh" content="0">
</noscript>
{% endif %}
<?php
add_action( 'timber/context', function ( array $context ) {
if ( isset( $_COOKIE, $_COOKIE['js'] ) ) {
$context['js'] = (bool) $_COOKIE['js'];
}
return $context;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment