$input */ abstract protected function change(DiviPage $page, array $input, DiviComposition $composition): DiviChange|WP_Error; public function outputSchema(): ?array { return ToolResult::schema([ 'tree_rev' => ['type' => 'string'], // Global library entries (answer F2): the pages that show the entry, and the backup // made when revisions are off (also for live Theme Builder layouts, ruling Q2). 'affected' => ['type' => 'array', 'items' => ['type' => 'object']], 'affected_count' => ['type' => 'integer'], 'hidden_count' => ['type' => 'integer'], 'backup_id' => ['type' => 'integer'], // Theme Builder layouts: the enabled templates that show the layout. 'templates' => ['type' => 'array', 'items' => ['type' => 'object']], ], ['tree_rev']); } public function isDirect(): bool { return true; } final public function permission(array $input): bool|WP_Error { $refusal = $this->precheck($input); if ($refusal !== null) { return $refusal; } $page = $this->writer->page($input); return $page instanceof WP_Error ? $page : true; } final public function execute(array $input): mixed { $refusal = $this->precheck($input); if ($refusal !== null) { return $refusal; } $page = $this->writer->page($input); if ($page instanceof WP_Error) { return $page; } $change = $this->change($page, $input, $this->writer->composition($page)); if ($change instanceof WP_Error) { return $this->writer->notice($page, $change); } return $this->writer->commit($this->name(), $page, $change, $input); } /** * Checks of a tool beyond the page (rights and Tools-tab gates of another group) – run in * permission() and again in execute(). Null = none. * * @param array $input */ protected function precheck(array $input): ?WP_Error { return null; } }