-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Block: Implement block insertion functions #5240
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PHP 7.0 didn't like the trailing comma 😕
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.
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 |
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.
insert_hooked_block
seems ready to go.
<!-- /wp:paragraph --> | ||
</div> | ||
<!-- /wp:tests/group --> | ||
HTML |
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.
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 😄 |
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 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.