Skip to content

Commit

Permalink
feat: add trace what prevents publish
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardBaumrock committed Mar 7, 2024
1 parent 90a993c commit fa9d0ab
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion RockMigrations.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -5105,15 +5105,20 @@ public function preventPublish(
// allow publish for superusers
if ($sudo and $allowForSuperusers) return;

// get trace for better info
$trace = Debug::backtrace();
$file = $trace[0]['file'];

// Remove publish button and unpublished checkbox in Page Edit
$this->wire->addHookAfter(
'ProcessPageEdit::buildForm',
function (HookEvent $event) use ($selector) {
function (HookEvent $event) use ($selector, $file) {
$form = $event->return;
$page = $event->object->getPage();
if (!$page->isUnpublished()) return;
if (!$page->matches($selector)) return;
$form->remove("submit_publish");
$page->message("$file prevents publishing this page.");
}
);

Expand Down

0 comments on commit fa9d0ab

Please sign in to comment.