[Bb-trac] Re: [bbPress] #623: Need a hook to extend the admin menu
bbPress
bb-trac at lists.bbpress.org
Sat Mar 31 06:20:07 GMT 2007
#623: Need a hook to extend the admin menu
-------------------------+--------------------------------------------------
Reporter: Null | Owner: sambauers
Type: enhancement | Status: new
Priority: normal | Milestone: 1.0
Component: integration | Version: 0.8.1
Severity: normal | Resolution:
Keywords: has-patch |
-------------------------+--------------------------------------------------
Changes (by sambauers):
* keywords: => has-patch
Comment:
Attached patch implements two simple new functions.
bb_admin_add_menu()
bb_admin_add_submenu()
To add a single submenu to the "Site management" menu just use this in
your plugin:
{{{
add_action( 'bb_admin_menu_generator', 'myplugin_add_admin_page' );
function myplugin_add_admin_page() {
bb_admin_add_submenu(__('My plugin'), 'use_keys', 'myplugin');
}
}}}
...of course you should change "myplugin" to something relevant.
To do the same with backward compatibility to bbPress 0.8:
{{{
add_action( 'bb_admin_menu_generator', 'myplugin_add_admin_page' );
function myplugin_add_admin_page() {
if (function_exists('bb_admin_add_submenu')) {
bb_admin_add_submenu(__('My plugin'), 'use_keys',
'myplugin_admin_page');
} else {
global $bb_submenu;
$bb_submenu['site.php'][] = array(__('My plugin'),
'use_keys', 'myplugin_admin_page');
}
}
}}}
To add a whole new menu item:
{{{
add_action( 'bb_admin_menu_generator', 'myplugin_add_admin_page' );
function myplugin_add_admin_page() {
bb_admin_add_menu(__('My plugin'), 'use_keys', 'myplugin');
bb_admin_add_submenu(__('My plugin sub menu item one'),
'use_keys', 'myplugin', 'myplugin');
}
}}}
... if you don't specify at least one submenu in your new menu item, the
navigation will not display your location properly.
Adding multiple submenu items to a new menu is a logical extension of the
above:
{{{
add_action( 'bb_admin_menu_generator', 'myplugin_add_admin_page' );
function myplugin_add_admin_page() {
bb_admin_add_menu(__('My plugin'), 'use_keys', 'myplugin');
bb_admin_add_submenu(__('My plugin sub menu item one'),
'use_keys', 'myplugin', 'myplugin');
bb_admin_add_submenu(__('My plugin sub menu item two'),
'use_keys', 'myplugin_two', 'myplugin');
bb_admin_add_submenu(__('My plugin sub menu item three'),
'use_keys', 'myplugin_three', 'myplugin');
bb_admin_add_submenu(__('My plugin sub menu item four'),
'use_keys', 'myplugin_four', 'myplugin');
}
}}}
--
Ticket URL: <http://trac.bbpress.org/ticket/623#comment:10>
bbPress <http://bbpress.org/>
Innovative forum development
More information about the Bb-trac
mailing list