Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php register_admin_color_schemes(); ?>
- $current_color = get_user_option( 'admin_color' );
- <?php
- $admin_colors;
- add_action('admin_head', function(){global $_wp_admin_css_colors; $admin_colors = $_wp_admin_css_colors;});
- ?>
- $admin_colors[get_user_option('admin_color')]['colors']; // array(0 => #222, 1 => #333, 2 => #0074a2, 3 => #2ea2cc)
- $admin_colors = Array
- (
- [fresh] => stdClass Object
- (
- [name] => Default
- [url] => https://example.com/wordpress/wp-admin/css/colors.min.css
- [colors] => Array
- (
- [0] => #222
- [1] => #333
- [2] => #0074a2
- [3] => #2ea2cc
- )
- [icon_colors] => Array
- (
- [base] => #999
- [focus] => #2ea2cc
- [current] => #fff
- )
- )
- )
- get_user_option( 'admin_color', get_current_user_id() );
- <?php
- /**
- * Set the default admin color scheme for WordPress user.
- */
- add_filter('get_user_option_admin_color', 'set_default_admin_color');
- function set_default_admin_color()
- {
- // set new default admin color scheme
- $result = 'midnight';
- // return the new default color
- return $result;
- }
- /**
- * Get the current admin color scheme from WordPress user.
- */
- add_filter('get_user_option_admin_color', 'get_current_admin_color');
- function get_current_admin_color()
- {
- global $_wp_admin_css_colors;
- // get current admin color scheme name
- $current_color_scheme = $result;
- // get all available colors from scheme name
- $colors = $_wp_admin_css_colors[$current_color_scheme];
- // now you can use this colors or store it
- // var_dump($colors);
- // important: we should return the default color scheme
- return $result;
- }
- /**
- * Get all available admin colors schemes from WordPress user.
- */
- add_filter('get_user_option_admin_color', 'get_all_admin_colors');
- function get_all_admin_colors()
- {
- global $_wp_admin_css_colors;
- // get all available color schemes
- $colors = $_wp_admin_css_colors;
- // now you can use this color schemes or store it
- // var_dump($colors);
- // important: we should return the default color scheme
- return $result;
- }
Add Comment
Please, Sign In to add comment