| @@ -326,7 +326,34 @@ | ||
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | return $dotProduct / ($normA * $normB); |
| 329 | 329 | } |
| 330 | + | |
| 331 | + /** | |
| 332 | + * Check the status of a Word document for the current session | |
| 333 | + */ | |
| 334 | +public function mxchat_check_word_status() { | |
| 335 | + check_ajax_referer('mxchat_chat_nonce', 'nonce'); | |
| 336 | + | |
| 337 | + if (empty($_POST['session_id'])) { | |
| 338 | + wp_send_json_error(esc_html__('Session ID missing.', 'mxchat')); | |
| 339 | + return; | |
| 340 | + } | |
| 341 | + | |
| 342 | + $session_id = sanitize_text_field($_POST['session_id']); | |
| 343 | + $word_path = get_transient('mxchat_word_url_' . $session_id); | |
| 344 | + $filename = get_transient('mxchat_word_filename_' . $session_id); | |
| 345 | + | |
| 346 | + if ($word_path && file_exists($word_path) && $filename) { | |
| 347 | + wp_send_json_success([ | |
| 348 | + 'has_word' => true, | |
| 349 | + 'filename' => $filename | |
| 350 | + ]); | |
| 351 | + } else { | |
| 352 | + wp_send_json_success([ | |
| 353 | + 'has_word' => false | |
| 354 | + ]); | |
| 355 | + } | |
| 356 | +} | |
| 330 | 357 | |
| 331 | 358 | |
| 332 | 359 | } |