Closed JanThiel closed 3 years ago
Hi Jan! Thank you to pointing out this curious behaviour. Currently it's more a bug than an improvement : a menu that contains 0 item should not be displayed... And yes, I've forgotten this very case :(
Would you find it better if this menu disappeared automatically, if you had the possibility to do it by yourself or both?
Personally, I would definitely vote for both.
An empty menu is bad ux, so it shouldn't be visible.
Yet there might be cases where the menu is not empty but there is a need to remove it. So I would suggest to also add the lowest possible priority to the admin_menu action calls instead of max int. Then everything works the "WordPress way" again :-). If you added the max int for a certain reason, let's brainstorm. Currently I don't see any reasonable need for that. Yet I do not have a full overview of the POO Suite Plugins as you do :-)
Have a great Sunday night!
Hi Jan!
Hiding of the main menu (when empty) is fixed (will be in 3.2).
For the custom management of the visibility, I was wondering if it would be better to provide filters like poo_hide_main_menu
, poo_hide_analytics_menu
and so on... What do you think about it?
Thanks alot!
Providing individual filters would be the "silver standard" in my opinion. That's much more comfortable than searching for the menu slugs to remove them manually. Another option I saw in other plugins (WP-ROCKET for example) are capabilities. The menus would then render based on the caps of the user. The benefit of this would be a real customizable access control. Just hiding the menu still allows to access the function if you "know" / craft the URL and are allowed to access it in general. So the capabilities way is what you really want - and the gold standard ;-). The menu filter is the quick way to go :-)
Hi Jan! Here what I will do: I will first implement individual filters (will be in 3.2 / ETA before Sept. 7th) and see how it is used. If the need arises, I will implement it afterwards via capabilities (which seems a little bit "overkill" for now). Thanks for the suggestion and discussion, Jan. It really helps :)
Hi Jan!
The new 3.2.0 version (available on wp.org for about 15 minutes) adds hooks to hide menus.
You can hide the main menu via the poo_hide_main_menu
filter or each submenu via the poo_hide_analytics_menu
, poo_hide_consoles_menu
, poo_hide_insights_menu
, poo_hide_tools_menu
, poo_hide_records_menu
and poo_hide_settings_menu
filters.
I'm closing this issue as I think it will do the job. Don't hesitate to reopen it if not...
Thanks for your help/suggestion in this solution.
Is your feature request related to a problem? Please describe. Currently the menu pages are created at
PHP_INT_MAX
andPHP_INT_MAX -1
in thefinalize
method. This makes it virtually impossible to remove the pages using own code. We want to remove the Dashboard (perfopsone-dashboard
) for non Super Admins in Multisite, as we do not want "Site owners" = Single Admins to access POO / Decalog in any way. In addition to that, with our current settings, the Menu page is simply empty for single site admins. There is just the top level entry, but no submenu entries.This is the relevant code: https://github.com/Pierre-Lannoy/wp-decalog/blob/adc7bd2adcc6dfc7f6a232e3d121d6a53a1f5881/includes/plugin/class-core.php#L111-L113
Describe the solution you'd like Decrease the priority to reasonable values. Set it as high as necessary, but as low as possible (like
100
,200
, etc. ?). With this, one could remove the pages usingadmin_menu
with a higher priority.Describe alternatives you've considered Add a filter to disable the POO Dashboard. Currently the Top Level entry is always created and there is no way to disable this. A filter here would be also a possible solution: https://github.com/Pierre-Lannoy/wp-decalog/blob/adc7bd2adcc6dfc7f6a232e3d121d6a53a1f5881/perfopsone/class-menus.php#L130
Additional context View for Single Site Admin:![image](https://user-images.githubusercontent.com/3857275/131250172-6384961d-184c-4173-ae3a-0336e03a6e5c.png)