feat: lit/page-render-summary – rendered content as structured excerpt

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
This commit is contained in:
2026-09-26 12:21:23 +02:00
co-authored by Claude Opus 5.5
parent d27504a750
commit 2e9acd686a
8 changed files with 412 additions and 3 deletions
@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace LIT\MCP\Integrations\WordPress\Render;
use WP_Post;
/**
* Renders the content area of an entry in-process, like the front end does for the_content
* (Divi 5 renders its blocks there – verified in DDEV). Header, footer and Theme Builder
* layouts are not part of it. Not final so abilities can be unit-tested with a mock.
*/
class PageRenderer
{
public function render(WP_Post $post): string
{
$previous = $GLOBALS['post'] ?? null;
$GLOBALS['post'] = $post;
setup_postdata($post);
ob_start();
try {
$html = (string) apply_filters('the_content', (string) $post->post_content);
} finally {
$echoed = (string) ob_get_clean();
$GLOBALS['post'] = $previous;
if ($previous instanceof WP_Post) {
setup_postdata($previous);
} else {
wp_reset_postdata();
}
}
return $echoed . $html;
}
}