add menu page and sub menu page wordpress plugin
add menu page and sub menu page
=========================================================================
add_menu_page( string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = '', string $icon_url = '', int $position = null )
add_submenu_page( string $parent_slug, string $page_title, string $menu_title, string $capability, string $menu_slug, callable $function = '', int $position = null )
...........
function custom_plugin(){
add_menu_page( //for menu
'customplugin',
'Custom Plugin',
'manage_options',
'custom-plugin',
'custom_plugin_function',
'dashicons-admin-site-alt2',
2
);
add_submenu_page( //for sub menu
'custom-plugin',
'Add New',
'Add New',
'manage_options',
'add-new',
'add_new_function'
);
add_submenu_page( //for sub menu
'custom-plugin',
'All Pages',
'All Pages',
'manage_options',
'all-pages',
'add_new_function2'
);
}
add_action('admin_menu', 'custom_plugin');
function custom_plugin_function(){ //for menu
echo "<h1>Hello, Zakir BD</h1>";
}
function add_new_function(){ //for sub menu
echo "<h1>Hello submenu</h1>";
}
function add_new_function2(){ //for sub menu
echo "<h1>Hello all pages</h1>";
}
........................................................................
No comments