[wp-trac] [WordPress Trac] #61177: WordPress admin menu cannot cater for hundreds of menu items
WordPress Trac
noreply at wordpress.org
Fri Aug 16 20:13:25 UTC 2024
#61177: WordPress admin menu cannot cater for hundreds of menu items
----------------------------+------------------------------
Reporter: tvejacques | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Administration | Version: 6.5.3
Severity: normal | Resolution:
Keywords: dev-feedback | Focuses: ui
----------------------------+------------------------------
Comment (by dotrex):
Here is a code snippet that we can use to quickly reproduce this issue. It
will add 100 sub-items to the Tools menu in WP dashboard:
{{{#!php
<?php
/*
* Adds 200 custom submenus to the Tools menu in the WordPress dashboard
menu
* it can be used to reproduce this issue:
https://core.trac.wordpress.org/ticket/61177
*/
function add_custom_submenus() {
// Loop to add 100 sub-items
for ($i = 1; $i <= 100; $i++) {
add_submenu_page(
'tools.php', // dded to tools, but you can use any page here
"Custom Tool $i", // Page title
"Custom Tool $i", // Menu title
'manage_options', // Capability
"custom-tool-$i", // Menu slug
'custom_tool_page_callback' // Function to display the page
content
);
}
}
// Callback function to display the content of the custom tool page
function custom_tool_page_callback() {
echo '<div class="wrap"><h1>Custom Tool Page</h1><p>This is a custom
tool page.</p></div>';
}
// Hook the function to the admin_menu action
add_action('admin_menu', 'add_custom_submenus');
}}}
Afterthat, you should be able to see the issue:
https://i.ibb.co/v1CghNW/screenshot-2024-08-16-a-s-17-00-47.png
This could be fixed with the following CSS. It will limit the menu height
to the screen size, and also add a scrollbar:
{{{
#adminmenu .wp-submenu {
overflow-y: scroll !important;
max-height: calc(100vh - 60px);
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61177#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list