From cf9a0201627dfd01bcaa51bb01aa80e69604a21d Mon Sep 17 00:00:00 2001 From: asus Date: Sun, 3 Mar 2024 21:48:39 +0100 Subject: [PATCH] - added a reinit function for acf fields after form validation - added a plugin version of the modal patch for form builder --- plugins/fipfcard_plugin/fipfcard_plugin.php | 5 ++-- .../js/form_builder_patch/form_builder.js | 30 +++++++++++++++++++ .../php/form_builder_patch/form_builder.php | 15 ++++++++++ plugins/fipfcard_plugin/php/hide_admin.php | 4 +-- plugins/fipfcard_plugin/php/menus.php | 4 +-- .../fipfcard_plugin/php/reinit_acf_fields.php | 12 ++++++++ .../fipfcard_plugin/utils/plgntls_class.php | 2 ++ private | 2 +- 8 files changed, 67 insertions(+), 7 deletions(-) create mode 100644 plugins/fipfcard_plugin/js/form_builder_patch/form_builder.js create mode 100644 plugins/fipfcard_plugin/php/form_builder_patch/form_builder.php create mode 100644 plugins/fipfcard_plugin/php/reinit_acf_fields.php diff --git a/plugins/fipfcard_plugin/fipfcard_plugin.php b/plugins/fipfcard_plugin/fipfcard_plugin.php index 823cae0..592fac5 100644 --- a/plugins/fipfcard_plugin/fipfcard_plugin.php +++ b/plugins/fipfcard_plugin/fipfcard_plugin.php @@ -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'); diff --git a/plugins/fipfcard_plugin/js/form_builder_patch/form_builder.js b/plugins/fipfcard_plugin/js/form_builder_patch/form_builder.js new file mode 100644 index 0000000..cd418c1 --- /dev/null +++ b/plugins/fipfcard_plugin/js/form_builder_patch/form_builder.js @@ -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 = ''; +} + diff --git a/plugins/fipfcard_plugin/php/form_builder_patch/form_builder.php b/plugins/fipfcard_plugin/php/form_builder_patch/form_builder.php new file mode 100644 index 0000000..8a4d549 --- /dev/null +++ b/plugins/fipfcard_plugin/php/form_builder_patch/form_builder.php @@ -0,0 +1,15 @@ +add_to_front( + array( + 'js/form_builder_patch/form_builder.js', + )); +} +add_shortcode('test_modal', 'test_modal_PLGNTLS'); + + + +?> diff --git a/plugins/fipfcard_plugin/php/hide_admin.php b/plugins/fipfcard_plugin/php/hide_admin.php index dbbe7a0..b7349c2 100644 --- a/plugins/fipfcard_plugin/php/hide_admin.php +++ b/plugins/fipfcard_plugin/php/hide_admin.php @@ -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'); ?> diff --git a/plugins/fipfcard_plugin/php/menus.php b/plugins/fipfcard_plugin/php/menus.php index e64c44b..45827be 100644 --- a/plugins/fipfcard_plugin/php/menus.php +++ b/plugins/fipfcard_plugin/php/menus.php @@ -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'); ?> diff --git a/plugins/fipfcard_plugin/php/reinit_acf_fields.php b/plugins/fipfcard_plugin/php/reinit_acf_fields.php new file mode 100644 index 0000000..cf7ef5e --- /dev/null +++ b/plugins/fipfcard_plugin/php/reinit_acf_fields.php @@ -0,0 +1,12 @@ + diff --git a/plugins/fipfcard_plugin/utils/plgntls_class.php b/plugins/fipfcard_plugin/utils/plgntls_class.php index d2c706d..d5f7f11 100644 --- a/plugins/fipfcard_plugin/utils/plgntls_class.php +++ b/plugins/fipfcard_plugin/utils/plgntls_class.php @@ -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)); diff --git a/private b/private index a25574e..3ab9da9 160000 --- a/private +++ b/private @@ -1 +1 @@ -Subproject commit a25574e7f7fe81f796d2b082aa981c25caf3655b +Subproject commit 3ab9da9ec3d06436e6995f8688531b8a2f0ca198