Skip to content

fix: run do_shortcode on manual, custom placements for the block theme#1526

Merged
laurelfulford merged 4 commits intotrunkfrom
fix/manual-custom-placements-block-theme
Feb 27, 2026
Merged

fix: run do_shortcode on manual, custom placements for the block theme#1526
laurelfulford merged 4 commits intotrunkfrom
fix/manual-custom-placements-block-theme

Conversation

@laurelfulford
Copy link
Copy Markdown
Contributor

@laurelfulford laurelfulford commented Feb 6, 2026

All Submissions:

Changes proposed in this Pull Request:

While Single Prompt and Custom Placements still work in the post/page content using the block theme, it absolutely does not want to do anything with the shortcode these placements use when placed in a template/template part via the site editor.

This PR adds a check for the block theme and the content, and runs do_shortcode() when you're using the block theme and not in the content, rather than inserting the shortcode block code directly. Both Copilot and Cursor suggested using a filter to make it easier to swap between these two "themes" for testing, so I went with that, too 😅

I think this is kind of a temporary measure; NPPD-1216 proposes some changes to campaigns to make them more "block-like".

Closes NPPD-1212

How to test the changes in this Pull Request:

  1. Set up a couple prompts, one manual and one custom placement.
  2. If it's not already running the block theme, switch your site to the block theme.
  3. Edit the Site, and add a Single Placement and Custom Placement block, and add your campaign prompts to them.
  4. View on the front-end:
CleanShot 2026-02-06 at 15 52 23
  1. Apply this PR.
  2. Refresh the page and confirm you're getting prompts:
CleanShot 2026-02-06 at 15 51 47
  1. Try adding the two manual placements in post/page content, and ensure they still work.
  2. Switch to the Classic theme and try adding both placements to the content and widget areas, respectively.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@laurelfulford laurelfulford requested a review from a team as a code owner February 6, 2026 23:52
@laurelfulford laurelfulford requested review from Copilot and removed request for a team February 6, 2026 23:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses prompt blocks not rendering when inserted into block-theme templates/template parts by changing how the underlying [newspack-popup] shortcode is executed in dynamic block render callbacks.

Changes:

  • Detect block themes and render the prompt via do_shortcode() instead of returning a wp:shortcode block comment wrapper.
  • Apply the same logic to both the Single Prompt block and the Custom Placement block renderers.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
src/blocks/single-prompt/view.php Adds block-theme detection and renders the prompt shortcode directly for block themes.
src/blocks/custom-placement/view.php Mirrors the block-theme shortcode rendering change for custom placement prompts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/blocks/custom-placement/view.php
Comment thread src/blocks/custom-placement/view.php
Comment thread src/blocks/custom-placement/view.php Outdated
Comment thread src/blocks/single-prompt/view.php
Comment thread src/blocks/single-prompt/view.php Outdated
Comment thread src/blocks/single-prompt/view.php Outdated
Copy link
Copy Markdown
Member

@miguelpeixe miguelpeixe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good solution and tests well!

@laurelfulford
Copy link
Copy Markdown
Contributor Author

Yay! Thanks @miguelpeixe! 🙌 😄

@laurelfulford laurelfulford merged commit adbca1c into trunk Feb 27, 2026
9 checks passed
@laurelfulford laurelfulford deleted the fix/manual-custom-placements-block-theme branch February 27, 2026 18:02
@github-actions
Copy link
Copy Markdown

Hey @laurelfulford, good job getting this PR merged! 🎉

Now, the needs-changelog label has been added to it.

Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label.

If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label.

Thank you! ❤️

matticbot pushed a commit that referenced this pull request Mar 5, 2026
# [3.10.0-alpha.1](v3.9.2...v3.10.0-alpha.1) (2026-03-05)

### Bug Fixes

* add is-layout-constrained and is-layout-flow CSS classes for block themes ([#1521](#1521)) ([bafa61f](bafa61f))
* give more specific overlays priority by tweaking DOM order ([f0a64ef](f0a64ef))
* give more specific overlays priority by tweaking DOM order ([b8abd19](b8abd19))
* iframe editor compatibility ([#1520](#1520)) ([222f33c](222f33c))
* leave inline (non-overlay) popups in default non-sort ([a9c6f64](a9c6f64))
* run do_shortcode on manual, custom placements for the block theme ([#1526](#1526)) ([adbca1c](adbca1c))

### Features

* add AI agent guidelines ([#1530](#1530)) ([d0c4eb4](d0c4eb4))
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 5, 2026

🎉 This PR is included in version 3.10.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Mar 16, 2026
# [3.10.0](v3.9.2...v3.10.0) (2026-03-16)

### Bug Fixes

* add is-layout-constrained and is-layout-flow CSS classes for block themes ([#1521](#1521)) ([bafa61f](bafa61f))
* give more specific overlays priority by tweaking DOM order ([f0a64ef](f0a64ef))
* give more specific overlays priority by tweaking DOM order ([b8abd19](b8abd19))
* iframe editor compatibility ([#1520](#1520)) ([222f33c](222f33c))
* leave inline (non-overlay) popups in default non-sort ([a9c6f64](a9c6f64))
* run do_shortcode on manual, custom placements for the block theme ([#1526](#1526)) ([adbca1c](adbca1c))

### Features

* add AI agent guidelines ([#1530](#1530)) ([d0c4eb4](d0c4eb4))
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 3.10.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants