WordPress:管理员

时间:2015-07-02 09:16:47

标签: php wordpress-plugin wordpress

如何在WordPress管理面板中嵌套嵌套子菜单。

就像,在插件子菜单中,我想让我的插件让我们说“CC' ,然后我想显示它的子菜单letay。 ' CC历史' ,' CC关于我'

我没有任何线索,所以任何帮助都将不胜感激 感谢

2 个答案:

答案 0 :(得分:0)

试试这个

/** 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>';
}

答案 1 :(得分:0)

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