在您的插件中添加子菜单页面

时间:2014-12-28 作者:user3193259

这就是我添加菜单并尝试添加未添加的子菜单页面的方式。

party-reservation.php

function a_qoute_admin_action()
{
    add_menu_page(__(\'Reservations Pages\'), __(\'Donation\'), \'edit_themes\', \'a-qoute\', \'qoute_settings\', \'\'); // working
    add_submenu_page("party-reservation.php", "Donations Log", "Donations Log", 8, "DonationsLog", "Donations_Log"); // not working.

}
add_action(\'admin_menu\', \'a_qoute_admin_action\');
如果我使用“主题”。php’它在外观部分添加了一个子菜单页。

1 个回复
最合适的回答,由SO网友:Bainternet 整理而成

这个add_submenu_page 第一个参数应该是顶部菜单页面句柄,在您的情况下是a-qoute 因此:

function a_qoute_admin_action(){
    add_menu_page(
        __(\'Reservations Pages\'),// the page title
        __(\'Donation\'),//menu title
        \'edit_themes\',//capability 
        \'a-qoute\',//menu slug/handle this is what you need!!!
        \'qoute_settings\',//callback function
        \'\',//icon_url,
        \'\'//position
    );
    add_submenu_page(
        \'a-qoute\',
        \'Donations Log\', //page title
        \'Donations Log\', //menu title
        \'edit_themes\', //capability,
        \'DonationsLog\',//menu slug
        \'Donations_Log\' //callback function
    );
}
add_action(\'admin_menu\', \'a_qoute_admin_action\');

结束