option_name, false); // Get the scheme to set $scheme = $modern_colors_enabled ? $this->modern_scheme : $this->default_scheme; // Update user meta to set the color scheme update_user_meta($user_id, 'admin_color', $scheme); } /** * Handle color scheme update via AJAX * Runs early to apply the color scheme change before the general option update handler */ public function handle_color_scheme_update() { // Check for required params if (!isset($_POST['option']) || !isset($_POST['value'])) { return; } // Only process our specific option if ($_POST['option'] !== $this->option_name) { return; } // Get the current user ID $user_id = get_current_user_id(); if (!$user_id) { return; } // Determine which scheme to set based on the value $value = (bool) $_POST['value']; $scheme = $value ? $this->modern_scheme : $this->default_scheme; // Update the user's color scheme update_user_meta($user_id, 'admin_color', $scheme); } }