The first line of code of this recipe registers a function to be called when WordPress is building the administration menu. When it is executed, the custom function that we created makes a call to the add_options_page function to add an item to the Settings menu. This function has a number of parameters that we will look at, as follows:
add_options_page( $page_title, $menu_title, $capability,
$menu_slug, $function );
The first two parameters are text strings that will be visible to site administrators, with the first one appearing in the browser title bar or tab title, and the second being the text of the submenu item that will appear under the Settings menu.
The third parameter is a bit more complicated and refers to the user capability required to be able to see and access this menu item. When creating users in a WordPress installation, each user is assigned one of the five default user roles (Subscriber, Administrator, Editor, Author, or Contributor). Each of these roles is mapped to a number of permissions that determine the actions that users with this role can perform. For a full list of roles and their associated capabilities, please refer to the WordPress Codex page on the topic (https://codex.wordpress.org/Roles_and_Capabilities). In this example, we used the user capability manage_options, which is assigned to users who have administrative rights on the site and to super admins when working in a network WordPress installation.
The fourth menu item, menu_slug, is a text string that will be used internally by WordPress to identify the menu item. This string should be unique to avoid conflicts with other plugins.
The last parameter specifies the name of the function to be called to display the contents of the configuration page when the submenu item is clicked.
The Settings menu is a perfect location for plugins that only require a single configuration page, as you may have seen when installing other plugins, while more complex plugins that require multiple menu sections should use the technique shown in the next recipe.