Created
March 27, 2018 09:33
-
-
Save keithdevon/1fbedcfe48fc0de03c88c5e191822eea to your computer and use it in GitHub Desktop.
Function to append a grid overlay div to the body depending on the environment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This function appends a grid overlay div to the body depending on the environment. | |
* | |
*/ | |
function tgf_add_grid_overlay_debugging_helper() { | |
if ( WP_LOCAL ) { | |
// echo the script | |
echo '<script> | |
function toggleVisualGrid() { | |
var element = document.getElementById("grid-overlay-js"); | |
element.classList.toggle("is--visible"); | |
} | |
</script>'; | |
// echo the div | |
echo '<div id="grid-overlay-js" class="grid-overlay"><div class="grid-overlay__inner"></div></div><button onclick="toggleVisualGrid()" class="button grid-overlay-toggle">Show grid</button>'; | |
} | |
} | |
add_action( 'wp_footer', 'tgf_add_grid_overlay_debugging_helper' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment