[英]WordPress : Nested Submenu in Admin
如何在WordPress管理面板中嵌套嵌套子菜单。
就像在Plugins子菜单中,我要让我的插件说“ CC”,然后我要显示其子菜单letay。 “ CC历史记录”,“ CC关于我”
我没有线索,所以任何帮助将不胜感激谢谢
尝试这个
/** Step 2 (from text above). */
add_action( 'admin_menu', 'my_plugin_menu' );
/** Step 1. */
function my_plugin_menu() {
add_options_page( 'My Plugin Options', 'My Plugin', 'manage_options', 'my-unique-identifier', 'my_plugin_options' );
}
/** Step 3. */
function my_plugin_options() {
if ( !current_user_can( 'manage_options' ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
}
echo '<div class="wrap">';
echo '<p>Here is where the form would go if I actually had options.</p>';
echo '</div>';
}
Try this,
This will create your plugin menu appear at the wordpress admin menu levels.
//Call hook admin_menu to add plugin menu in WP admin section
add_action('admin_menu', 'register_my_menu_page');
//Main function to populate plugin menus
function register_my_menu_page() {
add_menu_page('Employee Register', 'Attendance', 'manage_options', 'at-main-menu', 'AtShowReport');
add_submenu_page("at-main-menu", "Emp-timeoff-mast", "Report", 1, "at-main-menu", "fucntion_name");
add_submenu_page("at-main-menu", "Manage Employees", "Manage Employees", 1, "manage-emp", "fucntion_name");
add_submenu_page("at-main-menu", "Register Employee off time", "Register Time off", 1, "emp-reg-off-time", "fucntion_name");
add_submenu_page("at-main-menu", "Employee status", "Status", 1, "emp-status", "fucntion_name");
add_submenu_page("at-main-menu", "Holidays", "Holidays", 1, "emp-holiday", "fucntion_name");
}
function_name is the name of the fucntion that get executed when the menu is clicked
Refer following link to get better understanding of these functions.
https://codex.wordpress.org/Plugin_API/Action_Reference/admin_menu
https://codex.wordpress.org/Function_Reference/add_menu_page
https://codex.wordpress.org/Function_Reference/add_submenu_page
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.