Fixes registering block scripts & styles for parent themes#3921
Fixes registering block scripts & styles for parent themes#3921jack-h2ml wants to merge 6 commits intoWordPress:trunkfrom
Conversation
Fixes for both the
register_block_script_handle
and
register_block_style_handle
Which allow for Child themes to access and utilise blocks defined in Parent themes.
Previously these functions could not handle blocks registered in Parent themes, the above changes fix this by determining whether the given asset path belongs to either of the template or stylesheet directories (Parent and Child themes respectively).
|
Hi @jack-h2ml! 👋 Thank you for your contribution to WordPress! 💖 It looks like this is your first pull request to No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description. Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making. More information about how GitHub pull requests can be used to contribute to WordPress can be found in this blog post. Please include automated tests. Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook. If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook. The Developer Hub also documents the various coding standards that are followed:
Thank you, |
Fixes for PHP formatting issues as raised by PR unit-tests.
Removed errant tab from Line 252
Removed errant whitespace from line 252
Editor: Use a non-persistent object cache instead of transient in `wp…
Implemented a workaround for the following [WP Core PR](WordPress/wordpress-develop#3921)
Temporary WorkaroundI have created a filter based workaround for the above issue, just incase anyone lands here! Tested and working on my local dev server [MacOS 13.1, NGINX, PHP 8.0] and SiteGround Hosting [Linux, Apache, PHP 7.4.33] without issue thus far. I do have some reservations with regards to plugins filtering CommentedCompactedNote the three |
|
A note on the above workaround, ensure that the workaround is called before you register your blocks or it won't work, so for example call the above init filter with a priority of 1, and then register your blocks in a separate init filter with a priority >= 2. |
|
Closing in favor of #4788 |
Fixes for both the
register_block_script_handle()andregister_block_style_handle()functions withinwp-includes/blocks.js, allowing for child themes to access and utilise blocks defined in parent themes.Previously these functions could not handle blocks registered in Parent themes, however the above changes fix this by determining whether the given asset path belongs to either of the template or stylesheet directories (Parent and Child themes respectively) as opposed to just checking using
get_theme_file_path('')as is currently the case, thus mitigating this issue.An issue was raised under the WordPress / gutenberg Repo, however as
wp-includes/blocks.jsis included in the WordPress / wordpress-develop repo I have created the PR here instead. That original ticket can be found here.Trac ticket: Ticket
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.