wip patchs appears with informations, but are not yet updated
This commit is contained in:
0
plugins/fbpatch/css/menu.css
Normal file
0
plugins/fbpatch/css/menu.css
Normal file
@@ -1,21 +1,24 @@
|
||||
<!--
|
||||
|
||||
{"hide_show":false,"calculations":false}
|
||||
{"calculations":false,"hide_show":false}
|
||||
|
||||
-->
|
||||
|
||||
<style>
|
||||
.patches_wrapper {
|
||||
margin: 20px 5px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- https://developer.wordpress.org/reference/hooks/admin_post_action/ -->
|
||||
<form method="POST" action="<?php echo admin_url( 'admin-post.php' ); ?>">
|
||||
<input type="hidden" name="action" value="<?php echo $admin_post_patches; ?>">
|
||||
<?php wp_nonce_field($nonce['_action'], $nonce['_name']); ?>
|
||||
<div>
|
||||
<input type="checkbox" id="calculation_patch" name="calculation" checked />
|
||||
<label for="calculation_patch">calculation patch</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" id="hide_show_elements" name="hide_show" />
|
||||
<label for="hide_show_elements">hide/show elements</label>
|
||||
</div>
|
||||
<?php foreach($patches as $patch => $options) {?>
|
||||
<div class="patches_wrapper">
|
||||
<input type="checkbox" id="<?php echo $patch; ?>" name="<?php echo $patch; ?>" <?php echo $options['checked'] === true ? "checked" : "" ?> />
|
||||
<label for="<?php echo $patch; ?>"><b><?php echo $options['title']; ?> : </b><?php echo $options['description']; ?></label>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<input type="submit" value="send"/>
|
||||
</form>
|
||||
|
||||
@@ -16,7 +16,8 @@ if (!defined('ABSPATH')) {
|
||||
*
|
||||
*/
|
||||
function plugin_content() {
|
||||
$patches = Fbpatch::get_patchs();
|
||||
$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();
|
||||
|
||||
@@ -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) {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user