Skip to content

Admin Bar ​

A toolbar on the site for signed-in users: the admin, New and Edit, as in WordPress.

kitloom/admin-bar · admins: kitloom/admin-bar-filament, kitloom/admin-bar-nova

Video lessons ​

Recorded in the Filament admin; the Nova admin works the same way.

A toolbar at the top of the site for signed-in users, as WordPress shows its own on the site: the site's title leading to the admin, New with every type the user may add, Edit for the post or term on screen, Inspect — why this page is slow — once switched on, the user's name and Log Out. Where New and Edit lead is the admin's to say: kitloom/admin-bar-filament or kitloom/admin-bar-nova. Without either there is no bar.

Who sees what ​

PartShown when
The barAdmin Bar → Settings → Show the admin bar on the site is on (admin_bar_enabled, on until saved); the user is signed in and may enter the admin (Filament: canAccessPanel(); Nova: the viewNova gate); and their show_admin_bar_front user meta is not false — WordPress's "Show Toolbar when viewing site", for one user
NewOne entry per public post type the user may create (its create_posts capability) that the admin has a screen for; the first one is the link of New itself
EditThe page is a post or a term the user may edit (edit_post / edit_term) and the admin has a screen for it
InspectAdmin Bar → Settings → Show Inspect in the bar is on (admin_bar_inspector, off until switched on) and the user holds manage_options

Guests get nothing, and the page cache keeps only guests' pages, so a cached page never carries anyone's bar.

On the page ​

The bar goes right after <body> through the page scripts (@siteBodyOpen, which every theme has), with its own markup and styles: no theme needs to know about it. Like WordPress, it moves the page down (html { margin-top: 32px }) and adds the admin-bar class to <body>. The page moves, but what a theme fixes or sticks to the top of the window does not: a sticky or fixed header, a phone's menu under it, a sidebar that sticks while the page scrolls. The bar sets WordPress's own variable --wp-admin--admin-bar--height (32px) on :root, and a theme offsets such things by it — without the bar it is not set and the fallback applies:

css
.header {
    position: sticky;
    top: var(--wp-admin--admin-bar--height, 0px);
}

Every bundled theme does; CSS taken from a WordPress theme that reads the variable works as it is.

A Vue theme moves from page to page without reloading: the bar then asks GET /wp-json/admin-bar/v1/edit?path=/about/ (behind the session) what Edit leads to on the new page.

Inspect ​

Inspect a page

Why is this page slow, and what does it do? Clicking Inspect asks GET /wp-json/admin-bar/v1/inspect?path=/about/ (behind the session, manage_options, a throttle of its own: twenty a minute), which draws the page once more as the signed-in user through kitloom/site's Inspect\PageInspector — what php artisan kitloom:inspect does — and answers the inspection as data, the same shape the site_inspect_page agent tool answers. The bar draws a panel under itself, in its own markup and styles: the template and its candidates, the statements (how many, in how long, exact duplicates and same-shape repeats first, then the slowest five), the page cache's verdict for a guest, the timing. The page is drawn a second time for it, with caches warm, and the panel says so. A Vue theme asks again on every page change while the panel is open.

Only a user who holds manage_options sees the entry or gets an answer, and only once the owner switched it on: the page is drawn once more per click, which nobody should be able to ask for by default. Guests never see it, and a cached page never carries it (the bar is not cached).

Configuration ​

The bar is switched on and off on Admin Bar → Settings in either admin (manage_options), and Inspect with it (Show Inspect in the bar).

config/kitloom-admin-bar.php (php artisan vendor:publish --tag=kitloom-admin-bar-config): register false leaves the bar out whatever the setting says; filament.register and nova.register turn off one admin's section and links.

For the application ​

An admin of its own tags a Kitloom\AdminBar\Contracts\AdminLinks with AdminLinks::TAG: the admin's home for a user (or null when they may not enter), where a new post of a type is written, where a post or a term is edited. The bar takes the first admin that lets the user in; who may add or edit what it checks itself.

Read more ​

kitloom — sites on Laravel, built for you and run with AI.
Contact · Services · License · Refunds · Privacy · Community · YouTube · [email protected]