Instead of "admin_menu", you should use "network_admin_menu" (see also Create A Network) Admin Menu Functions Network Admin Displays plugin options that are set on the Network. Settings Displays plugin options that only administrators should view (also see Creating Settings Pages). Tools Manage the export, import, and even backup of blog data. Users Displays controls for user management. Plugins Displays controls dealing with plugin management, not configuration options for a plugin itself. Appearance Displays controls for manipulation of theme/style files, sidebars, etc. Comments Controlling and regulation reader to responses to posts. Pages Displays tools for writing your static content called pages. Media Uploading and managing your pictures, videos, and audio. ![]() Posts Displays tools for writing posts (time oriented content). Use this guide of the WordPress top-level menus to determine the correct location for your sub-level menu item:ĭashboard Information central for your site and include the Updates option for updating WordPress core, plugins, and themes. Please note with the taxonomy registration, WordPress automatically creates sub-level menus under the applicable top-level menu to manage those features. For example, the Backup plugin adds a sub-level menu option to the Tools top-level menu. As a point of reference, most plugins add sub-level menu items underneath existing WordPress top-level menus. If the creation of a top-level menu is not necessary, decide under what top-level menu to place your sub-level menu item. Please note with the native post type registration, WordPress automatically creates top-level menus to manage those features. Examples of new top-level menus might include job management or conference management. Adding a top-level menu should only be considered if you really need multiple, related screens to make WordPress do something it was not originally designed to accomplish. If the plugin introduces an entirely new concept or feature to WordPress, and needs many screens to do it, then that plugin may warrant a new top-level menu. It is rare that a plugin would require the creation of a top-level menu. A sub-level menu means the menu item is a member of an existing menu. ![]() A top-level menu displays as new section in the administration menus and contains sub-level menu items. Remember to enclose the creation of the menu and the page in functions, and use the admin_menu hook to get the whole process started at the right time!īefore creating a new menu, first decide if the menu should be a top-level menu, or a sub-level menu item. These processes are described in more detail in the sections below. Finally, the add_options_page() call refers to the my_plugin_options() function which contains the actual page to be displayed (and PHP code to be processed) when someone clicks the menu item. Without that add_action() call, a PHP error for undefined function will be thrown when attempting to activate the plugin. Notice the add_action() call in Step 2 that registers the my_plugin_menu() function under the admin_menu hook. Note: more complicated multiple menu items can be added, but that will be described later. In this example, the function my_plugin_menu() adds a new item to the Settings administration menu via the add_options_page() function. Note: this code should be added to a main plugin PHP file or a separate PHP include file.Įcho 'Here is where the form would go if I actually had options.' This plugin will add a sub-level menu item under the Settings top-level menu in Administration Screens, and when selected, that menu item will cause a very basic screen to display. ![]() Here is a very simple example of the three steps just described. You cannot simply call the menu code described you must put it inside a function, and then register the function. It is that second step that is often overlooked by new developers. Create the HTML output for the page (screen) displayed when the menu item is clicked.(If you are adding an admin menu for the Network, use network_admin_menu instead). Register the above function using the admin_menu action hook.Create a function that contains the menu-building code.To add an administration menu, you must do three things: Note: the following information assumes a knowledge of the basics of Writing a Plugin and using the Plugin API of Actions and Filters. This article explains how plugin authors can add administration menus and screens. The best way to present the user with such a screen is to create an administration menu item that allows the user to access that settings screen from all the Administration Screens. Usually, plugin and theme authors need to provide access to a settings (options) screen so users can customize how the plugin or theme is used.
0 Comments
Leave a Reply. |