admin_color_scheme_picker

Display the default admin color scheme picker (Used in user-edit.php).

Description

admin_color_scheme_picker( (int) $user_id ); 

Parameters (1)

0. $user_id (int)
The user id.

Usage

  1. if ( !function_exists( 'admin_color_scheme_picker' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/misc.php'; 
  3.  
  4. // The user id. 
  5. $user_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = admin_color_scheme_picker($user_id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/misc.php  
  1. function admin_color_scheme_picker( $user_id ) { 
  2. global $_wp_admin_css_colors; 
  3.  
  4. ksort( $_wp_admin_css_colors ); 
  5.  
  6. if ( isset( $_wp_admin_css_colors['fresh'] ) ) { 
  7. // Set Default ('fresh') and Light should go first. 
  8. $_wp_admin_css_colors = array_filter( array_merge( array( 'fresh' => '', 'light' => '' ), $_wp_admin_css_colors ) ); 
  9.  
  10. $current_color = get_user_option( 'admin_color', $user_id ); 
  11.  
  12. if ( empty( $current_color ) || ! isset( $_wp_admin_css_colors[ $current_color ] ) ) { 
  13. $current_color = 'fresh'; 
  14.  
  15. ?> 
  16. <fieldset id="color-picker" class="scheme-list"> 
  17. <legend class="screen-reader-text"><span><?php _e( 'Admin Color Scheme' ); ?></span></legend> 
  18. <?php 
  19. wp_nonce_field( 'save-color-scheme', 'color-nonce', false ); 
  20. foreach ( $_wp_admin_css_colors as $color => $color_info ) : 
  21.  
  22. ?> 
  23. <div class="color-option <?php echo ( $color == $current_color ) ? 'selected' : ''; ?>"> 
  24. <input name="admin_color" id="admin_color_<?php echo esc_attr( $color ); ?>" type="radio" value="<?php echo esc_attr( $color ); ?>" class="tog" <?php checked( $color, $current_color ); ?> /> 
  25. <input type="hidden" class="css_url" value="<?php echo esc_url( $color_info->url ); ?>" /> 
  26. <input type="hidden" class="icon_colors" value="<?php echo esc_attr( wp_json_encode( array( 'icons' => $color_info->icon_colors ) ) ); ?>" /> 
  27. <label for="admin_color_<?php echo esc_attr( $color ); ?>"><?php echo esc_html( $color_info->name ); ?></label> 
  28. <table class="color-palette"> 
  29. <tr> 
  30. <?php 
  31.  
  32. foreach ( $color_info->colors as $html_color ) { 
  33. ?> 
  34. <td style="background-color: <?php echo esc_attr( $html_color ); ?>"> </td> 
  35. <?php 
  36.  
  37. ?> 
  38. </tr> 
  39. </table> 
  40. </div> 
  41. <?php 
  42.  
  43. endforeach; 
  44.  
  45. ?> 
  46. </fieldset> 
  47. <?php