6 years ago (2015-03-20)  Software development |   First to comment  27 
post score 0 times, average 0.0

The add_menu_page() function adds a management menu page to wordpress's management background.


Parameter Description:

1.$page_title (string) (required) text is the title tag of the web page displayed in the menu

Default: None

2.$menu_title (string) (required) text of the menu screen name

Default: None

3. $capability (string) (required) This menu is displayed to the user's desired ability.The user level is outdated and should not be used here!

Default: None

4.$menu_slug (string) (required) The name of the slug stream to refer to this menu (should be unique for this menu).

This was called file (or processing) parameter before version 3.If the function's parameters are omitted, this menu_slug should be the contents of the PHP file processing menu page.

Default: None

5.$function (string) (optional) Function to display the page content of the menu page.

Default: None. Technically, the parameters of the function are optional, but if it is not provided, then WordPress will assume that including the PHP file will generate a management screen without calling a function.Most plug-in authors choose to generate page code within the function's main plug-in file.If the parameter of the function is specified, it can be used for any string of file parameters.This allows use of pages such as page=my_super_plugin_page instead of ?page=my-super-plugin/admin-options.php.

This function must be referenced in one of two ways:

If the function is a plugin inside a class member it should reference the array ($this, ‘function_name’ ). In all other cases, using the name of the function itself is sufficient.

6.$icon_url (string) (optional) The URL icon can be used for this menu.

This parameter is optional.The icon should be quite small, with the best result of about 16 x 16 pixels.You can use the plugin_dir_url(__file__) function to get the URL of your plugin directory and add an image file to it.You can set $icon_url to "div" to have wordpress generate <tag> instead of <img>. This can be used for more advanced formation via CSS, such as changing the icon hover.


7.$position (integer) (optional) The location should appear in the menu command menu.

By default, if this parameter is omitted, the menu will appear at the bottom of the menu structure.The higher the value, the lower the position in the menu.Warning: If two menu items use the same location property, one item may be overwritten, so only one item is displayed!The risk of conflict can be reduced by using a decimal instead of an integer value, for example 63.3 instead of 63 (Note: use the code in quotation marks, ie "63.3").

Default: The bottom of the menu structure




Our article in this site is original or translated, except for the reprinted article, and you are welcome to reproduce it in any form. However, please be sure to indicate the source and respect others for creating a harmonious network environment. Reprint please specify: article reprinted from: ask net » add_menu_page () function details Original title: add_menu_page () function explain the original address: http://www.uedsc.com/add_menu_page.html

Post comment


No Comment


Forget password?