How It Works
The ID Admin Menu Customizer operates by hooking into WordPress at a very late stage of the admin menu construction process. Understanding this mechanism helps explain why the plugin is reliable, non-destructive, and compatible with virtually any other plugin.
Hook Timing
WordPress fires the admin_menu action to let plugins and themes register their admin menu items. The ID Admin Menu Customizer attaches its reorder logic at priority 9999 — far after the default priority of 10. This ensures that every plugin, theme, and WordPress core has already finished registering menu items before the customizer rearranges them.
Data Storage
All customization data is stored as a single option in the wp_options table under the key idamc_menu_order. This option contains three arrays:
- order — An ordered array of menu slugs representing the custom sequence.
- hidden — An array of slugs for items that should be hidden from non-administrators.
- dividers — An array of unique divider IDs for custom visual separators.
Drag-and-Drop Interface
The edit interface is powered by jQuery UI Sortable, which ships bundled with WordPress core — no additional libraries are loaded. When an administrator clicks “Edit Menu,” the sidebar items become draggable. Reordering, hiding, and adding dividers all happen in real time within the sidebar itself.
Saving via AJAX
When you click Save, the plugin sends the current state to the server via an AJAX POST request. This means no full page reload is required. The server validates the nonce, checks that the user has manage_options capability, sanitizes all inputs, and writes the updated configuration to the database.
Slug Identification
To reliably identify each menu item in JavaScript, the plugin stamps every admin menu <li> element with a data-idamc-slug attribute. This attribute mirrors the internal WordPress menu slug, allowing the JavaScript to accurately track items during drag-and-drop operations regardless of the menu item’s display label or icon.
