wp_ajax_save_user_color_scheme

Ajax handler for auto-saving the selected color scheme for a user's own profile.

Description

wp_ajax_save_user_color_scheme(); 

Usage

  1. if ( !function_exists( 'wp_ajax_save_user_color_scheme' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/ajax-actions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_ajax_save_user_color_scheme(); 
  7.  

Defined (1)

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

/wp-admin/includes/ajax-actions.php  
  1. function wp_ajax_save_user_color_scheme() { 
  2. global $_wp_admin_css_colors; 
  3.  
  4. check_ajax_referer( 'save-color-scheme', 'nonce' ); 
  5.  
  6. $color_scheme = sanitize_key( $_POST['color_scheme'] ); 
  7.  
  8. if ( ! isset( $_wp_admin_css_colors[ $color_scheme ] ) ) { 
  9.  
  10. $previous_color_scheme = get_user_meta( get_current_user_id(), 'admin_color', true ); 
  11. update_user_meta( get_current_user_id(), 'admin_color', $color_scheme ); 
  12.  
  13. 'previousScheme' => 'admin-color-' . $previous_color_scheme,  
  14. 'currentScheme' => 'admin-color-' . $color_scheme 
  15. ) );