-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve logic in render_block_core_template_part
.
#50636
Improve logic in render_block_core_template_part
.
#50636
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@spacedmonkey The logic here looks good, though it would be great to do a performance benchmark first to assess the impact.
It would be great to do two benchmarks, one for a regular block theme, and another one for a block theme with a child theme being used.
Based on the logic changes, it seems this change would be most beneficial for sites not using a child theme (which is probably the majority of sites).
@felixarntz I applied these changes manaully to WordPress trunk and run benchmarks. 500 runs again, TT3 and TT3 child theme.
This change seems to have a nice benefit for both types of site. 👍 |
I really wish Gutenberg would have PHP unit tests for all the block render callbacks 😞 That would make me much more confident in reviewing this change here. Maybe we could start adding some tests? |
@swissspidy I agree that the lack of a unit testing for callbacks is here is a real problem. But not one in the scope of this change. However we test these callbacks, how that is backported, it is another ticket. I could maybe add tests once this is backported, that would be much easier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that unit testing is needed for essential logic in rendering callbacks like this.
It is also beneficial to provide testing instructions; they help reviewers and can later be adopted in tests. The original PR(#36910) was also missing the instructions, so apologies if I missed something.
Testing instructions
- Create a child theme -
wp scaffold child-theme tt3-child --parent_theme=twentytwentythree --theme_name="TT3 Child"
- Override the footer template part using the legacy directory -
tt3-child/block-template-parts/footer.html
. - Confirm override works as expected - ✅
- Rename the legacy template-parts directory -
tt3-child/parts/footer.html
. - Confirm override works as expected - ✅
- Edit the template in Site Editor.
- Confirm that editor content is rendered - ✅
Co-authored-by: George Mamadashvili <georgemamadashvili@gmail.com>
Flaky tests detected in 9d55418. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5312394222
|
* Improve logic in `render_block_core_template_part`. * Use a foreach loop. * Apply suggestions from code review Co-authored-by: George Mamadashvili <georgemamadashvili@gmail.com> --------- Co-authored-by: George Mamadashvili <georgemamadashvili@gmail.com>
What?
Improve logic in
render_block_core_template_part
. These improves include.get_stylesheet
.Why?
How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast