Block Bindings: Add private HTML API subclass with experimental set_inner_html#7742
Block Bindings: Add private HTML API subclass with experimental set_inner_html#7742sirreal wants to merge 7 commits intoWordPress:trunkfrom
Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
src/wp-includes/class-wp-block.php
Outdated
| */ | ||
| class PrivateProcessor extends WP_HTML_Processor { | ||
|
|
||
| public function set_inner_html( ?string $html ) { |
There was a problem hiding this comment.
This method allows does "naive" inner HTML replacement, where the content that should be inside the node can change the HTML tree beyond the node.
This is also true with the existing implementation so it's not a regression and can be dealt with now or in follow-up work.
| * | ||
| * @access private | ||
| */ | ||
| class PrivateProcessor extends WP_HTML_Processor { |
There was a problem hiding this comment.
#6838 uses a pattern for a private processor class:
wordpress-develop/src/wp-includes/class-wp-block.php
Lines 338 to 341 in 825f78e
|
Nice progress here. In #6838, an HTML API subclass was explored to add support for a new Image attribute. It might be interesting to use it as a reference and potentially borrow the unit test when playing with it. |
2703671 to
058d473
Compare
| /*}*/ | ||
|
|
||
| if ( '' !== $html ) { | ||
| $fragment_parser = $this->create_fragment_at_current_node( $html ); |
There was a problem hiding this comment.
I was testing the pull request, and it seems this method is private. If I change it to protected, everything seems to work as expected.
There was a problem hiding this comment.
Thank you! The changes (that I rebased this on) were partially reverted. This method may become public again in #7912.
For now we can make it protected as part of this PR.
Depends on #7348
Uses an implementation from sirreal#9
Trac 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.