[wp-hackers] add_menu_page, icon, dynamic menu, css and plugin

andré renaut andre.renaut at gmail.com
Mon Dec 8 14:29:26 GMT 2008


Hi there !

How to solve this ?

I am using a main menu (add_menu_page) in my plugin.
In add_menu_page parms, instead of the icon menu url, i put 'div' to manage
the icon thru css.
The css displaying the icon is this :

#adminmenu #toplevel_page_mailpress_mails div.wp-menu-image {
    background:transparent url(../images/menu.png) no-repeat scroll -1px
-33px;
}
#adminmenu #toplevel_page_mailpress_mails:hover div.wp-menu-image,
#adminmenu #toplevel_page_mailpress_mails.wp-has-current-submenu
div.wp-menu-image,
#adminmenu #toplevel_page_mailpress_mails.current div.wp-menu-image {
    background:transparent url(../images/menu.png) no-repeat scroll -1px
-1px;
}

I have also implemented roles and capabilities wp facilities in my plugin.

My main menu is now completely dynamic, meaning that the toplevel page can
be any of the pages available inside my plugin !

The issue i am facing right now is about displaying the icon of my main menu
(that shouldnot changed) (still with 'div' in add_menu_page).

Apparently, the only way to identify the right div is to rely on the
$hookname (get_plugin_page_hookname) ("#toplevel_page_mailpress_mails" in
css above).

The issue i am facing right now is

* do i have to declare all the pages available in my plugin in the css ?

* could it be possible to have a class such as .toplevel_plugin_(name of the
plugin)_menu_image instead of wp-menu-image ?

Thanks for your answers.

Arena


More information about the wp-hackers mailing list