Skip to content

Instantly share code, notes, and snippets.

@alanef
Last active September 12, 2019 19:31
Show Gist options
  • Select an option

  • Save alanef/43810ee51b7b79d9389a9b3cc5cafaff to your computer and use it in GitHub Desktop.

Select an option

Save alanef/43810ee51b7b79d9389a9b3cc5cafaff to your computer and use it in GitHub Desktop.
Sets Admin Colour in Staging and Dev sites

Download the zip file and install as a plugin

Sets the admin colour of staging and local siyes to red ( sunrise )

<?php
/**
* Plugin Name: Set Admin Colour on Staging and Dev
* Plugin URI: http://fullworks.net/
* Description: Set Admin Colour on staging and dev sites: locahost staginxyx.mydomain mydomain.local mydomain.dev
* Version: 1.0
* Author: Fullworks
* Author URI: http://fullworks.net/
* License: GPL-3.0+
* License URI: http://www.gnu.org/licenses/gpl-3.0.txt
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
add_filter( "get_user_option_admin_color", function ( $result, $option, $user ) {
if ( preg_match( '#(localhost|staging.*\.|\.local|\.dev)#', site_url() ) ) {
return 'sunrise';
}
return $result;
}, 9999, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment