I am working my way through the plug-in tutorial and am having trouble getting the adding a button to the admin menu and adding a button to the system menu ones to work. What happens is that they install but don't alter the display (ie. no additional buttons are displayed).
Here is the code I have for the system menu example, it is as written except that it seems a language file is needed.
configuration.php
<?php
/*************************
Coppermine Plugin - A test Plugin
************************
Copyright (c) 2011
************************
v1.0 originally written by Gregory Demar
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3
as published by the Free Software Foundation.
********************************************/
$name='button sys';
$description = 'add a button to sys menu';
$author = 'example';
$version = '1.0';
$plugin_cpg_version = array('min' => '1.5');
?>
codebase.php
<?php
/**************************************************
Coppermine Plugin - Button Sys
*************************************************
Copyright (c) 20011 Example Plugin
*************************************************
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3
as published by the Free Software Foundation.
***************************************************/
require_once "./plugins/buttonSys/initialize.inc.php";
if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');
// Add install & configure actions
$thisplugin->add_filter('sys_menu','coffee_maker_sys_button');
// Add a filter for the admin_menu
function coffee_maker_bar_sys_button($menu) {
global $lang_plugin_coffee_maker, $template_sys_menu_spacer, $CONFIG;
if ($CONFIG['plugin_coffee_maker_how'] == 4) {
coffee_maker_bar_language(); // Call the function that populates the language variable
$new_button = array();
$new_button[0][0] = $lang_plugin_coffee_maker['picinfo_heading'];
$new_button[0][1] = $lang_plugin_coffee_maker['menu'];
$new_button[0][2] = 'index.php?file=coffee_maker/index';
$new_button[0][3] = 'coffee_maker';
$new_button[0][4] = $template_sys_menu_spacer;
$new_button[0][5] = 'rel="nofollow"';
array_splice($menu, count($menu)-1, 0, $new_button);
}
return $menu;
}
?>
lang/english.php
<?php
$lang_plugin_coffee_maker['plugin_name'] = 'Coffee Maker';
$lang_plugin_coffee_maker['plugin_description'] = 'This plugin will turn your gallery into a full-featured coffee machine.';
$lang_plugin_coffee_maker['coffee_bean'] = 'coffee bean';
$lang_plugin_coffee_maker['brew'] = 'brew';
$lang_plugin_coffee_maker['picinfo_heading']='testing1';
$lang_plugin_coffee_maker['menu']='testing2';
?>
initialize.inc.php
<?php
function coffee_maker_language() {
global $CONFIG, $lang_plugin_coffee_maker;
require "./plugins/buttonSys/lang/english.php";
if ($CONFIG['lang'] != 'english' && file_exists("./plugins/coffee_maker/lang/{$CONFIG['lang']}.php")) {
require "./plugins/buttonSys/lang/{$CONFIG['lang']}.php";
}
}
?>
I am not sure if the example is meant as a complete example that should display a button or if other code is needed. It would be extremely instructive if I could get the example working. I only added the language file since it seemed necessary to support the variables. I wonder if there is a complete example of this coffee maker plugin if it is not complete.
I also noticed in code that the add_filter command references coffee_maker_sys_button but the function is named coffee_maker_bar_sys_button. Is a coffee_maker_sys_button function needed?
Hope this makes some sense, I appreciate any help.