Created
November 16, 2016 22:00
-
-
Save Veraxus/556de5f624ab154882d0f033ea881d91 to your computer and use it in GitHub Desktop.
A WordPress plugin that shows a small green label during local development.
This file contains hidden or 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 | |
/* | |
Plugin Name: Local Flagging | |
Plugin URI: | |
Description: Shows a flag on the page when the site is detected to be local. | |
Version: 1.5 | |
Author: Matt van Andel | |
Author URI: | |
License: GPL2 | |
Text Domain: | |
Domain Path: | |
Place in mu-plugins on your local environment and ensure that you have the following added to your local vhost... | |
Header Set LOCAL-ENV true | |
SetEnv LOCAL-ENV true | |
*/ | |
if ( isset( $_SERVER['LOCAL-ENV'] ) ) { | |
function maybe_output_local_flag() { | |
echo '<div style="background:green;color:white;font-weight:bold;position:fixed;bottom:0;right:0;padding:5px 8px;z-index:999;font-family:sans-serif;">LOCAL</div>'; | |
} | |
add_action( 'wp_footer', 'maybe_output_local_flag' ); | |
add_action( 'admin_footer', 'maybe_output_local_flag' ); | |
add_action( 'login_footer', 'maybe_output_local_flag' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment