Full tutorial: http://hofmannsven.com/2013/laboratory/wordpress-admin-ui/
Last active
April 3, 2018 23:51
-
-
Save hofmannsven/7592304 to your computer and use it in GitHub Desktop.
Using a dynamic admin body class within WordPress to distinguish between light or dark admin interface.
This file contains 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 | |
add_filter( 'admin_body_class', 'admin_interface_version_body_class' ); | |
function admin_interface_version_body_class( $classes ) { | |
// check wp_version | |
if ( version_compare( $GLOBALS['wp_version'], '3.8-alpha', '>' ) ) { | |
$classes .= 'dark-admin-ui'; // new admin interface | |
} else { | |
$classes .= 'light-admin-ui'; // old admin interface | |
} | |
return $classes; | |
} | |
?> |
This file contains 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 | |
add_filter( 'admin_body_class', 'admin_interface_version_body_class' ); | |
function admin_interface_version_body_class( $classes ) { | |
// check wp_version | |
if ( version_compare( $GLOBALS['wp_version'], '3.8-alpha', '>' ) ) { | |
$classes .= 'dark-admin-ui'; // new admin interface | |
} else { | |
// check admin_color | |
if ( get_user_option( 'admin_color' ) === 'mp6' ) { | |
$classes .= 'dark-admin-ui'; // updated old admin interface | |
} else { | |
$classes .= 'light-admin-ui'; // old admin interface | |
} | |
} | |
return $classes; | |
} | |
?> |
This file contains 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 | |
add_filter( 'admin_body_class', 'admin_interface_version_body_class' ); | |
function admin_interface_version_body_class( $classes ) { | |
// check wp_version | |
if ( version_compare( $GLOBALS['wp_version'], '3.8-alpha', '>' ) ) { | |
// check admin_color | |
if ( get_user_option( 'admin_color' ) === 'light' ) { | |
$classes .= 'light-admin-ui'; // custom new admin interface | |
} else { | |
$classes .= 'dark-admin-ui'; // new admin interface | |
} | |
} else { | |
$classes .= 'light-admin-ui'; // old admin interface | |
} | |
return $classes; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment