Skip to content

Blocks: Process shortcodes in pattern blocks - #13261

Draft
jawsrdev wants to merge 1 commit into
WordPress:trunkfrom
jawsrdev:fix/58397-pattern-shortcodes
Draft

Blocks: Process shortcodes in pattern blocks#13261
jawsrdev wants to merge 1 commit into
WordPress:trunkfrom
jawsrdev:fix/58397-pattern-shortcodes

Conversation

@jawsrdev

Copy link
Copy Markdown

Trac ticket: https://core.trac.wordpress.org/ticket/58397

What?

When a core/pattern block is used in a block template, template-level shortcode processing runs before the pattern is expanded. Shortcodes introduced by the pattern therefore remain unprocessed and are rendered literally.

This change applies shortcode_unautop() and do_shortcode() to registered pattern content before do_blocks() renders its blocks.

Why?

Processing shortcodes before blocks matches the existing block-template ordering and also allows block markup returned by a shortcode to be rendered.

Testing

A PHPUnit regression test registers a shortcode and a pattern containing a core/shortcode block, renders the pattern through the same shortcode-then-block ordering used by block templates, and verifies the shortcode output.

Focused command:

npm run test:php -- --filter Tests_Blocks_RenderBlockCorePattern

The focused test was not run locally because the available environment does not include PHP or Docker. This is submitted as a draft so CI and contributor testing can validate it before review.

Use of AI Tools

AI assistance: Yes
Tool(s): OpenAI Codex in ChatGPT Work
Model(s): GPT-5
Used for: Investigating the rendering order, drafting the implementation and regression test, reviewing the diff for scope and consistency, and preparing this pull request description. PHPUnit was not available in the working environment, as disclosed above.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant