[wp-trac] [WordPress Trac] #60671: If you hook some blocks with Block Hooks API, slashes are stripped from template part block attributes
WordPress Trac
noreply at wordpress.org
Mon Mar 11 14:12:36 UTC 2024
#60671: If you hook some blocks with Block Hooks API, slashes are stripped from
template part block attributes
-------------------------------------------------+-------------------------
Reporter: karolmanijak | Owner: Bernhard
| Reiter
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 6.5
Component: Revisions | Version: trunk
Severity: major | Resolution: fixed
Keywords: has-patch has-unit-tests dev- | Focuses:
reviewed commit |
-------------------------------------------------+-------------------------
Changes (by Bernhard Reiter):
* status: reopened => closed
* resolution: => fixed
Comment:
In [changeset:"57802" 57802]:
{{{
#!CommitTicketReference repository="" revision="57802"
Block Hooks: Use new Templates Controller filter instead of action.
This changeset adds a new `rest_pre_insert_{$this->post_type}` filter in
the `WP_REST_Templates_Controller`, where it is applied to the return
value of the `prepare_item_for_database` method. (This is consistent with
the `WP_REST_Post_Controller`, where that filter has existed before.)
The new filter is then used to inject hooked blocks into the template (or
template part) content received via the endpoint, prior to persisting it
to the database.
This supersedes the previous mechanism, which was using the
`rest_after_insert_{$this->post_type}` ''action'', from which it performed
an additional `wp_update_post` call to update the template (part) content
with the hooked blocks injected. The new technique eschews that additional
call and the resulting extra revision it created, as well as a problem
with regard to duplicated escaping and sanitization, which had caused some
special characters to be garbled.
Reviewed by swissspidy.
Merges [57790] to the to the 6.5 branch.
Props tomjcafferkey, gziolo, swissspidy, karolmanijak.
Fixes #60671.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60671#comment:20>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list