Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Split core blocks assets loading #25220
Split core blocks assets loading #25220
Changes from 40 commits
332a5be
c349cae
59f83ac
abd7a4d
48de591
7e5866c
78e25ab
08f5583
923bbd9
5698860
2ed1a62
ae9e26e
ff7b96b
4865c10
0da1afc
e98910a
d2cd042
d692c38
9d8271c
3a9ed36
994a95b
6aef0de
e551a83
973da54
9689d53
d185c07
7e57414
38133f2
9913ba7
476d9bf
11d7d0c
ee529a2
58f83df
309a4e6
a87fd68
26c94f4
9db606f
423d76b
2601d4e
831e38a
8a18dc8
ba8e3bf
a27d3c3
16a7df3
f5c745e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
The same action is assigned twice for the front-end and admin screens:
https://github.com/WordPress/wordpress-develop/blob/9fc20595b651ebd543e742b1056b38d5c670a9e6/src/wp-includes/default-filters.php#L520-L521
It's a reminder to myself as it's easy to forget how it all works.
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 don't like that this refers to handle, for me it should be the opposite. the block.json links to files and handlers are auto-registered based on the block.json file making block.json the source of truth for block configs. Is this possible?
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.
Hmmm these are basically just passed-on to
register_block_type
viaregister_block_type_from_metadata
.Ideally,
style
andediorStyle
would be the URLs of the stylesheets, but I don't know at this point if we can actually change it, there are lots of plugins out there that are already using them inregister_block_type
, so any changes would have to basically cascade in all functions, check if it's a URL or a handle and act accordingly 🤔If we want to only change it for the
block.json
files and not make any changes toregister_block_type
, things will probably get more complicated since we have no way of dynamically defining a URL inside the static json fileThere 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.
It's supported in this method https://github.com/WordPress/wordpress-develop/blob/2a46c3987f806ea4aae642320101440260b1aba9/src/wp-includes/blocks.php#L144 that is used inside
register_block_type_from_metadata
. You can provide the local path prefixed withfile:
(similar to npm paths for local dependencies) asstyle
oreditorStyle
. The rest will be handled behind the scenes.However, it doesn't support RTL version for CSS yet. Besides it isn't guarded with the feature flag proposed here. We discussed it in one of the comments above.
We should improve what WordPress Core has and in my opinion it would work with paths provided in
block.json
. In general, whenever adding APIs to Core we should introduce hooks more often to allow ourselves to apply such modifications inside the plugin 😅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.
oooh nice, I didn't know about that ❤️ Do you think we should do that in this PR? Or should we do that refactor later in a separate PR?