Search by

4rn0 / statamic-cp-bar

4rn0

WordPress's admin bar, rebuilt for Statamic: edit, add and refresh any page from the front end. No template changes, safe with static caching.

Package info

github.com/4rn0/statamic-cp-bar

Type:statamic-addon

pkg:composer/4rn0/statamic-cp-bar

Statistics

Installs: 0

Dependents: 0

Suggesters: 2

Stars: 0

Open Issues: 0

v1.0.0 2026-09-28 23:48 UTC

This package is auto-updated.

Last update: 2026-09-28 23:57:18 UTC


README

A WordPress-style admin bar for Statamic, safe with static caching.

Install it, and CP Bar is on every page. You change no templates. It is safe with half and full measure static caching. A cached page gets about 1 KB, the same for every visitor. Visitors never send a request for the bar. CP Bar knows SEO Pro, Redirect and Runway, and each item follows the permissions of the control panel.

The bar is for the people who work on the site. It sits across the top of every page. With one click, you edit the page, add something next to it, or refresh it in the static cache.

What you get

  • Edit takes you from the page to its entry or term in the control panel, and tells you when it's a draft.
  • New lists every blueprint you may create an entry or term with, the current collection first.
  • Sites takes you to the same page on the other sites of a multisite.
  • Cache shows whether the page is in the static cache, and refreshes just this page without touching the rest.
  • Forms links to the submissions of the forms in this entry.
  • Your account: profile, preferences, and a log out that brings you back to the page. The bar turns amber while you're impersonating a control panel user.
  • SEO Pro, Redirect and Runway work when they are installed. You see the SEO report of the page, Create redirect on a 404, and Runway models under New and Edit.
  • The control panel's look. The bar is the control panel's header, in each user's own theme color.
  • Permissions. A View CP Bar permission for each role, and a preference to switch the bar off for each user. Each item follows the permissions of the control panel.
  • Keyboard and screen readers. Tab moves along the bar, Enter or ↓ opens a menu. It also works in high contrast mode and right to left.
  • English, Dutch and French, in the language each user picked in the control panel.

Extending CP Bar

Your addon can add its own items to CP Bar, and it keeps working on sites without CP Bar. Put CP Bar in suggest in your composer.json, not in require:

"suggest": {
    "4rn0/statamic-cp-bar": "Shows broken links in CP Bar."
}

Then add your items in bootAddon(). The class_exists() check skips them on a site without CP Bar:

<?php

namespace Acme\BrokenLinks;

use Arnohoogma\StatamicCpBar\Facades\CpBar;
use Statamic\Facades\Permission;
use Statamic\Providers\AddonServiceProvider;

class ServiceProvider extends AddonServiceProvider
{

    public function bootAddon()
    {

        Permission::extend(fn () => Permission::register('view broken links'));

        // CP Bar is optional: without it, this does nothing.
        if (! class_exists(CpBar::class)) {
            return;
        }

        CpBar::extend(function ($bar, $context) {
            // Only on the page of an entry or a term.
            if (! $context->page) {
                return;
            }

            $bar->add([
                'id' => 'broken-links',
                'title' => __('Broken links'),
                'href' => cp_route('broken-links.show', $context->page->id()),
                'can' => 'view broken links',
            ]);
        });

    }

}

If an item throws an exception or has data that is not valid, CP Bar skips it and logs a warning. The rest of the bar and the page keep working. The API reference has all item types, options, actions, and what stays stable across versions.

Requirements

Statamic 6.31 or later and PHP 8.3. Roles, multisite and impersonation need Statamic Pro. On Solo, your one user gets the whole bar. Tested with SEO Pro 7.14, Redirect 4.2 and Runway 9.7.

What CP Bar does not do

  • It does not edit content on the page. You edit in the control panel.
  • It does not show to visitors, or to users without access to the control panel.
  • It does not have a menu builder. Items come from code.
  • It does not find forms that are only in a template.
  • It does not show Edit on a page from Route::statamic().
  • It does not catch a fatal error, a timeout, or output from echo or dd() in the code of another addon.

Documentation and license

The full documentation is in DOCUMENTATION.md. CP Bar is free and open source, under the MIT license.

More addons

  • Image Editor crops, rotates and adjusts images in the control panel, and keeps the original.
  • ImageOptimizer makes JPEG, PNG, GIF and WebP files smaller with the best free tools there are, bundled.
  • Image Colors picks background and text colors that match each image, and lets an editor pin one. Free.