Opened 12 months ago
Last modified 11 days ago
#56780 assigned defect (bug)
shortcode block in block-based template part in a classic theme does not get expanded
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.4 | Priority: | high |
Severity: | normal | Version: | 6.1 |
Component: | Editor | Keywords: | has-testing-info has-screenshots has-patch has-unit-tests |
Focuses: | Cc: |
Description
While testing the new feature in 6.1 (w/ 6.1-beta3) for a classic theme to include block-based template parts, I discovered that shortcode blocks in such template parts are not expanded (their render callbacks are not called).
The details are in my comment on the Dev Note announcing this new feature.
Note: creating the ticket here in Trac, rather than the GB GitHub, because that's where @mamaduka asked me to open in
Attachments (6)
Change History (50)
#1
@
12 months ago
- Summary changed from shortcode block in block-based template part in a class theme does not be expanded to shortcode block in block-based template part in a class theme does not get expanded
#3
@
12 months ago
- Milestone changed from Awaiting Review to 6.1
Moving to 6.1 milestone for investigation.
This ticket was mentioned in Slack in #core by chaion07. View the logs.
12 months ago
#5
@
12 months ago
- Keywords needs-testing added
@pbiron thank you for reporting this. We reviewed this ticket during a recent bug-scrub session and based on the feedback we are adding the keyword needs-testing.
Cheers!
Props to @costdev & @mukesh27
#6
@
12 months ago
test-56780.zip contains a minimal classic theme that can be used to replicate the problem.
- Download and activate the theme on a site running WP 6.1-beta1, 6.1-beta2, 6.1-beta3, or 6.1-RC1.
- Then view any post/page on the front-end.
- Expected results: the string 'hellow world' should display above any post/page content.
- Actual results: the stirng '[hello_world]' displays above any post/page content.
This ticket was mentioned in Slack in #core by pbiron. View the logs.
12 months ago
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
12 months ago
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
12 months ago
#10
@
12 months ago
- Summary changed from shortcode block in block-based template part in a class theme does not get expanded to shortcode block in block-based template part in a classic theme does not get expanded
#14
@
10 months ago
- Keywords has-testing-info has-screenshots added; needs-testing removed
Reproduction Report
I was able to reproduce this issue.
Environment
- Hardware: MacBook Pro Apple M1 Pro
- OS: macOS 12.6.1
- Browser: Safari 16.1
- Server: nginx/1.23.2
- PHP: 7.4.33
- WordPress: 6.2-alpha-54642-src
- Theme: test-56780 v0.1.0 (the provided attachment:test-56780.zip)
- Active Plugins:
- gutenberg v14.8.0-rc.1 (tested active/inactive)
Actual Results
- ✅ Shortcodes are not processed when included in a
block_template_part
.
Additional Information
- Shortcode was not processed in the template part, whether inside a
<!-- wp:shortcode -->
or standalone. - Added paragraph and shortcode blocks to post to demonstrate the shortcode was otherwise functional.
- Applied the following adjustments to the provided test theme for added clarity:
- in
masthead.html
, added<h3>masthead:</h3>
before the shortcode block - correct typo in shortcode to
[hello_world]
- in
functions.php
, updated return value of shortcode tohello world!
- in
Supplemental Artifacts
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
9 months ago
#16
@
9 months ago
- Milestone changed from 6.2 to Future Release
As per today's bug scrub and since this ticket doesn't have any patch yet, let's move it to Future Release.
This ticket was mentioned in PR #3851 on WordPress/wordpress-develop by @petitphp.
9 months ago
#17
- Keywords has-patch has-unit-tests added; needs-patch removed
Update block_template_part
to expand shortcodes in template parts
Add set of typical actions run on the_content
to the block_template_part
function. This replicate the behavior of the template part block's render method.
Trac ticket: https://core.trac.wordpress.org/ticket/56780
#18
@
9 months ago
Added a patch that replicate the behavior of the template part block's render method in block_template_part
. Tested manually and with the newly created unit test.
@audrasjb I don't know if this ticket can be added back to the 6.2 milestone or if it's too late given it was tagged early.
#19
@
9 months ago
Thanks for the patch, @petitphp! I've expanded the test cases to include the other processing added in PR 3851.
Test Report
Patch tested: https://github.com/WordPress/wordpress-develop/pull/3851
Environment
- Hardware: MacBook Pro Apple M1 Pro
- OS: macOS 12.6.2
- Browser: Safari 16.2
- Server: nginx/1.23.3
- PHP: 7.4.33
- WordPress: 6.2-alpha-54642-src
- Theme: test-56780 v0.1.0 (same as comment:14 plus changes noted below)
Actual Results
block_template_part
content is now processed by:
- ✅ do_shortcode (original reported issue)
- ✅ wptexturize (e.g. processed smart quotes)
- ✅ convert_smilies
- ✅ shortcode_unautop
- ✅ wp_filter_content_tags (added
decoding="async" loading="lazy"
attributes to<img>
tag) - ✅ $wp_embed->autoembed
Additional Notes
- In the test theme, I replaced
masthead.html
with the content of this gist to incorporate the additional markup processing.
Supplemental Artifacts
Before Patch | After Patch |
---|---|
![]() | ![]() |
@ironprogrammer commented on PR #3851:
9 months ago
#20
Thanks for this, @petitphp! Because this PR goes beyond handling do_shortcode()
(original issue), it would be great if the unit tests accounted for the other changes. If you have time to expand those further, perhaps we can nudge this back into the current release cycle 🤞🏻
There are still a couple of `early` scrubs left, so I don't think the door is closed quite yet if this keeps up momentum.
@petitphp commented on PR #3851:
9 months ago
#21
@ironprogrammer Thanks for taking the time to do another round of testing! As suggested, I've expanded the test cases for the change based on the ones you mentioned on your report.
#23
@
6 months ago
- Keywords early removed
I don't think this ticket needs to be constrained by early
.
Why?
This keyword should only be applied by committers. The keyword signals that the ticket is a priority, and should be handled early in the next release cycle.
The high
priority level flags that it needs to be addressed high in the bugfix queue.
But early
keyword has a time restriction that the bugfix must be completed early alpha release cycle, else it will be punted out of the release.
For this bugfix, I'm seeing a high risk to users or the project to drive needing it committed early in alpha. Is there a high risk?
IMO this could have been fixed up until RC1. But since it was flagged as an early
candidate, once the early phase of the alpha cycle was past, it has to be punted.
To avoid punting it in 6.3, I suggest removing early
but leaving the high
priority. With this approach, the high priority bugfix can happen at any time between now and 6.3 RC1.
@audrasjb do you agree?
#24
@
5 months ago
In WP 6.2.1 a change was made to stop processing shortcodes in block templates.
This change is being discussed after some issues were reported for some site after the update to 6.2.1.
This ticket might become invalid if shortcode processing is removed, or the patch for this ticket will need to be updated to match the definitive solution.
This ticket was mentioned in Slack in #core by chaion07. View the logs.
4 months ago
This ticket was mentioned in Slack in #core by oglekler. View the logs.
3 months ago
#27
@
3 months ago
- Keywords needs-testing added
I tested with 6.3-alpha-56078-src and Twenty Twenty-Three theme, placing inline shortcode into Header, Footer and Post Meta templates part — it is working everywhere.
So, it looks like the initial issue needs to be tested again to see if it was fully fixed during 6.2.2.
#28
@
3 months ago
I can reproduce the issue with 6.3-beta3-56130-src.
I have used the provided classic/hybrid test theme with some additions like the default gallery short code. I found that short codes are not rendered in the header part.
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
3 months ago
#30
@
3 months ago
Test Report
Reproducible with the following steps based on https://core.trac.wordpress.org/ticket/56780#comment:14
1- Install and activate the following theme
https://core.trac.wordpress.org/attachment/ticket/56780/test-56780_updated.zip
2- Create a post and add short code
<!-- wp:shortcode --> [hello_world] <!-- /wp:shortcode -->
3- View the frontend of the post
Environment
- OS: Ubuntu 23.04
- Web Server: Nginx
- PHP: 8.1.9
- WordPress: 6.3-beta4-56228)
- Browser: Chrome 114.0.5735.198
- Theme: [test-56780_updated.zip]
- Active Plugins:
- Core rollback 1.3.5
- WordPress Beta Tester 3.5.2
Actual Results
Additional Notes
- Expected o/p:
masthead: hello_world!
Short code in post edit
hello_world!
Supplemental Artifacts
- Tested with copy past the changes here into related file https://github.com/WordPress/wordpress-develop/pull/3851 and can see it is fixed
This ticket was mentioned in Slack in #core-test by mai21. View the logs.
3 months ago
#32
@
3 months ago
- Keywords close added; needs-testing removed
According to @mai21, this ticket was fixed on the related PR.
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
3 months ago
#34
@
3 months ago
- Keywords early added; close removed
- Milestone changed from 6.3 to 6.4
As per today's bug scrub, and since WP 6.3 release candidate 1 is planned tomorrow, let's move this ticket to milestone 6.4 wirth early
keyword, so it doesn't wait until the end of the beta cycle to be committed.
#35
@
6 weeks ago
- Keywords early removed
I've removed the early
keyword. Why? See my comments above.
The handbook explains the keyword as:
This keyword should only be applied by committers. The keyword signals that the ticket is a priority, and should be handled early in the next release cycle.
early
means the commits need to happen during the early part of the Alpha cycle.
Though it would be great to prepare the work for commit as early as possible, commits for this ticket should not be constrained to only happen during the early Alpha phase. Rather, defect commits can happen up to 6.4 RC 1.
To aid in 6.4 tracking and scrubs, I've removed the early
keyword.
This ticket was mentioned in Slack in #core by petitphp. View the logs.
4 weeks ago
#37
@
4 weeks ago
Is there a chance in the next update to include Bard AI? I recently run a
Entertainment website and it would be
perfect if we can have AI. Thanks.
This ticket was mentioned in Slack in #core by petitphp. View the logs.
3 weeks ago
#39
@
3 weeks ago
Test Report
This report validates that the indicated patch addresses the issue.
Patch tested: https://github.com/WordPress/wordpress-develop/pull/3851
Environment
- OS: macOS 13.4.1
- Web Server: Nginx
- PHP: 7.4.33
- WordPress: 6.4-alpha-56267-src
- Browser: Firefox 118.b2
- Theme: Theme: test-56780 v0.1.0 (same as comment:14) with custom
masthead.html
content from ironprogrammer's gist - Active Plugins: ø
Actual Results
- ✅
do_shortcode
(original reported issue) - ✅
wptexturize
(e.g. processed smart quotes) - ✅
convert_smilies
- ✅
shortcode_unautop
- ✅
wp_filter_content_tags
(added decoding="async" loading="lazy" attributes to <img> tag) - ✅
$wp_embed->autoembed
Additional Notes
- I was able to reproduce the original issue in trunk.
- Prior to doing the testing, the patch has been refresh with latest change up until trunk@3f9bc4e.
Supplemental Artifacts
See attachments bellow for screenshots before and after applying the patch.
#40
@
3 weeks ago
Test Report
This report validates that the indicated patch fixed the issue.
Patch tested: https://github.com/WordPress/wordpress-develop/pull/3851
Environment
- OS: Windows 11 Pro (22H2)
- Web Server: nginx/1.25.1
- PHP: 7.4.33
- WordPress: 6.4-alpha-56267-src
- Browser: Chrome Version 116.0.5845.141 (Official Build) (64-bit)
- Theme: Test 56780 - https://core.trac.wordpress.org/attachment/ticket/56780/test-56780_updated.zip.
- No Active Plugins
Prior to Applying the Patch
- Followed the provided guidelines of @mai21
- ❌ The shortcode remained unprocessed within the template section, whether it was placed within a <!-- wp:shortcode --> block or used independently.
After Applying The Patch
- ✅ The issue was fixed.
Supplemental Artifacts
Before patch:
After Patch:
#41
@
3 weeks ago
Test Report
This report validates that the indicated patch addresses the issue.
Patch tested: https://github.com/WordPress/wordpress-develop/pull/3851
Environment
- OS: Windows 11 (22H2)
- Web Server: nginx/1.25.1
- PHP: 7.4.33
- WordPress: 6.4-alpha-56267-src
- Browser: Chrome Version 113.0.5672.126 (Official Build) (64-bit)
- Theme: [test-56780_updated.zip]
- Plugins: None activated
Before Applying The Patch
- Followed the instructions of @mai21
- ❌ shortcode was not applied.
After Applying The Patch
- Followed the same instructions.
- ✅ shortcode was applied properly.
Supplemental Artifacts
Before: https://i.imgur.com/GsMts5M.png
After: https://i.imgur.com/T2KG8sU.png
See also: #54614, #54759, #55996