adding patchs files according to form in menu

This commit is contained in:
asus
2024-03-24 16:16:55 +01:00
parent 28a1f7922d
commit 1745d8754d
4 changed files with 12 additions and 6 deletions

View File

@@ -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/admin_menu_toggle.php');
include_once(plugin_dir_path(__FILE__) . '/menu/menu_content.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(); \FBPATCH\Fbpatch::init_hook();

View File

@@ -17,7 +17,6 @@ if (!defined('ABSPATH')) {
*/ */
function plugin_content() { function plugin_content() {
$patches = Fbpatch::get_patches(); $patches = Fbpatch::get_patches();
error_log("in plugin_content, patches: ".json_encode($patches));
$nonce = Fbpatch::NONCE; $nonce = Fbpatch::NONCE;
$admin_post_patches = Fbpatch::ADMIN_POST_PATCH_CHOICE; $admin_post_patches = Fbpatch::ADMIN_POST_PATCH_CHOICE;
ob_start(); ob_start();
@@ -51,7 +50,6 @@ function patches_choice() {
"hide_show":"on" "hide_show":"on"
} }
*/ */
error_log("-> _POST: " . json_encode($_POST));
$pathes_on = array(); $pathes_on = array();
foreach($_POST as $key => $value) { foreach($_POST as $key => $value) {
if ($value !== 'on') { if ($value !== 'on') {
@@ -59,7 +57,6 @@ function patches_choice() {
} }
$pathes_on[] = $key; $pathes_on[] = $key;
} }
error_log("-> pathes_update: " . json_encode($pathes_on));
Fbpatch::set_patches($pathes_on); Fbpatch::set_patches($pathes_on);
\FBPATCH\redirect_menu_referer($_POST); \FBPATCH\redirect_menu_referer($_POST);

View File

@@ -20,7 +20,7 @@ function add_form_builder_calculations_patch() {
$defer = true; $defer = true;
wp_enqueue_script($handle, $url, $dependencies, $version, $defer); 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);

View File

@@ -108,8 +108,17 @@ class Fbpatch {
update_option(self::$_patches['_name'], $serialize_patches_option); 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() { 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');
}
}
} }
} }