[wp-hackers] Admin menu hook

Ryan Boren ryan at boren.nu
Sun Nov 28 00:50:47 UTC 2004


Plugins can now be loaded from subdirectories of wp-content/plugins.  If
your plugin requires multiple files, everything can now be packaged in
one directory.  Your includes will be relative to the plugin directory.
Adding admin pages automatically takes into account the directory
structure if you use __FILE__.

Here's how a plugin file can add itself to the options submenu.

add_options_page(__("Test Page"), __('Test'), 5, __FILE__);

Here's how the plugin file can add another file residing in the plugin
file's directory to the options submenu.

add_options_page(__("Test Page"), __('Test'), 5, dirname(__FILE__) .
'testpage.php');

Doing this plus using relative includes allows the plugin and all of its
files to be installed directly into plugins/ or into a subdirectory of
plugins.  The name of the subdirectory doesn't matter.

There are also some new admin menu hooks.

add_menu_page() -- Add to the top level menu.
add_submenu_page() -- Add to a submenu.
add_options_page() -- Add to the Options submenu.
add_management_page() -- Add to the Manage submenu.

Ryan




More information about the hackers mailing list