wip patchs appears with informations, but are not yet updated

This commit is contained in:
asus
2024-03-24 13:23:00 +01:00
parent 94dbe05f87
commit 1415fc14a2
4 changed files with 30 additions and 21 deletions

View File

@@ -22,10 +22,15 @@ class Fbpatch {
const NONCE = ['_name'=>'nonce_name', '_action'=>'action_name'];
const ADMIN_POST_PATCH_CHOICE = 'add_patches';
private static $_patches = ['_name'=>'fbpatch_list_of_patches', 'calculations', 'hide_show'];
private static $_patches = [
'_name'=>'fbpatch_list_of_patches',
'calculations'=>['checked'=>'false', 'title'=>'calculations title', 'description'=>'calculation description'],
'hide_show'=>['checked'=>'false', 'title'=>'hide/show title', 'description'=>'hide/show description'],
];
//private static $_patches = ['_name'=>'fbpatch_list_of_patches', 'hide_show'];
//private static $_patches = ['_name'=>'fbpatch_list_of_patches'];
private static function set_option_patchs() {
private static function set_option_patches() {
error_log("---");
/*
* get the list of patches in option
@@ -47,14 +52,14 @@ class Fbpatch {
*
*/
error_log("patches_option before 1: " . json_encode($patches_option));
foreach (self::$_patches as $key => $patch) {
if ($key === '_name') {
foreach (self::$_patches as $patch => $data) {
if ($patch === '_name') {
continue;
}
if (isset($patches_option[$patch])) {
continue;
}
$patches_option[$patch] = false;
$patches_option[$patch] = $data;
}
error_log("patches_option after 1: " . json_encode($patches_option));
@@ -63,11 +68,11 @@ class Fbpatch {
*
*/
error_log("patches_option before 2: " . json_encode($patches_option));
foreach ($patches_option as $key => $patch) {
if (in_array($key, self::$_patches)) {
foreach ($patches_option as $patch => $data) {
if (isset(self::$_patches[$patch])) {
continue;
}
unset($patches_option[$key]);
unset($patches_option[$patch]);
}
error_log("patches_option after 2: " . json_encode($patches_option));
@@ -81,10 +86,10 @@ class Fbpatch {
error_log("serialize patches_option: " . json_encode($serialize_patches_option));
update_option(self::$_patches['_name'], $serialize_patches_option);
}
public static function get_patchs() {
self::set_option_patchs();
public static function get_patches() {
self::set_option_patches();
$patches = get_option(self::$_patches['_name']);
return serialize($patches);
return unserialize($patches);
}
public static function set_patchs($query) {
}