updated options to make them not automatically loaded when added

This commit is contained in:
asus
2024-03-25 15:16:19 +01:00
parent 6ec621a20b
commit 4036f4300d
10 changed files with 168 additions and 44 deletions

View File

@@ -16,7 +16,7 @@ function toggle_menu($menu_page_title, $menu_title, $menu_capability, $menu_slug
$toggle_menu = Fbpatch::OPTION_TOGGLE_MENU;
if (false === get_option($toggle_menu['_name'])) {
add_option($toggle_menu['_name'], $toggle_menu['hide']);
add_option($toggle_menu['_name'], $toggle_menu['hide'], '', 'no');
}
$toggle = get_option($toggle_menu['_name']);

View File

@@ -28,7 +28,15 @@ function plugin_content() {
/*
* use this hook 'admin_post_{$action}' to receive a form post
* https://developer.wordpress.org/reference/hooks/admin_post_action/
*
* add the url to the action atrtibute of form, and the value of the action in an hidden input
* <form method="POST" action="<?php echo admin_url( 'admin-post.php' ); ?>">
* <input type="hidden" name="action" value="<?php echo $admin_post_patches; ?>">
*
*/
function patches_choice() {
$nonce = Fbpatch::NONCE;
if (!isset($_POST[$nonce['_name']])) {
@@ -43,12 +51,12 @@ function patches_choice() {
/*
*
*
[24-Mar-2024 12:24:08 UTC] -> _POST {
"action":"add_patches",
"nonce_name":"7eeb560dc0",
"_wp_http_referer":"\/wp-admin\/admin.php?page=fbpatch-plugin",
"hide_show":"on"
}
[24-Mar-2024 12:24:08 UTC] -> _POST {
"action":"add_patches",
"nonce_name":"7eeb560dc0",
"_wp_http_referer":"\/wp-admin\/admin.php?page=fbpatch-plugin",
"hide_show":"on"
}
*/
$pathes_on = array();
foreach($_POST as $key => $value) {