You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
cosmopet-architecture/wp-content/themes/cosmopet/modules/forms/module-ajax-controller.php

45 lines
1.0 KiB

<?php
require_once 'module-controller.php';
add_action('wp_ajax_contact_form', function() {
$enabledHandlers = ['b24', 'email'];
process_form($enabledHandlers);
});
add_action('wp_ajax_nopriv_contact_form', function() {
$enabledHandlers = ['b24', 'email'];
process_form($enabledHandlers);
});
add_action('wp_ajax_subscribe_form', function() {
$enabledHandlers = ['b24', 'email'];
process_form($enabledHandlers);
});
add_action('wp_ajax_nopriv_subscribe_form', function() {
$enabledHandlers = ['b24', 'email'];
process_form($enabledHandlers);
});
add_action('wp_ajax_to_know_form', function() {
$enabledHandlers = ['b24'];
process_form($enabledHandlers);
});
add_action('wp_ajax_nopriv_to_know_form', function() {
$enabledHandlers = ['b24'];
process_form($enabledHandlers);
});
function process_form($enabledHandlers) {
$formData = $_POST['formData'];
$handler = FormHandlerFactory::getHandler($enabledHandlers);
$response = $handler->handle($formData);
wp_send_json($response);
}
?>