Without plug-in, delete the word press management menu item through programming.

The WordPress dashboard menu is a very useful way to view and manage multiple parts of the dashboard, but sometimes it may be cumbersome or unwilling. In particular, contrary to blogs, if you use WordPress as the content management system for creating client websites, you must delete the unnecessary WordPress management menu item. One of the easiest ways to delete WordPress management menu items is to use free plug-ins, which allow users to hide management menu items according to roles or conditions. If you should not use plug-ins to delete WordPress management menu items, the disadvantage of using plug-ins to delete WordPress management menu items is that you may rely too much on third-party plug-in developers for consistent updates.
If a third-party plug-in is at risk and you don’t want to use the plug-in, but want to control the menu displayed on the word press dashboard, this tutorial is the best guide. Another reason to programmatically remove the word press management menu item is the continuous update on all word press plug-ins installed. These updates are important because they improve the user experience, performance, and security, but can be too cumbersome when dealing with a large number of client sites. If too many plug-ins are installed on multiple plug-in management menu sites, most plug-ins are provided with the management menu, and you may want to delete the menu because you have never used the management menu.
This post describes how to remove the word press menu item without using the plug-in. To do this on the WordPress site, especially the function. I need some experience editing WordPress sites to add code fragments to PHP theme files. Programmatically delete the word press management menu item. I like to start with a quick summary because it makes it easier for readers to find a quick solution in the step-by-step guide. The following steps are required to delete the word press management menu item:
Identify the administrator menu item to log in to the WordPress site and delete. Create a task hook, which is a callback function that contains the logic to delete the WordPress management menu from the dashboard and is used to connect the admin_menu event. The callback function must use the remove_menu_page or remove_subnu_page() word press function to remove each target management menu item. For example, you can use the following code to delete the component menu from the theme menu: remove_submenu_page( ‘themes.php’, ‘widgets.php’); Alternatively, use this code to delete the dashboard default menu- remove_menu_page(‘index.php’); Alternatively, you can use the unset() PHP function to access the values in the global submenu array and delete each target word press management menu item. Topic function. Add to PHP and update changes. Successfully deleted the word press management menu item without using the plug-in. You can also add this code to the function of the custom plug-in, the theme function. Just like in PHP. How to delete the word press manager menu without using plug-ins the following are the detailed steps and methods to delete the word press manager menu items by adding code instead of using other plug-ins.
The administrator menu item ID logs into the slog WordPress dashboard and confirms the management menu item to be deleted. As shown in this example, the default dashboard menu contains slug index. There is PHP. Isrug is the remove_sumbnu_p I’m going to explain
This is important because it is one of the parameters added to the age () function. Male remove page and remove submenu page function methods understand the function of removing page. The remove_menu_page function only provides one parameter as page sliding, and removes the top-level management menu. The parameter must be a string, and the general code must be:
Remove_menu_page (string; $menu_slug;) Remove sub page function when removing a sub menu, the remove_sumbnu_page function will be provided together with the first slug parameter of the parent menu and the second parameter in the slug of the sub menu to be removed. General codes must: Create a task hook to delete the remove_subnu_page (string $menu_slug, string $subnu_slug) management menu and \/ or submenu items. The following is an example of a task hook connected to the admin_menu event with a callback function \
add_action( ‘admin_menu’, ‘remove_admin_menu_items’, 999 ); If you use remove_subnu_page and remove_menu_page() to create callback functions for deleting administrator menu and \/ or submenu items, you must import a global menu array containing the global $subnu variable. Second, add the remove_subnu_page or remove_menu_page() function, as shown in the following code.
Function remove_admin_menu_items(){
Remove_subnu_page (\
}Or unset can provide the following callback functions: Male function remove_admin_menu_items (){
Global $submenu;
Unset ($subnu [\
}If you log in to the sample WordPress dashboard, you will see the update menu item under the main dashboard menu, as shown in the following figure.
Use the method described above to explain how to delete the management menu item. The first is the superior menu index. PHP, the slog in the update menu is update core. php。 Delete the parent and child menus of WordPress management menu items, so you can use the remove_menu_page() function to create task hook and callback functions to delete the entire menu item\/\/ Delete the default menu item with subpages\/ submenus
add_action( ‘admin_menu’, ‘remove_admin_menu_items’, 999 );
Function remove_admin_menu_items(){
remove_menu_page(‘index.php’);
}The full menu and submenus will be removed as follows:
Only WordPress submenu items can be deleted. As shown below, the remove_subnu_page function can be used to generate action hook and callback functions for deleting submenu items\/\/ Remove subpage or submenu
add_action( ‘admin_menu’, ‘remove_admin_menu_items’, 999 );
Function remove_admin_menu_items(){
remove_submenu_page(‘index.php’,’update-core.php’ );
}This removes the submenu specified in the second parameter of the remove_subnu_page function. In this case, \
Specify, and the result is as follows.
Use the unset() PHP function. You can also use the unset function of PHP to delete sub menu items. In this case, you must first access the global $subnu array, as shown in the following code\/\/ Add action hook to admin_menu event
add_action( ‘admin_menu’, ‘remove_admin_menu_items’, 999 );
\/\/Callback function
Function remove_admin_menu_items(){
\/\/Manage menu array – > this array contains a list of all word press manage menu items.
Global $submenu;
Print the array on the screen to view the administrator menu item by \/ \/ index.
Printed (\
Print_r ($submenu);
Printed (\
Delete all other items displayed on the screen so that only the \/ \/ administrator menu item array is displayed.
dice
}This code can import the global submenu array and print to display the array of all menus, select the index of each management menu item, and then delete it as needed. In this code, you can see that the code is displayed in a readable format using the pre tag and the die () function. Use cancel setting to delete the word press submenu item, so the array index of the update core submenu is 10. Therefore, you can use the unset() function:\/\/ Use unset to remove the default menu item with subpages.
add_action( ‘admin_menu’, ‘remove_admin_menu_items’, 999 );
Function remove_admin_menu_items(){
Global $submenu;
unset($submenu[‘index.php’][0]); \/\/ Delete the top-level index menu. PHP (dashboard menu – main menu)
unset($submenu[‘index.php’][10]); \/\/ Remove the submenu update core. PHP (menu update)
}The result is the same as using the remove_subnu_page WordPress function. You can also use disable settings to delete word press management menu items and use the unset function for each page to delete top-level pages and submenus at the same time. The code should be as follows. \/ \/. Use unset to delete the default submenu item
add_action( ‘admin_menu’, ‘remove_admin_menu_items’, 999 );
Function remove_admin_menu_items(){
Global $submenu;
unset($submenu[‘index.php’][10]);
}The result is to remove one of the non enabled pages from the code. Ending this post introduces two main methods widely, which can be used to delete word press management menu items and clean up word press dashboard. For WordPress developers, you can reuse and copy this code, easily identify my points, and see more future updates in GitHub. I also shared several different snipet – WP snippets here. You can now remove unwanted word press management items from the menu.

Author:

Leave a Reply

Your email address will not be published. Required fields are marked *