Wordpress Plugin Admin Tab

时间:2013-07-23 作者:Bradly Spicer

我不确定这个术语,因为谷歌搜索并没有真正把我带向正确的方向。

我目前有一个WordPress插件,它位于设置选项卡内。

我想有我自己的标签,下面有3个子部分。

我试过看这些:

add_action(\'admin_menu\', \'jobboard_admin_actions\');
function jobboard_admin_actions() {
add_options_page(\'JobBoard\', \'JobBoard\', \'manage_options\', __FILE__, \'JobBoard_admin\');
}
但我还是被卡住了。

谢谢

更改:

add_action(\'admin_menu\', \'jobboard_admin_actions\');
function jobboard_admin_actions() {
add_menu_page(\'JobBoard\', \'JobBoard\', \'manage_options\', JobBoard_admin,  \'JobBoard_admin\', \'\');
add_submenu_page( \'JobBoard_admin\', \'JobBoard\', \'JobBoard\', \'manage_options\',    \'JobBoard_admin\', \'JobBoard_admin_delete\' ); 

}

1 个回复
最合适的回答,由SO网友:Marin Bînzari 整理而成

以下是我用过的东西:

add_action( \'admin_menu\', \'manage_poll_menu\' );
function manage_poll_menu() {
    add_menu_page( \'Manage Polls\', \'Polls\', \'manage_polls_cap\', \'manage_polls\', \'my_poll_options\', \'\' );
    add_submenu_page( \'manage_polls\', \'Add New\', \'Add New Poll\', \'manage_polls_cap\', \'add_new_poll\', \'my_poll_options\' );
    add_submenu_page( \'manage_polls\', \'Poll Sections\', \'Poll Sections\', \'manage_polls_cap\', \'poll_sections\', \'my_poll_options\' );
    add_submenu_page( \'manage_polls\', \'Add New Poll Section\', \'Add New Poll Section\', \'manage_polls_cap\', \'add_new_poll_section\', \'my_poll_options\' );
}
function my_poll_options() {
    if ( !current_user_can( \'manage_polls_cap\' ) )  {
        wp_die( __( \'You do not have sufficient permissions to access this page.\' ) );
    }

    echo \'<div class="wrap">Page content</div>\';
}
还有关于Administration MenusSubmenu Pages 您可以在上找到here.

结束

相关推荐

!is_admin()条件在管理页面中变为True

我需要用户重定向到登录,如果没有登录,一旦他们是,重定向到后端,如果他们试图看到前端页面。这是我的代码:add_action( \'template_redirect\', function () { if(is_user_logged_in() ): bk1_debug(\'logged in\'); if (!is_admin()): bk1_debug(\'not in admin, redirectin