Hooks for developers
Filters and actions to change how the menu is read, drawn, hidden and blocked, and to add to the editor.
Adminline is built on WordPress's own menu: it reads $menu and $submenu just before the menu is printed, draws your saved menu in their place, and puts the originals back right after, so other code sees the menu it registered.
Menu items
Each item has a key: t:<slug> for a top-level item and s:<parent slug>><slug> for a submenu item (for example t:edit.php, s:edit.php>post-new.php, s:woocommerce>wc-orders). Added separators are sep:<id> and custom links link:<id>.
Who sees an item
adminline_item_visible decides whether someone sees an item, after the item's own setting. Return true to show it, false to hide it. It also decides blocking (a hidden, blocked item's screen is refused) and the admin bar.
// Comments only for people who can moderate them, whatever the menu settings.
add_filter( 'adminline_item_visible', function ( $visible, $item, $user ) {
if ( 't:edit-comments.php' === $item['key'] ) {
return user_can( $user, 'moderate_comments' );
}
return $visible;
}, 10, 3 );
adminline_protected_items lists the keys that are always shown to, and never blocked for, people who can manage options (Adminline's screen and Plugins). Add your own:
add_filter( 'adminline_protected_items', function ( $keys ) {
$keys[] = 's:tools.php>site-health.php';
return $keys;
} );
Blocking
adminline_blockedfilters whether the current screen is blocked ($blocked, $item, $request, $user;$requesthaspath, the file, andargs, the query arguments).adminline_blocked_messagefilters the message (HTML, passed throughwp_kses_post()).
The menu itself
adminline_live_menufilters the menu as read, before saved changes are laid over it.adminline_menufilters the tree about to be drawn for the current person.adminline_activeswitches every change off for a request when it returnsfalse(safe mode and theADMINLINE_DISABLEconstant use the same switch).adminline_iconsfilters the Dashicons offered in the icon picker.
The editor
adminline_tabsadds tabs to Settings → Admin Menu (an array of slug => label). Print a tab with theadminline_tab_<slug>action.adminline_editor_afterandadminline_tools_afterprint after the editor and after the Tools boxes.adminline_savedfires after a save, with the saved tree;adminline_resetafter a reset.adminline_exportfilters the export file's data;adminline_importfires with the imported file's data.adminline_import_errorsfilters the problems found in an import file ($errors, $data), before anything is saved. Add a message to refuse the file; nothing is imported then.- In the editor's JavaScript, the
adminline.panelaction (wp.hooks) fires when an item's panel is drawn, andadminline.changedafter any change.window.adminlinegives the model andrender().
For add-ons
adminline_loaded fires once Adminline has loaded (on plugins_loaded); ADMINLINE_VERSION, ADMINLINE_FILE, ADMINLINE_URL and ADMINLINE_DIR are defined from then on. Adminline Pro is built on these hooks.