posts whose content is being rendered right now */ private static array $stack = []; public function name(): string { return 'post-content'; } public function title(): string { return __('Post content', 'zadex'); } public function render(array $settings, Context $ctx) { $post = $ctx->post(); if (!$post || isset(self::$stack[$ctx->post_id])) { return ''; } self::$stack[$ctx->post_id] = true; try { // Nested the_content (shortcodes, a Zadex document of that post) reads the current post: make it this one. $html = (string) \Zadex\Frontend\PostData::with($post, static fn() => apply_filters('the_content', (string) ($post->post_content ?? ''))); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- WordPress core filter. } finally { unset(self::$stack[$ctx->post_id]); } return $html; } }