From 1745d8754d620c4b793425a52a4b190406a691c4 Mon Sep 17 00:00:00 2001 From: asus Date: Sun, 24 Mar 2024 16:16:55 +0100 Subject: [PATCH] adding patchs files according to form in menu --- plugins/fbpatch/fbpatch.php | 2 +- plugins/fbpatch/menu/menu_content.php | 3 --- plugins/fbpatch/php/calculations.php | 2 +- plugins/fbpatch/php/fbpatch_class.php | 11 ++++++++++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/plugins/fbpatch/fbpatch.php b/plugins/fbpatch/fbpatch.php index c837a80..88a3c67 100644 --- a/plugins/fbpatch/fbpatch.php +++ b/plugins/fbpatch/fbpatch.php @@ -23,7 +23,7 @@ include_once(plugin_dir_path(__FILE__) . '/menu/admin_menu.php'); include_once(plugin_dir_path(__FILE__) . '/menu/admin_menu_toggle.php'); include_once(plugin_dir_path(__FILE__) . '/menu/menu_content.php'); -include_once(plugin_dir_path(__FILE__) . '/php/calculations.php'); +//include_once(plugin_dir_path(__FILE__) . '/php/calculations.php'); \FBPATCH\Fbpatch::init_hook(); diff --git a/plugins/fbpatch/menu/menu_content.php b/plugins/fbpatch/menu/menu_content.php index 7703e09..cf0611e 100644 --- a/plugins/fbpatch/menu/menu_content.php +++ b/plugins/fbpatch/menu/menu_content.php @@ -17,7 +17,6 @@ if (!defined('ABSPATH')) { */ function plugin_content() { $patches = Fbpatch::get_patches(); - error_log("in plugin_content, patches: ".json_encode($patches)); $nonce = Fbpatch::NONCE; $admin_post_patches = Fbpatch::ADMIN_POST_PATCH_CHOICE; ob_start(); @@ -51,7 +50,6 @@ function patches_choice() { "hide_show":"on" } */ - error_log("-> _POST: " . json_encode($_POST)); $pathes_on = array(); foreach($_POST as $key => $value) { if ($value !== 'on') { @@ -59,7 +57,6 @@ function patches_choice() { } $pathes_on[] = $key; } - error_log("-> pathes_update: " . json_encode($pathes_on)); Fbpatch::set_patches($pathes_on); \FBPATCH\redirect_menu_referer($_POST); diff --git a/plugins/fbpatch/php/calculations.php b/plugins/fbpatch/php/calculations.php index 2e35003..aaa0da4 100644 --- a/plugins/fbpatch/php/calculations.php +++ b/plugins/fbpatch/php/calculations.php @@ -20,7 +20,7 @@ function add_form_builder_calculations_patch() { $defer = true; wp_enqueue_script($handle, $url, $dependencies, $version, $defer); } -//add_action('wp_enqueue_scripts', __NAMESPACE__.'\add_form_builder_calculations_patch', 22); +add_action('wp_enqueue_scripts', __NAMESPACE__.'\add_form_builder_calculations_patch', 22); diff --git a/plugins/fbpatch/php/fbpatch_class.php b/plugins/fbpatch/php/fbpatch_class.php index 605e90b..96ab8a4 100644 --- a/plugins/fbpatch/php/fbpatch_class.php +++ b/plugins/fbpatch/php/fbpatch_class.php @@ -108,8 +108,17 @@ class Fbpatch { update_option(self::$_patches['_name'], $serialize_patches_option); } + /* + * this function will include the files of the different patches if they are set in the options + * + */ public static function init_hook() { - add_action('wp_enqueue_scripts', __NAMESPACE__.'\add_form_builder_calculations_patch', 22); + $patches = Fbpatch::get_patches(); + foreach($patches as $patch => $data) { + if ($data['checked'] === true) { + include_once(plugin_dir_path(__DIR__) . '/php/'.$patch.'.php'); + } + } } }