add_options_page

Add submenu page to the Settings main menu.

Description

(false|string) add_options_page( (string) $page_title, (string) $menu_title, (string) $capability, (string) $menu_slug, (string) $function = '' ); 

This function takes a capability which will be used to determine whether or not a page is included in the menu.

The function which is hooked in to handle the output of the page must check that the user has the required capability as well.

Returns (false|string)

The resulting page's hook_suffix, or false if the user does not have the capability required.

Parameters (5)

0. $page_title (string)
The text to be displayed in the title tags of the page when the menu is selected.
1. $menu_title (string)
The text to be used for the menu.
2. $capability (string)
The capability required for this menu to be displayed to the user.
3. $menu_slug (string)
The slug name to refer to this menu by (should be unique for this menu).
4. $function — Optional. (string) => ''
The function to be called to output the content for this page.

Usage

  1. if ( !function_exists( 'add_options_page' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/plugin.php'; 
  3.  
  4. // The text to be displayed in the title tags of the page when the menu is selected. 
  5. $page_title = ''; 
  6.  
  7. // The text to be used for the menu. 
  8. $menu_title = ''; 
  9.  
  10. // The capability required for this menu to be displayed to the user. 
  11. $capability = ''; 
  12.  
  13. // The slug name to refer to this menu by (should be unique for this menu). 
  14. $menu_slug = ''; 
  15.  
  16. // The function to be called to output the content for this page. 
  17. $function = ''; 
  18.  
  19. // NOTICE! Understand what this does before running. 
  20. $result = add_options_page($page_title, $menu_title, $capability, $menu_slug, $function); 
  21.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/plugin.php  
  1. function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { 
  2. return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $function );