Skip to content

Instantly share code, notes, and snippets.

@odil-io
Last active August 11, 2020 07:56
Show Gist options
  • Save odil-io/ea3e5814c46281e3076be7228d2f4461 to your computer and use it in GitHub Desktop.
Save odil-io/ea3e5814c46281e3076be7228d2f4461 to your computer and use it in GitHub Desktop.
WordPress: display a notice while on localhost
<?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