Block: Implement block insertion functions#5240
Block: Implement block insertion functions#5240ockham wants to merge 1 commit intoWordPress:trunkfrom
Conversation
a665872 to
dd8f187
Compare
|
@gziolo I've decided to only implement Edit: I've updated the tracking ticket accordingly. |
| <!-- /wp:paragraph --> | ||
| </div> | ||
| <!-- /wp:tests/group --> | ||
| HTML |
There was a problem hiding this comment.
PHP 7.0 didn't like the trailing comma 😕
There was a problem hiding this comment.
Yes, that is a bit annoying. Usually, you need to put the string in its variable to use Heredoc:
Warning
Prior to PHP 7.3.0, it is very important to note that the line with the closing identifier must contain no other characters, except a semicolon (;). That means especially that the identifier may not be indented, and there may not be any spaces or tabs before or after the semicolon. It's also important to realize that the first character before the closing identifier must be a newline as defined by the local operating system. This is \n on UNIX systems, including macOS. The closing delimiter must also be followed by a newline.
So it's only the semicolon allowed which won't work here 😞
|
@gziolo This needs test coverage for |
|
Will need #5242 to eventually pass the parent arg to |
gziolo
left a comment
There was a problem hiding this comment.
insert_hooked_block seems ready to go.
| <!-- /wp:paragraph --> | ||
| </div> | ||
| <!-- /wp:tests/group --> | ||
| HTML |
There was a problem hiding this comment.
Yes, that is a bit annoying. Usually, you need to put the string in its variable to use Heredoc:
Warning
Prior to PHP 7.3.0, it is very important to note that the line with the closing identifier must contain no other characters, except a semicolon (;). That means especially that the identifier may not be indented, and there may not be any spaces or tabs before or after the semicolon. It's also important to realize that the first character before the closing identifier must be a newline as defined by the local operating system. This is \n on UNIX systems, including macOS. The closing delimiter must also be followed by a newline.
So it's only the semicolon allowed which won't work here 😞
|
I was considering doing one more thing: Split |
Might actually rename to |
a3ebe61 to
257e1a0
Compare
|
@gziolo Should be ready for review! I've changed it a lot, but I'm really happy with it now. It's much less specific to hooked blocks now, yet the functions are exactly the way we'll need them 😄 |
gziolo
left a comment
There was a problem hiding this comment.
I had a minor note about the return values that seem obsolete for the helper functions because they all mutate the first param, which is then returned. Anyway, I don't have strong feelings about it so if there is any reason to keep them, feel free to leave it as is.
|
Test failures seem unrelated, so maybe there is a need to rebase the PR. I like how the code is split now into smaller helper functions that are specialized and nicely encapsulate their task. One final note, they will be exposed in the dev docs portal, which I'm fine with. |
Yeah, looks like unit tests have been failing for all recent PRs 😕
Yeah, I think that's perfectly okay -- the functions are now generic enough that they might even come in handy for different purposes. |
3b18937 to
4812c96
Compare
099ad1b to
1c5c63e
Compare
For #59313, we need to implement functions to insert a given parsed block into another parsed block's inner blocks, and to prepend and append to that array, respectively. We will use those functions in combination with `traverse_and_serialize_blocks` (see #59327) to implement automatic insertion of hooked blocks into block templates and patterns. Props gziolo. Fixes #59385.
1c5c63e to
13aa0cf
Compare
|
Committed to Core in https://core.trac.wordpress.org/changeset/56618. |
See https://core.trac.wordpress.org/ticket/59313 and #5158.
Trac ticket: https://core.trac.wordpress.org/ticket/59385
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.