That’s an interesting question. I think it’s theoretically possible, but there’s only a very small window where you can remove a menu item like that before the admin menu is rendered and it’s too late to change it.
At the moment, AME replaces the default WordPress admin menu with its custom menu configuration using the parent_file
filter with priority 1001
. If you want to modify the menu before it’s displayed, you would need to use the same filter and a later priority, like 1020
. At that point, functions like remove_menu_page()
should probably work. Remember to return the filter argument unchanged to avoid introducing unexpected bugs.
As for what arguments to pass to the functions: for custom menu items with custom URLs, the “slug” will be the same as the URL. Or, if an item links to an existing menu item (using the “Target page” dropdown), the slug will be the same as the slug of the target.
-
This reply was modified 1 year, 4 months ago by Janis Elsts. Reason: fix grammar