WordPress alert when you are on the staging site.

Recently I accidentaly overwrote my Production site when I thought i was on the staging site so after a bit of googling i came up with this solution. If you are on WordPress you can just paste this at the end of your functions.php for your theme. This could also probably be turned into a very simple plugin.

/*Alert on Staging Site*/
$host = $_SERVER['HTTP_HOST'];
if ($host === 'XXXXXX.staging.wpengine.com') {
    function staging_admin_error_notice() {
        $class = "error";
        $message = "You are on the staging site.";
            echo"<div class=\"$class\"> <p>$message</p></div>";
    add_action( 'admin_notices', 'staging_admin_error_notice' );
/*End Alert on Staging Site*/