Declare that menus will exist
add_action('admin_menu', array(&$this, 'add_pages')); // Indicate that there are menu items |
function add_pages() { add_options_page(__('Library Events', 'lib_events'), __('Library Events', 'lib_events'), 'manage_options', __FILE__, array(&$this, 'option_page')); // Add to lower Settings menu } |
add_menu_page(page_title, menu_title, access_level/capability, file, [function], [icon_url]); |
page_title | Text displayed as the page title |
menu_title | Menu label |
access_level/capability | The minimum user level to display and use the feature |
file | The PHP file that displays the page |
function | Optional - Called if present |
icon_url | Optional - Uses the associated icon (image) in the menu |
add_submenu_page(parent, page_title, menu_title, access_level/capability, file/ID, [function]); |
parent | Filename of the associated main menus |
page_title | Text displayed as the page title
Ignored on pages under a custom top level menu |
menu_title | Menu label |
access_level/capability | The minimum user level to display and use the feature |
file/ID | The PHP file that displays the page
If you create a custom top level menu, this MUST be a unique ID, otherwise, clicking any sub-menu all cause all items to execute |
function | Optional - Called if present
Required if you create a custom top level menu |
icon_url | Optional - Uses the associated icon (image) in the menu |
add_options_page(page_title, menu_title, access_level/capability, file, [function]); add_management_page(page_title, menu_title, access_level/capability, file, [function]); add_theme_page(page_title, menu_title, access_level/capability, file, [function]); |
Menu | WP Help | Filename | Shortcut |
---|---|---|---|
Posts | Manage | add_submenu_page('edit.php',...) | add_posts_page(...) |
Media | add_submenu_page('upload.php',...) | add_media_page(...) | |
Links | add_submenu_page('link-manager.php',...) | add_links_page(...) | |
Pages | add_submenu_page('edit-pages.php',...) | add_pages_page(...) | |
Comments | Comments | add_submenu_page('edit-comments.php',...) | add_comments_page(...) |
Appearance | Design | add_submenu_page('themes.php',...) | add_theme_page(...) |
Plugins | Plugins | add_submenu_page('plugins.php',...) | |
Users | Users | add_submenu_page('users.php',...) | add_users_page(...) |
Your Profile | add_submenu_page('profile.php',...) | add_users_page(...) | |
Tools | add_submenu_page('tools.php',...) | add_management_page(...) | |
Settings | Settings | add_submenu_page('options-general.php',...) | add_options_page(...) |
Posts/Add New | Write | add_submenu_page('post-new.php',...) | |
Dashboard | add_submenu_page('index.php',...) | add_dashboard_page(...) |
By default, the first sub-menu will have the same label as the top level selection. To change it, create the first sub-menu with the same ID and function as the top level - the menu_title string will be displayed.
Function names
'function_name' | Use this for global functions |
array(&$this, 'class_member_name')
Use this for class members
| |
'xyz.php' | This should work, but probably needs a path |
__FILE__
I use this
| |
There are 5 roles and 40 capabilities.
When creating a user, only one of the 5 roles can be set. Same when editing the user profile.
Yet, when browsing the database, some individual capabilities are defined. There is no indication how this is done.
The functions to add and remove capabilities exist in
wp-includes/capabilities.php |
This is a code example
if(get_user_option('rich_editing') == 'true') { add_filter("mce_external_plugins", array(&$this, "mm_forms_tinymce_addplugin"), 11); add_filter('mce_buttons', array(&$this, 'mm_forms_tinymce_registerbutton'), 11); } |
When your page is displayed
function myplugin_setup_options(){ $plugin_page=add_options_page( ... ); // see details above add_action( 'admin_head-'. $plugin_page, 'myplugin_admin_header' ); } function myplugin_admin_header(){ echo '<p>Only executes when the myplugin options page is displayed.</p>'; } |
do_action('admin_enqueue_scripts', $hook_suffix); do_action("admin_print_styles-$hook_suffix"); do_action('admin_print_styles'); do_action("admin_print_scripts-$hook_suffix"); do_action('admin_print_scripts'); do_action("admin_head-$hook_suffix"); do_action('admin_head'); |