Created
October 30, 2014 15:00
Know When You're On Localhost - WordPress
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 | |
function opubco_localhost() { | |
// Do check for localhost IP (remove this if you want to ALWAYS display it) | |
if ( '127.0.0.1' != $_SERVER['REMOTE_ADDR'] && '::1' != $_SERVER['REMOTE_ADDR'] ) { | |
return; | |
} | |
if ( defined( 'WP_DEBUG' ) && WP_DEBUG == true ) { | |
$debug = 'WP_DEBUG=ON'; | |
} else { | |
$debug = 'WP_DEBUG=OFF'; | |
} | |
echo ' | |
<div style=" | |
position: fixed; | |
right: 10px; | |
bottom: 10px; | |
width: auto; | |
padding: 0 8px; | |
height: 22px; | |
background: #ff0000; | |
border-radius: 5px; | |
box-shadow: 0 2px 5px 2px rgba(0,0,0,0.3); | |
z-index: 99999999999999; | |
font-family: sans-serif; | |
font-size: 13px; | |
line-height: 22px; | |
color: #fff; | |
font-weight: bold; | |
text-align: center; | |
text-shadow: 1px 1px 1px rgba(0,0,0,0.3); | |
">' . php_uname( 'n' ) . ' ' . $debug . '</div>'; | |
} | |
add_action( 'wp_footer', 'opubco_localhost' ); | |
add_action( 'admin_footer', 'opubco_localhost' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment