Skip to content

Instantly share code, notes, and snippets.

@michelegiorgi
Last active December 20, 2023 00:06
Show Gist options
  • Save michelegiorgi/56fe4489b922cf2af4704b79d4f56bb6 to your computer and use it in GitHub Desktop.
Save michelegiorgi/56fe4489b922cf2af4704b79d4f56bb6 to your computer and use it in GitHub Desktop.
Formality hooks reference
<?php
/**
* Formality hooks reference
*
* @link https://formality.dev
* @since 1.1
* @package Formality
* @author Michele Giorgi <[email protected]>
*/
/**
* Filters reference
*/
add_filter('formality_form_body_classes', function($classes) {
//add or remove body classes from $classes array here
return $classes;
});
add_filter('formality_form_template', function($template) {
//change form template path here
return $template;
});
add_filter('formality_form_header', function($html, $form_id) {
//edit rendered $html here
return $html;
}, 10, 2);
add_filter('formality_form_body', function($html, $form_id) {
//edit rendered $html here
return $html;
}, 10, 2);
add_filter('formality_form_sidebar', function($html, $form_id) {
//edit rendered $html here
return $html;
}, 10, 2);
add_filter('formality_form_nav', function($html, $form_id) {
//edit rendered $html here
return $html;
}, 10, 2);
add_filter('formality_form_footer', function($html, $form_id) {
//edit rendered $html here
return $html;
}, 10, 2);
add_filter('formality_form_style', function($html, $form_id) {
//edit rendered $html here
return $html;
}, 10, 2);
add_filter('formality_form_field', function($html, $field) {
//edit rendered $html here
return $html;
}, 10, 2);
add_filter('formality_form_result', function($html, $form_id) {
//edit rendered $html here
return $html;
}, 10, 2);
add_filter('formality_form_credits', function($html, $form_id) {
//edit rendered $html here
return $html;
}, 10, 2);
add_filter('formality_sanitized_data', function($data) {
//edit sanitized data here
return $data;
});
add_filter('formality_enqueue_assets', function($enqueue) {
//enqueue embed formality assets (bool)
return $enqueue;
});
/**
* Actions reference
*/
add_action('formality_after_validation', function($data){
//do something here
});
add_action('formality_before_save_data', function($data){
//do something here
});
add_action('formality_before_notification', function($data){
//do something here
});
add_action('formality_after_notification', function($data){
//do something here
});
add_action('formality_after_save_data', function($data, $errors){
//do something here
}, 10, 2);
/**
* JS dom events reference
*/
add_action('wp_print_scripts', function() { ?>
<script>
window.addEventListener("foFormsInit", function(e) { console.log(e.detail); })
window.addEventListener("foFormSubmit", function(e) { console.log(e.detail); })
window.addEventListener("foFormSuccess", function(e) { console.log(e.detail); })
window.addEventListener("foFormError", function(e) { console.log(e.detail); })
window.addEventListener("foFieldFocus", function(e) { console.log(e.detail); })
window.addEventListener("foFieldFill", function(e) { console.log(e.detail); })
window.addEventListener("foSidebarOpen", function(e) { console.log(e.detail); })
window.addEventListener("foSidebarClose", function(e) { console.log(e.detail); })
</script>
<?php });
@michelegiorgi
Copy link
Author

@cattaneoriccardo Thank you for reporting this issue. Fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment