Files
Bookshelf/Old/bd-murphy-author/page-contact.php
2026-10-18 19:01:01 -07:00

90 lines
3.2 KiB
PHP

<?php
// Copyright 2026 Umbra Tools (umbratools.com)
// SPDX-License-Identifier: Apache-2.0
/**
* Template Name: Contact
*/
get_header();
?>
<div class="contact-container">
<div class="contact-content">
<h1><?php esc_html_e('Contact', 'bd-murphy'); ?></h1>
<form id="contact-form" class="contact-form" method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>">
<?php wp_nonce_field('bdm_contact', 'bdm_contact_nonce'); ?>
<input type="hidden" name="action" value="bdm_contact_submit">
<div class="form-field">
<label for="name"><?php esc_html_e('Name', 'bd-murphy'); ?> *</label>
<input type="text" id="name" name="name" required>
</div>
<div class="form-field">
<label for="email"><?php esc_html_e('Email', 'bd-murphy'); ?> *</label>
<input type="email" id="email" name="email" required>
</div>
<div class="form-field">
<label for="subject"><?php esc_html_e('Subject', 'bd-murphy'); ?> *</label>
<input type="text" id="subject" name="subject" required>
</div>
<div class="form-field honeypot">
<label for="website"><?php esc_html_e('Website', 'bd-murphy'); ?></label>
<input type="text" id="website" name="website" tabindex="-1" autocomplete="off">
</div>
<div class="form-field">
<label for="message"><?php esc_html_e('Message', 'bd-murphy'); ?> *</label>
<textarea id="message" name="message" rows="8" required></textarea>
</div>
<div class="form-submit">
<button type="submit" class="submit-btn"><?php esc_html_e('Send Message', 'bd-murphy'); ?></button>
</div>
</form>
<div id="contact-form-response" class="form-response" style="display:none;"></div>
</div>
</div>
<script>
jQuery(document).ready(function($) {
$('#contact-form').on('submit', function(e) {
e.preventDefault();
if ($('#website').val() !== '') {
return;
}
var formData = $(this).serialize();
var responseDiv = $('#contact-form-response');
$.ajax({
type: 'POST',
url: '<?php echo admin_url('admin-ajax.php'); ?>',
data: formData,
success: function(response) {
if (response.success) {
responseDiv.html('<p class="success"><?php esc_html_e('Thank you for your message. We will get back to you soon.', 'bd-murphy'); ?></p>');
$('#contact-form')[0].reset();
} else {
responseDiv.html('<p class="error"><?php esc_html_e('There was an error sending your message. Please try again.', 'bd-murphy'); ?></p>');
}
responseDiv.show();
},
error: function() {
responseDiv.html('<p class="error"><?php esc_html_e('There was an error sending your message. Please try again.', 'bd-murphy'); ?></p>');
responseDiv.show();
}
});
});
});
</script>
<?php
get_footer();