WooCommerce Code Reference

Post_Content
in package

Stateless renderer for core/post-content block.

This renderer replaces WordPress's default render_block_core_post_content() which uses a static $seen_ids array that causes issues when rendering multiple emails in a single request (e.g., MailPoet batch processing).

Unlike other block renderers, this class does NOT extend Abstract_Block_Renderer because it needs to directly replace WordPress's render_callback with a method that matches the exact signature expected by WordPress.

Table of Contents

render_stateless()  : string
Stateless render callback for core/post-content block.

Methods

render_stateless()

Stateless render callback for core/post-content block.

public render_stateless(array<string|int, mixed> $attributes, string $content, WP_Block $block) : string

This implementation avoids using get_the_content() which relies on global query state, and instead directly accesses post content and applies the_content filter for processing.

Key differences from WordPress's implementation:

  • No static $seen_ids array (allows multiple renders in same request)
  • Uses direct post content access instead of get_the_content()
  • Properly backs up and restores global state

IMPORTANT: This method is only set as the render_callback during email rendering. Outside of email rendering, the original callback is restored, so this method will never be called in non-email contexts.

Parameters
$attributes : array<string|int, mixed>

Block attributes.

$content : string

Block content.

$block : WP_Block

Block instance.

Return values
stringRendered post content HTML.