Last active
August 11, 2020 07:56
-
-
Save odil-io/ea3e5814c46281e3076be7228d2f4461 to your computer and use it in GitHub Desktop.
WordPress: display a notice while on localhost
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 | |
function localhost_admin_notice(){ | |
$whitelist = array('127.0.0.1', "::1"); | |
if( in_array( $_SERVER['REMOTE_ADDR'], $whitelist )): | |
echo '<div class="notice notice-warning"><p>Let op: dit is een local site: '.$_SERVER['REMOTE_ADDR'].'</p></div>'; | |
endif; | |
} | |
add_action('admin_notices', 'localhost_admin_notice'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment