[wp-hackers] Re: add_menu_page icon hover

Andy Staines andy at yellowswordfish.com
Fri Dec 5 18:43:06 GMT 2008


Thanks Ozh
I didn't miss anything then. Just for the life of me I can't get that CSS to
do it's stuff. I'll give it another whirl.
Andy


On 05/12/2008 18:34PM, "Ozh" <ozh at planetozh.com> wrote:

> 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




More information about the wp-hackers mailing list