| @@ -42,10 +42,10 @@ | ||
| 42 | 42 | $errors['short_description'][] = __('Short description cannot exceed 500 characters', 'yatra'); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | if (isset($data['slug']) && !empty($data['slug'])) { |
| 46 | - if (!preg_match('/^[a-z0-9-]+$/', $data['slug'])) { | |
| 47 | - $errors['slug'][] = __('Slug can only contain lowercase letters, numbers, and hyphens', 'yatra'); | |
| 46 | + if (!preg_match('/^[\pL\pN-]+$/u', $data['slug'])) { | |
| 47 | + $errors['slug'][] = __('Slug can only contain letters, numbers, and hyphens', 'yatra'); | |
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | if (isset($data['difficulty_level']) && !empty($data['difficulty_level'])) { |
| @@ -109,10 +109,10 @@ | ||
| 109 | 109 | if (isset($data['short_description']) && strlen($data['short_description']) > 500) { |
| 110 | 110 | $errors['short_description'][] = __('Short description cannot exceed 500 characters', 'yatra'); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - if (isset($data['slug']) && !empty($data['slug']) && !preg_match('/^[a-z0-9-]+$/', $data['slug'])) { | |
| 114 | - $errors['slug'][] = __('Slug can only contain lowercase letters, numbers, and hyphens', 'yatra'); | |
| 113 | + if (isset($data['slug']) && !empty($data['slug']) && !preg_match('/^[\pL\pN-]+$/u', $data['slug'])) { | |
| 114 | + $errors['slug'][] = __('Slug can only contain letters, numbers, and hyphens', 'yatra'); | |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | if (isset($data['difficulty_level']) && !empty($data['difficulty_level'])) { |
| 118 | 118 | if (!in_array($data['difficulty_level'], ['easy', 'moderate', 'challenging', 'extreme'])) { |
| @@ -155,9 +155,9 @@ | ||
| 155 | 155 | $sanitized['name'] = sanitize_text_field($data['name']); |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | if (isset($data['slug'])) { |
| 159 | - $sanitized['slug'] = sanitize_title($data['slug']); | |
| 159 | + $sanitized['slug'] = \Yatra\Helpers\SlugHelper::generate($data['slug']); | |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | if (isset($data['description'])) { |
| 163 | 163 | $sanitized['description'] = wp_kses_post($data['description']); |
| @@ -226,8 +226,21 @@ | ||
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | if (isset($data['excluded_items'])) { |
| 229 | 229 | $sanitized['excluded_items'] = is_array($data['excluded_items']) ? json_encode($data['excluded_items']) : $data['excluded_items']; |
| 230 | + } | |
| 231 | + | |
| 232 | + // Icon (Yatra SVG / Font Awesome / image) — preserve full picker shape; Service layer serializes. | |
| 233 | + if (array_key_exists('icon', $data)) { | |
| 234 | + if (is_array($data['icon'])) { | |
| 235 | + $sanitized['icon'] = function_exists('yatra_normalize_icon_picker_for_storage') | |
| 236 | + ? yatra_normalize_icon_picker_for_storage($data['icon']) | |
| 237 | + : $data['icon']; | |
| 238 | + } elseif (is_string($data['icon'])) { | |
| 239 | + $sanitized['icon'] = sanitize_text_field($data['icon']); | |
| 240 | + } elseif ($data['icon'] === null) { | |
| 241 | + $sanitized['icon'] = null; | |
| 242 | + } | |
| 230 | 243 | } |
| 231 | 244 | |
| 232 | 245 | return $sanitized; |
| 233 | 246 | } |