Haven’t thoroughly tested it or anything, but this hook seems to work:
wire()->addHookBefore('ProcessPageEdit::execute', function(HookEvent $event) {
/** @var Page $page */
$page = $event->object->getPage();
//ProcessPageEdit does roughly this to figure out if it’s dealing with a save request. if it isn’t, we don’t care
if (!count($_POST) || (int)input()->post('id') !== $page->id)
return;
//if the page isn’t locked -> don’t care
if (!$page->isLocked())
return;
//if it’s locked and we’re a superuser, unlock
if (user()->isSuperuser()) {
$page->removeStatus(Page::statusLocked);
wire()->message('leet hax, you just edited a locked page.');
//You don’t need to re-lock the page here, because the Locked checkbox is
//sent with the page edit form, so saving will set it to the desired value
}
});
I would have hooked processSave directly, but it’s not hookable.
Bonus tip: You can change the warning that says “This page is locked for edits” if you put this in the hook:
if (user()->isSuperuser())
$event->object->noticeLocked .= ', but I’ll make an exception for you because you’re such a pleasure to be around';
Btw, you can always edit locked pages from the API as a superuser.