The wonderful Admin Drop Down Menu comes with a cool set of hooks that will allow plugin coders to hack everything to death.
Add you own plugin icon
All the plugin have, by default, a cute green plugin icon. But your plugin is special, right? It deserves its own icon!

Your plugin will need the following :
-
// Add a page like usual
-
add_options_page('My Plugin Settings', 'My Plugin', 10, 'myplugin', 'myplugin_do_admin_page');
-
-
// Add a cool icon
-
add_filter('ozh_adminmenu_icon', 'myplugin_icon');
-
function myplugin_icon($hook) {
-
if ($hook == 'myplugin') return 'http://path/to/icon.png';
-
return $hook;
-
}
And that's all.
If you're using __FILE__ as a page name (yuck, dude, I mean, wtf), your code should look like this:
-
// Add a page like usual, but with an ugly name
-
add_options_page('My Plugin Settings', 'My Plugin', 10, __FILE__, 'myplugin_do_admin_page');
-
-
// Add a cool icon
-
add_filter('ozh_adminmenu_icon', 'myplugin_icon');
-
function myplugin_icon($hook) {
-
if ( $hook == plugin_basename(__FILE__) ) return 'http://path/to/icon.png';
-
return $hook;
-
}
Modify the menu itself
Third party plugins can modify the menu or its entries, with the help of the almighty add_filter() function. Note: I'm not providing any help on this, as it implies you know what you're doing, how you'll do it, and why you need to do it.
The main functions of the plugin are:
- wp_ozh_adminmenu_build(): builds an array of all links and their anchors, class, icon, etc...
- wp_ozh_adminmenu(): uses this array to actually generate all the HTML mayhem that makes the menu itself.
If your plugin needs to modify menu entries, you'll find in wp_ozh_adminmenu_build() various filters to do so, this means you'll write stuff like:
-
add_filter('pre_ozh_adminmenu_menu', 'myplugin_modify');
-
add_filter('ozh_adminmenu_menu', 'myplugin_hack');
-
add_filter('pre_ozh_adminmenu_altmenu', 'myplugin_break');
-
add_filter('ozh_adminmenu_altmenu', 'myplugin_scramble');
Read the source of wp_ozh_adminmenu_build(), add various debugging print_r() everywhere and you'll manage your way :)
pingback on 21/Aug/08 at 8:58 pm # :
[...] Update: I've update the plugin doc and added a page for plugin coders. [...]
replied, on 22/Aug/08 at 4:22 pm # :
Wow man, this is simply amazing...wondering if it can get any better than this!!! :).
Jokes apart awesome work man!
pingback on 22/Aug/08 at 4:42 pm # :
[...] the last update there are now not only cool icons in the drop down menu but Ozh has also provided a Plugin API for other wordpress plugin developers to be able to do very neat [...]