- added a reinit function for acf fields after form validation

- added a plugin version of the modal patch for form builder
This commit is contained in:
asus
2024-03-03 21:48:39 +01:00
parent 483c02a4c6
commit cf9a020162
8 changed files with 67 additions and 7 deletions

View File

@@ -38,13 +38,14 @@ include_once(PLGNTLS_class::get_path() . 'php/admin_menu/example_menu.php');
include_once(PLGNTLS_class::get_path() . 'php/paypal/paypal.php');
include_once(PLGNTLS_class::get_path() . '/php/user_infos.php');
//include_once(PLGNTLS_class::get_path() . '/php/hide_admin.php');
include_once(PLGNTLS_class::get_path() . '/php/hide_admin.php');
//include_once(PLGNTLS_class::get_path() . '/php/menus.php');
include_once(PLGNTLS_class::get_path() . 'php/register_partenaires.php');
include_once(PLGNTLS_class::get_path() . 'php/redirections.php');
include_once(PLGNTLS_class::get_path() . 'php/author_restriction.php');
include_once(PLGNTLS_class::get_path() . 'php/reinit_acf_fields.php');
include_once(PLGNTLS_class::get_path() . 'php/form_builder_patch/form_builder.php');

View File

@@ -0,0 +1,30 @@
let modal_wrapper_UNIQ_ID_7623 = document.querySelector('#de-fb-modal-wrapper-');
// create an observer on first #de-fb-modal-wrapper- to check if child nodes are added
const observer_UNIQ_ID_7623 = new MutationObserver(wait_for_close_button_UNIQ_ID_7623);
observer_UNIQ_ID_7623.observe(modal_wrapper_UNIQ_ID_7623, {
subtree: true,
childList: true,
});
// observe mutations to see if they include the creation of the button .modal-close
// if the button is created, add an eventListener to it
function wait_for_close_button_UNIQ_ID_7623(mutationsList) {
mutationsList.forEach((mutation) => {
// check if nodes were added
if (mutation.type !== 'childList')
return;
// check if added nodes includes the button .modal-close
let modal_close = document.querySelector('#de-fb-modal-wrapper- .modal-close');
if (modal_close !== null) {
modal_close.addEventListener("click", delete_modal_UNIQ_ID_7623);
}
});
}
// when triggered, the .modal-close button will remove all childs from #de-fb-modal-wrapper-
function delete_modal_UNIQ_ID_7623() {
modal_wrapper_UNIQ_ID_7623.innerHTML = '';
}

View File

@@ -0,0 +1,15 @@
<?php
function test_modal_PLGNTLS() {
$fipf_modal = new PLGNTLS_class();
$fipf_modal->add_to_front(
array(
'js/form_builder_patch/form_builder.js',
));
}
add_shortcode('test_modal', 'test_modal_PLGNTLS');
?>

View File

@@ -14,12 +14,12 @@ if (!defined('ABSPATH')) {
/*
* hide admin bar if access a front page and is not an admin
*/
function hide_admin_bar() {
function hide_admin_bar_CIPF() {
if (!current_user_can('administrator') && !is_admin()) {
show_admin_bar(false);
}
}
add_action('after_setup_theme', 'hide_admin_bar');
add_action('after_setup_theme', 'hide_admin_bar_CIPF');
?>

View File

@@ -22,7 +22,7 @@ if (!defined('ABSPATH')) {
* - $menu_redirect = $current_url -> https://le_site_actuel.com/la_meme_page
* - $menu_redirect = 'www.un_autre_site.net/contact' -> https://www.un_autre_site.net/contact
*/
function change_menu($items){
function change_menu_logout($items){
$menu_title = 'special logout';
// quelques urls utiles :
@@ -37,7 +37,7 @@ function change_menu($items){
}
return $items;
}
add_filter('wp_nav_menu_objects', 'change_menu');
add_filter('wp_nav_menu_objects', 'change_menu_logout');
?>

View File

@@ -0,0 +1,12 @@
<?php
function reinit_some_fields_CIPF($form_id, $user_id, $post_array) {
update_field('cgv', array(""), 'user_'.$user_id);
update_field('paiement', array(""), 'user_'.$user_id);
update_field('livraison', array(""), 'user_'.$user_id);
}
add_action('df_after_insert_user', 'reinit_some_fields_CIPF', 10, 3);
?>

View File

@@ -262,9 +262,11 @@ class PLGNTLS_class
/*
* uncomment to print all enqueued files, can be usefull
*/
global $wp_scripts;
error_log("wp_scripts->queue:");
error_log(json_encode($wp_scripts->queue));
/*
global $wp_styles;
error_log("wp_styles->queue:");
error_log(json_encode($wp_styles->queue));