| @@ -64,13 +64,16 @@ | ||
| 64 | 64 | ]); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
| 68 | - * Check user permissions | |
| 68 | + * Sample-data import / cleanup — gated on the settings cap. | |
| 69 | + * Installing or removing sample content is a one-time setup | |
| 70 | + * task with the same risk profile as other settings changes. | |
| 71 | + * WP admins pass via the Team module's admin-fallback filter. | |
| 69 | 72 | */ |
| 70 | 73 | public function check_permissions() |
| 71 | 74 | { |
| 72 | - return current_user_can('manage_options'); | |
| 75 | + return current_user_can('yatra_manage_settings'); | |
| 73 | 76 | } |
| 74 | 77 | |
| 75 | 78 | /** |
| 76 | 79 | * Handle import actions from admin forms |
| @@ -193,9 +196,8 @@ | ||
| 193 | 196 | 'message' => $result['message'] ?? __('Import failed.', 'yatra') |
| 194 | 197 | ]; |
| 195 | 198 | } |
| 196 | 199 | } catch (\Exception $e) { |
| 197 | - error_log('Yatra Sample Data Import Error: ' . $e->getMessage()); | |
| 198 | 200 | return [ |
| 199 | 201 | 'success' => false, |
| 200 | 202 | 'message' => __('An error occurred during import. Please check the error logs.', 'yatra') |
| 201 | 203 | ]; |
| @@ -228,9 +230,8 @@ | ||
| 228 | 230 | 'message' => $result['message'] ?? __('Cleanup failed.', 'yatra') |
| 229 | 231 | ]; |
| 230 | 232 | } |
| 231 | 233 | } catch (\Exception $e) { |
| 232 | - error_log('Yatra Sample Data Cleanup Error: ' . $e->getMessage()); | |
| 233 | 234 | return [ |
| 234 | 235 | 'success' => false, |
| 235 | 236 | 'message' => __('An error occurred during cleanup. Please check the error logs.', 'yatra') |
| 236 | 237 | ]; |