fixed small errors in plugin tools for options and menu

This commit is contained in:
asus
2024-04-03 12:37:04 +02:00
parent 1553490444
commit 59b9acc55e

View File

@@ -117,6 +117,8 @@ class Plgntls {
* 'add menu' init
*
*/
$option_admin_menu_name = self::$_option_toggle_menu['_name'];
self::$_option_toggle_menu['_name'] = $option_admin_menu_name . self::$_plugin_dir;
add_filter("plugin_action_links_".self::$_plugin_dir."/".self::$_main_file, function($links) {
return self::_add_link_to_plugin($links);
});
@@ -126,8 +128,8 @@ class Plgntls {
* 'handle options' init
*
*/
self::$_options_action = 'action_for_admin_post_options_'.self::$_prefix;
self::$_options_list = 'list_of_options_for_this_plugin_'.self::$_prefix;
self::$_options_action = 'action_for_admin_post_options_'.self::$_plugin_dir;
self::$_options_list = 'list_of_options_for_this_plugin_'.self::$_plugin_dir;
if (false === get_option(self::$_options_list)) {
add_option(self::$_options_list, '', '', 'no');
}
@@ -878,10 +880,11 @@ class Plgntls {
* *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
'_name'=>'toggle_admin_menu_option_cipf',
*/
const OPTION_TOGGLE_MENU = [
'_name'=>'toggle_admin_menu_option_xtxpatch',
private static $_option_toggle_menu = [
'_name'=>'toggle_admin_menu_option_',
'_default'=>'hide',
'show'=>'show',
'hide'=>'hide',
@@ -900,6 +903,8 @@ class Plgntls {
*
*/
self::init_class();
$toggle_menu = self::$_option_toggle_menu;
error_log("toggle menu: " . json_encode($toggle_menu));
if (empty($menu_options)) {
return;
@@ -953,7 +958,8 @@ class Plgntls {
}
}
private static function _toggle_menu($menu_page_title, $menu_title, $menu_capability, $menu_slug, $menu_callback) {
$toggle_menu = self::OPTION_TOGGLE_MENU;
$toggle_menu = self::$_option_toggle_menu;
error_log("toggle menu: " . json_encode($toggle_menu));
$toggle = self::get_option_safe($toggle_menu);
@@ -971,7 +977,8 @@ class Plgntls {
*
*/
private static function _add_link_to_plugin($links) {
$option_toggle = self::OPTION_TOGGLE_MENU;
$option_toggle = self::$_option_toggle_menu;
error_log("toggle menu: " . json_encode($option_toggle));
$toggle = self::get_option_safe($option_toggle);
if (false === $toggle) {
@@ -1094,6 +1101,15 @@ class Plgntls {
$ret_option = $option_unserialized;
}
/*
* if option is an array and _name is not define,
* add the _name entry to the output, to facilitate the access to the name
*
*/
if (is_array($ret_option) && !isset($ret_option['_name'])) {
$ret_option['_name'] = $option_name;
}
return $ret_option;
}