While I've gotten this to work - I'm not sure I've done it the best way...
The documentation at
http://documentation.coppermine-gallery.net/en/dev_plugin_api.htm#plugin_api_tutorial_button suggests use of the plugin filter 'admin_menu' with code:
$thisplugin->add_filter('admin_menu','coffee_maker_config_button');
function coffee_maker_bar_config_button($admin_menu){
global $lang_plugin_coffee_maker, $CONFIG, $coffee_maker_icon_array;
if ($CONFIG['plugin_coffee_maker_config_link'] == 1) {
$new_button = '<div class="admin_menu admin_float"><a href="index.php?file=coffee_maker/index&action=configure"';
$new_button .= ' title="' . $lang_plugin_coffee_maker['config'] . '">';
$new_button .= $coffee_maker_icon_array['config_menu'] . $lang_plugin_coffee_maker['config'] . '</a></div>';
$look_for = '<!-- END export -->'; // This is where you determine the place in the admin menu
$admin_menu = str_replace($look_for, $look_for . $new_button, $admin_menu);
}
return $admin_menu;
}
This seems to have issues with 'newer' themes with pull down menus... not displaying properly in the pull downs (in some case next to the block)
I see other plugins using this technique - and as I move through different themes - seem to have issues...
MiniCMS uses a different approach based on plugin action page_start with code:
$thisplugin->add_action('page_start','minicms_page_start');
function minicms_add_admin_button($href,$title,$target,$link)
{
global $template_gallery_admin_menu;
$new_template=$template_gallery_admin_menu;
$button=template_extract_block($new_template,'documentation');
$params = array(
'{DOCUMENTATION_HREF}' => $href,
'{DOCUMENTATION_TITLE}' => $title,
'target="cpg_documentation"' => $target,
'{DOCUMENTATION_LNK}' => $link,
);
$new_button="<!-- BEGIN $link -->".template_eval($button,$params)."<!-- END $link -->\n";
template_extract_block($template_gallery_admin_menu,'documentation',"<!-- BEGIN documentation -->" . $button . "<!-- END documentation -->\n" . $new_button);
}
function minicms_page_start()
{
...
if (GALLERY_ADMIN_MODE) {
minicms_add_admin_button('index.php?file=minicms/cms_admin',$lang_minicms['admin_title'],'',$lang_minicms['admin_title']);
}
...
}
This seems to work in all cases I've tried... but would seem not to be the ideal (or intended??) hookpoint for this function alone (minicms does other things at page start - initializing it's processing - so may make sense for that plugin...)
I adapted this for my use (direct call to function to add button since I have no other page_start actions needed...) but thought I would ask...
What is the 'recommended' way to add an admin menu button that works with the different styles of themes??
Thanks!
Greg