02 април, 2015

Duplicate submenu item in WordPress custom admin menu.

Hi Blogger, long time no see.

Just as a reminder for myself and anyone else searching for the solution of
"how to hide the first submenu of my plugin menu on WordPress":

I read through many articles on stackoverflow and elsewhere about this issue, dated back from 2012 or even 2009, all pointing to the same solution: make the first add_submenu_page $menu_slug the same as the one in add_menu_page (and respectively the same as its own $parent_slug).

Of course this solution does not work anymore (or at least don't work with WordPress 4.1.1).

But I found this post, also dated back from 2012
https://wordpress.org/support/topic/add-menu-page-without-submenu?replies=4
And there is a different suggestion, from apimlott: to use a non-existing capability like this
add_menu_page( "Myplugin", "Myplugin", "nosuchcapability", "Myplugin");
and leave the capability check do it's magic.

And it this works for 4.1.1, yay!

Няма коментари: