Skip to content

Instantly share code, notes, and snippets.

@Nerd-Rush
Last active August 7, 2024 13:24
Show Gist options
  • Save Nerd-Rush/56296e0b1179de099b546519f1354f55 to your computer and use it in GitHub Desktop.
Save Nerd-Rush/56296e0b1179de099b546519f1354f55 to your computer and use it in GitHub Desktop.
WordPress Admin Menu Organizer
function move_plugins_to_end() {
global $menu;
$plugin_menus = [];
$non_plugin_menus = [];
if (!isset($menu) || !is_array($menu)) {
return; // Exit if $menu is not properly set
}
foreach ($menu as $index => $item) {
if (is_array($item) && isset($item[2]) && strpos($item[2], 'plugin.php') !== false) {
// Exclude the 'plugins.php' menu item
if ($item[2] !== 'plugins.php') {
$plugin_menus[] = $item;
}
} else {
$non_plugin_menus[] = $item;
}
}
$menu = array_merge($non_plugin_menus, $plugin_menus);
}
add_action('admin_menu', 'move_plugins_to_end', 999);
function custom_admin_styles() {
echo '<style>
.separator {
background-color: rgba(128, 128, 128, 0.5);
height: 1px !important;
margin-top: 10px;
}
.separator-croco, #adminmenu > li.wp-not-current-submenu.wp-menu-separator.elementor {
display: none !important;
}
</style>';
}
add_action('admin_head', 'custom_admin_styles');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment