Form Submission Debug'; echo '
Test URL: ' . $test_url . '
'; // Check if form was submitted if ($_SERVER['REQUEST_METHOD'] === 'POST') { echo '✓ submit_snippet is set
'; // Check if nonce is set and valid if (isset($_POST['pc_hfap_nonce'])) { if (wp_verify_nonce($_POST['pc_hfap_nonce'], 'pc_hfap_save_snippet')) { echo '✓ Nonce is valid
'; // Try to save directly require_once dirname(__FILE__) . '/includes/class-database.php'; require_once dirname(__FILE__) . '/includes/class-snippet.php'; $data = array( 'title' => sanitize_text_field($_POST['pc_hfap_title']), 'location' => in_array($_POST['pc_hfap_location'], array('header', 'footer', 'body')) ? $_POST['pc_hfap_location'] : 'header', 'code' => wp_unslash($_POST['pc_hfap_code']) ); echo 'Saving snippet...
'; $snippet = new PC_HFAP_Snippet($data); $result = $snippet->save(); if ($result) { echo '✓ SUCCESS! Snippet saved with ID: ' . $result . '
'; echo ''; } else { echo '✗ FAILED to save snippet
'; global $wpdb; echo 'Last error: ' . $wpdb->last_error . '
'; } } else { echo '✗ Nonce is invalid
'; } } else { echo '✗ Nonce not set
'; } } else { echo '✗ submit_snippet not set
'; } echo '';
print_r($_POST);
echo '';
} else {
echo 'To test, submit the form or use this test form:
'; echo ''; }