id, 'wp-allstars') === false) { return; } // Check if we have a transient indicating a recent save $user_id = get_current_user_id(); $transient_name = 'wp_allstars_colors_updated_' . $user_id; if (get_transient($transient_name)) { // Add inline script to show the notification ?> 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 */ public function handle_color_scheme_update() { // Check for required params if (!isset($_POST['option']) || !isset($_POST['value']) || !isset($_POST['nonce'])) { return; } // Verify nonce check_ajax_referer('wp-allstars-nonce', 'nonce'); // 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); // Update the option update_option($this->option_name, $value ? 1 : 0); // Set a transient to show the saved notice set_transient('wp_allstars_colors_updated_' . $user_id, true, 30); // Return success wp_send_json_success(); } }