Guest User

Untitled

a guest
Dec 16th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Set the default admin color scheme for WordPress user.
  5. */
  6. add_filter('get_user_option_admin_color', 'set_default_admin_color');
  7. function set_default_admin_color($result)
  8. {
  9.  
  10. // set new default admin color scheme
  11. $result = 'midnight';
  12.  
  13. // return the new default color
  14. return $result;
  15.  
  16. }
  17.  
  18. /**
  19. * Get the current admin color scheme from WordPress user.
  20. */
  21. add_filter('get_user_option_admin_color', 'get_current_admin_color');
  22. function get_current_admin_color($result)
  23. {
  24.  
  25. global $_wp_admin_css_colors;
  26.  
  27. // get current admin color scheme name
  28. $current_color_scheme = $result;
  29.  
  30. // get all available colors from scheme name
  31. $colors = $_wp_admin_css_colors[$current_color_scheme];
  32.  
  33. // now you can use this colors or store it
  34. // var_dump($colors);
  35.  
  36. // important: we should return the default color scheme
  37. return $result;
  38.  
  39. }
  40.  
  41. /**
  42. * Get all available admin colors schemes from WordPress user.
  43. */
  44. add_filter('get_user_option_admin_color', 'get_all_admin_colors');
  45. function get_all_admin_colors($result)
  46. {
  47.  
  48. global $_wp_admin_css_colors;
  49.  
  50. // get all available color schemes
  51. $colors = $_wp_admin_css_colors;
  52.  
  53. // now you can use this color schemes or store it
  54. // var_dump($colors);
  55.  
  56. // important: we should return the default color scheme
  57. return $result;
  58.  
  59. }
Add Comment
Please, Sign In to add comment