'object', 'properties' => ['post_id' => ['type' => 'integer', 'minimum' => 1]], 'required' => ['post_id'], 'additionalProperties' => false, ]; } public function outputSchema(): ?array { return [ 'type' => 'object', 'properties' => [ 'post_id' => ['type' => 'integer'], 'url' => ['type' => 'string'], 'headings' => ['type' => 'array', 'items' => ['type' => 'object']], 'texts' => ['type' => 'array', 'items' => ['type' => 'string']], 'links' => ['type' => 'array', 'items' => ['type' => 'object']], 'images' => ['type' => 'array', 'items' => ['type' => 'object']], 'warnings' => ['type' => 'array', 'items' => ['type' => 'string']], 'notes' => ['type' => 'array', 'items' => ['type' => 'string']], ], 'required' => ['post_id', 'headings', 'texts', 'links', 'images', 'warnings', 'notes'], ]; } public function annotations(): array { return Annotations::read(); } public function isDirect(): bool { return true; } public function permission(array $input): bool|WP_Error { $post = PostGuard::editable($input['post_id'] ?? null, $this->schema, 'post_id', true); return $post instanceof WP_Error ? $post : true; } public function execute(array $input): mixed { $post = PostGuard::editable($input['post_id'] ?? null, $this->schema, 'post_id', true); if ($post instanceof WP_Error) { return $post; } $notes = [ 'Nur der Inhaltsbereich; Header, Footer und Theme-Builder-Vorlagen fehlen.', 'Das Rendern führt Plugin-/Theme-Filter aus (Shortcodes, oEmbed u. Ä.) und kann dabei ' . 'Netzwerkanfragen auslösen, die von WordPress oder anderen Plugins zwischengespeichert werden.', ]; if ((string) $post->post_password !== '') { $notes[] = 'Der Eintrag ist passwortgeschützt; Besucher sehen zuerst das Passwortformular.'; } foreach (array_slice(self::globalModuleIds((string) $post->post_content), 0, self::GLOBAL_NOTES) as $id) { $notes[] = sprintf( 'Globales Modul %s ist im Auszug nicht enthalten (beim Aufruf über die Schnittstelle rendert Divi ' . 'globale Module nicht); Inhalt mit lit-divi-outline mit post_id %s lesen.', $id, $id ); } return array_merge( ['post_id' => (int) $post->ID, 'url' => (string) get_permalink($post)], RenderSummary::fromHtml($this->renderer->render($post)), ['notes' => $notes] ); } /** * IDs of the global modules in $content, found the way Divi finds them (a string scan for * "globalModule", BlockParserStore::get_global_layout_content – parse_blocks() is unreliable there). * * @return list */ private static function globalModuleIds(string $content): array { preg_match_all('/"globalModule":"?(\d+)"?/', $content, $matches); return array_values(array_unique($matches[1])); } }