-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-test.php
More file actions
127 lines (106 loc) · 4.15 KB
/
Copy pathdebug-test.php
File metadata and controls
127 lines (106 loc) · 4.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
/**
* Resume Parser Debug Test
*
* This file helps debug API connectivity and response issues
*/
// Prevent direct access
if (!defined('ABSPATH')) {
exit;
}
/**
* Test the n8n webhook endpoint
*/
function test_n8n_webhook() {
$endpoint = 'https://n8n.softinator.org/webhook/63d093d6-57e8-44cc-b16e-10d7c1303c47';
// Test data
$test_data = array(
'file_name' => 'test_resume.pdf',
'file_type' => 'application/pdf',
'file_data' => base64_encode('This is test file content')
);
$args = array(
'timeout' => 60,
'body' => json_encode($test_data),
'headers' => array(
'Content-Type' => 'application/json',
)
);
echo "<h3>Testing n8n Webhook</h3>";
echo "<p><strong>Endpoint:</strong> " . esc_html($endpoint) . "</p>";
echo "<p><strong>Test Data:</strong></p>";
echo "<pre>" . esc_html(json_encode($test_data, JSON_PRETTY_PRINT)) . "</pre>";
$response = wp_remote_post($endpoint, $args);
if (is_wp_error($response)) {
echo "<p><strong>Error:</strong> " . esc_html($response->get_error_message()) . "</p>";
return false;
}
$response_code = wp_remote_retrieve_response_code($response);
$body = wp_remote_retrieve_body($response);
echo "<p><strong>Response Code:</strong> " . esc_html($response_code) . "</p>";
echo "<p><strong>Response Headers:</strong></p>";
echo "<pre>" . esc_html(print_r(wp_remote_retrieve_headers($response), true)) . "</pre>";
echo "<p><strong>Response Body:</strong></p>";
echo "<pre>" . esc_html($body) . "</pre>";
if ($response_code === 200) {
$decoded = json_decode($body, true);
if ($decoded) {
echo "<p><strong>Parsed JSON:</strong></p>";
echo "<pre>" . esc_html(json_encode($decoded, JSON_PRETTY_PRINT)) . "</pre>";
} else {
echo "<p><strong>JSON Parse Error:</strong> " . esc_html(json_last_error_msg()) . "</p>";
}
}
return $response_code === 200;
}
// Add this to a page or post to test: [test_resume_parser_debug]
add_shortcode('test_resume_parser_debug', function() {
ob_start();
echo "<div style='background: #f9f9f9; padding: 20px; margin: 20px 0; border: 1px solid #ddd;'>";
echo "<h2>Resume Parser Debug Test</h2>";
// Test webhook
test_n8n_webhook();
echo "<hr>";
echo "<h3>WordPress Environment Info</h3>";
echo "<p><strong>WordPress Version:</strong> " . esc_html(get_bloginfo('version')) . "</p>";
echo "<p><strong>PHP Version:</strong> " . esc_html(phpversion()) . "</p>";
echo "<p><strong>cURL Available:</strong> " . (function_exists('curl_version') ? 'Yes' : 'No') . "</p>";
echo "<p><strong>allow_url_fopen:</strong> " . (ini_get('allow_url_fopen') ? 'Yes' : 'No') . "</p>";
echo "<p><strong>Max Upload Size:</strong> " . esc_html(ini_get('upload_max_filesize')) . "</p>";
echo "<p><strong>Max Post Size:</strong> " . esc_html(ini_get('post_max_size')) . "</p>";
echo "<p><strong>Memory Limit:</strong> " . esc_html(ini_get('memory_limit')) . "</p>";
echo "<hr>";
echo "<h3>Test Resume Parser Form</h3>";
echo do_shortcode('[resume_parser fields="name,email,phone" api_endpoint="https://n8n.softinator.org/webhook/63d093d6-57e8-44cc-b16e-10d7c1303c47" class="debug-test"]');
echo "</div>";
return ob_get_clean();
});
/**
* Add debugging CSS
*/
add_action('wp_head', function() {
echo '<style>
.debug-test {
border: 2px dashed #007cba !important;
background: #f0f8ff !important;
}
.debug-test .resume-upload-section {
background: #ffe0e0 !important;
}
</style>';
});
/**
* Add debug information to console
*/
add_action('wp_footer', function() {
echo '<script>
console.log("Resume Parser Debug: Plugin loaded");
// Monitor form submissions
jQuery(document).ready(function($) {
$(document).on("change", ".resume-file-input", function() {
console.log("Resume Parser Debug: File input changed");
console.log("API Endpoint:", $(this).data("api-endpoint"));
});
});
</script>';
});