[wp-hackers] Re: add_menu_page icon hover

Ozh ozh at planetozh.com
Fri Dec 5 18:34:02 GMT 2008


On Fri, Dec 5, 2008 at 6:14 PM, Andy Staines <andy at yellowswordfish.com> wrote:
> Perhaps I am missing the obvious but can anyone expand on this please?
> Andy
>
> On 27/11/2008 12:56PM, "andré renaut" <andre.renaut at gmail.com> wrote:
>> found it, just put 'div' instead of icon url in "add_menu_page", everything
> is
>> handle with css now !!!

from menu-header.php:
if ( 'div' === $item[6] )
   $img = '<div class="wp-menu-image"><br /></div>';
else
   $img = '<img class="wp-menu-image" src="' . $item[6] . '" alt="" />';

So, either you're passing a full img src and it outputs a regular
<img>, or you're passing 'div' and it outputs the <div> shown on line
2 of the snippet.

Example:
add_menu_page('page_title', 'menu_title', 'manage_options', 'blah',
'some_function', 'div');

This will add:
<li id="toplevel_page_blah" class="[various classes...]">
<div class="wp-menu-image"><br/></div>
[the link and stuff to the page...]
</li>

So you can style with something like:
#toplevel_page_blah div.wp-menu-image {
  background:transparent url(full url to icon);
}

In other words: mostly complicated compared to the regular & simple:
add_menu_page('page_title', 'menu_title', 'manage_options', 'blah',
'some_function', [full url to icon]);


Ozh
-- 
http://planetOzh.com ~ Blog and WordPress Stuff
http://FrenchFragFactory.net ~ Daily Quake News


More information about the wp-hackers mailing list