From 6ec621a20bc9f4518d617079fe5e23b482836579 Mon Sep 17 00:00:00 2001 From: asus Date: Mon, 25 Mar 2024 13:07:12 +0100 Subject: [PATCH] fbpatch small fixes in options and hide-show --- plugins/fbpatch/php/fbpatch_class.php | 35 ++++++++++++++++----------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/plugins/fbpatch/php/fbpatch_class.php b/plugins/fbpatch/php/fbpatch_class.php index 1c55726..079af6e 100644 --- a/plugins/fbpatch/php/fbpatch_class.php +++ b/plugins/fbpatch/php/fbpatch_class.php @@ -44,10 +44,10 @@ class Fbpatch { private static $_patches = [ '_name'=>'fbpatch_list_of_patches', - 'calculations'=>['checked'=>true, 'title'=>'calculations title', 'description'=>'calculation description'], - 'hide_show' =>['checked'=>true, 'title'=>'hide/show title', 'description'=>'hide/show description'], - 'modals' =>['checked'=>false, 'title'=>'modals title', 'description'=>'modals description'], - 'urls' =>['checked'=>false, 'title'=>'urls title', 'description'=>'urls description'], + 'calculations'=>['checked'=>true, 'title'=>'calculations', 'description'=>"afficher le total des calculs dès l'ouverture des formulaires"], + 'hide_show' =>['checked'=>true, 'title'=>'masquer les offres', 'description'=>"permettre de masquer les offres en editant un formulaire, sans les supprimer"], + 'modals' =>['checked'=>false, 'title'=>'modals', 'description'=>"permettre plusieurs modals sur une meme page"], + 'urls' =>['checked'=>false, 'title'=>'urls', 'description'=>"permettre de rentrer des urls sans 'http://'"], ]; private static function set_option_patches() { @@ -74,9 +74,14 @@ class Fbpatch { continue; } if (isset($patches_option[$patch])) { - continue; + // updates the title and the description + $patches_option[$patch]['title'] = $data['title']; + $patches_option[$patch]['description'] = $data['description']; + } + else { + // add the option + $patches_option[$patch] = $data; } - $patches_option[$patch] = $data; } /* @@ -181,24 +186,26 @@ class Fbpatch { } /* - * if there is elements to skip, add the filter, otherwise removes it (to be sure) + * if there is elements to skip, add the filter * */ public static function init_skip_hook() { - if (false === self::$_has_elements_to_skip) { - remove_filter("update_post_metadata", __NAMESPACE__.'\filter_elements_to_skip'); - return; + if (true === self::$_has_elements_to_skip) { + add_filter("update_post_metadata", __NAMESPACE__.'\filter_elements_to_skip', 10, 5); } - - add_filter("update_post_metadata", __NAMESPACE__.'\filter_elements_to_skip', 10, 5); } /* - * after insertion finished, removes filter + * after insertion finished, removes filter and reset variables * */ public static function end_skip_hook() { - remove_filter("update_post_metadata", __NAMESPACE__.'\filter_elements_to_skip'); + if (true === self::$_has_elements_to_skip) { + remove_filter("update_post_metadata", __NAMESPACE__.'\filter_elements_to_skip'); + } + self::$_post_id = 0; + self::$_has_elements_to_skip = false; + self::$_skip_elements = array(); }