Skip to content

Instantly share code, notes, and snippets.

@ronalfy
Created October 30, 2014 15:00
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 ronalfy/2159dac987da8c51719a to your computer and use it in GitHub Desktop.
Save ronalfy/2159dac987da8c51719a to your computer and use it in GitHub Desktop.
Know When You're On Localhost - WordPress
<?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