Guest User

Untitled

a guest
Dec 13th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. <?php register_admin_color_schemes(); ?>
  2.  
  3. $current_color = get_user_option( 'admin_color' );
  4.  
  5. <?php
  6. $admin_colors;
  7. add_action('admin_head', function(){global $_wp_admin_css_colors; $admin_colors = $_wp_admin_css_colors;});
  8. ?>
  9.  
  10. $admin_colors[get_user_option('admin_color')]['colors']; // array(0 => #222, 1 => #333, 2 => #0074a2, 3 => #2ea2cc)
  11.  
  12. $admin_colors = Array
  13. (
  14. [fresh] => stdClass Object
  15. (
  16. [name] => Default
  17. [url] => https://example.com/wordpress/wp-admin/css/colors.min.css
  18. [colors] => Array
  19. (
  20. [0] => #222
  21. [1] => #333
  22. [2] => #0074a2
  23. [3] => #2ea2cc
  24. )
  25. [icon_colors] => Array
  26. (
  27. [base] => #999
  28. [focus] => #2ea2cc
  29. [current] => #fff
  30. )
  31. )
  32. )
  33.  
  34. get_user_option( 'admin_color', get_current_user_id() );
  35.  
  36. <?php
  37.  
  38. /**
  39. * Set the default admin color scheme for WordPress user.
  40. */
  41. add_filter('get_user_option_admin_color', 'set_default_admin_color');
  42. function set_default_admin_color()
  43. {
  44.  
  45. // set new default admin color scheme
  46. $result = 'midnight';
  47.  
  48. // return the new default color
  49. return $result;
  50.  
  51. }
  52.  
  53. /**
  54. * Get the current admin color scheme from WordPress user.
  55. */
  56. add_filter('get_user_option_admin_color', 'get_current_admin_color');
  57. function get_current_admin_color()
  58. {
  59.  
  60. global $_wp_admin_css_colors;
  61.  
  62. // get current admin color scheme name
  63. $current_color_scheme = $result;
  64.  
  65. // get all available colors from scheme name
  66. $colors = $_wp_admin_css_colors[$current_color_scheme];
  67.  
  68. // now you can use this colors or store it
  69. // var_dump($colors);
  70.  
  71. // important: we should return the default color scheme
  72. return $result;
  73.  
  74. }
  75.  
  76. /**
  77. * Get all available admin colors schemes from WordPress user.
  78. */
  79. add_filter('get_user_option_admin_color', 'get_all_admin_colors');
  80. function get_all_admin_colors()
  81. {
  82.  
  83. global $_wp_admin_css_colors;
  84.  
  85. // get all available color schemes
  86. $colors = $_wp_admin_css_colors;
  87.  
  88. // now you can use this color schemes or store it
  89. // var_dump($colors);
  90.  
  91. // important: we should return the default color scheme
  92. return $result;
  93.  
  94. }
Add Comment
Please, Sign In to add comment