[wp-hackers] Admin menu hook
Ryan Boren
ryan at boren.nu
Sat Dec 4 05:07:06 UTC 2004
> I tried this:
>
> add_submenu_page(__("test.php"), __("Test"),
> __('Edit'), 5, '../wp-content/plugins/test/php');
>
> but it doesn't work. If I replace "plugins" with
> "plugin", it does. This seems odd to me...?
Try this:
<?php
/*
Plugin Name: Menu Test
Plugin URI: http://nowhere.null/
Description: Menu Test
Author: Nobody
Author URI: http://nobody.null/
*/
if (! function_exists('mt_add_menu_page')) {
function mt_add_menu_page() {
add_menu_page(__("Menu Test"), __('Menu Test'), 5, __FILE__);
}
}
if (! function_exists('mt_add_submenu_page')) {
function mt_add_submenu_page() {
// Submenu that refers back to the parent.
add_submenu_page(__FILE__, __("Menu Test"), __('Menu 1'), 5,
__FILE__);
// Submenu pointing to another file.
add_submenu_page(__FILE__, __("SubMenu Test"), __('Menu 2'), 5,
dirname(__FILE__) . '/submenu.php');
}
}
if (is_plugin_page()) :
echo "<h1>Menu Test</h1>";
endif;
add_action('admin_menu', 'mt_add_menu_page');
add_action('admin_menu', 'mt_add_submenu_page');
?>
More information about the hackers
mailing list