Skip to content
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

Fix formats not working in block bindings content #58055

Merged

Conversation

talldan
Copy link
Contributor

@talldan talldan commented Jan 22, 2024

What?

Fixes #58053

Currently formats are not working for block bindings content. This PR attempts to resolve the issue.

How?

Currently esc_html is being used on any block content html. This PR switches to using wp_kses_post to allow a subset of safe html.

Testing Instructions

Prerequisite: Enable the pattern overrides experiment from the gutenberg experiment page.

  • Create a new post
  • Insert a mixture of blocks that include paragraphs and optionally other blocks too
  • Select the blocks, and 'Create a pattern' from the block options menu
  • Give the pattern a name and make it 'synced'
  • Click the 'Edit original' button on the toolbar
  • Select a paragraph block in the pattern, and in the block settings sidebar expand the advanced section. Check the 'Allow instance overrides' option
  • Use the 'Back' button in the header area of the editor to go back to the post
  • Edit the paragraph and add formats
  • View the post on the frontend

Screenshots or screencast

Before

Screenshot 2024-01-22 at 1 09 27 pm

After

Screenshot 2024-01-22 at 1 32 22 pm

@talldan talldan added [Type] Bug An existing feature does not function as intended [Feature] Block API API that allows to express the block paradigm. labels Jan 22, 2024
@talldan talldan self-assigned this Jan 22, 2024
Copy link

This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress.

If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged.

If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack.

Thank you! ❤️

View changed files
❔ lib/experimental/block-bindings/class-wp-block-bindings.php

Copy link

Flaky tests detected in bf62a61a7b90c447ea959ec4dd121dd0afec507c.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7606932279
📝 Reported issues:

@talldan talldan force-pushed the update/block-bindings-to-use-wp-kses-for-content branch from bf62a61 to a87b95b Compare January 23, 2024 00:05
Copy link
Contributor

@SantosGuillamot SantosGuillamot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested it, and it seems to work fine.

cc: @artemiomorales @michalczaplinski In case you have to apply this change in your ongoing PRs.

michalczaplinski added a commit to michalczaplinski/wordpress-develop that referenced this pull request Jan 23, 2024
@michalczaplinski michalczaplinski merged commit 987265a into trunk Jan 23, 2024
55 checks passed
@michalczaplinski michalczaplinski deleted the update/block-bindings-to-use-wp-kses-for-content branch January 23, 2024 17:51
@github-actions github-actions bot added this to the Gutenberg 17.6 milestone Jan 23, 2024
@michalczaplinski
Copy link
Contributor

cc: @artemiomorales @michalczaplinski In case you have to apply this change in your ongoing PRs.

Thanks, I've applied it in the Core backport 02f0ea3

@getdave
Copy link
Contributor

getdave commented Jan 26, 2024

@getdave getdave added the Backported to WP Core Pull request that has been successfully merged into WP Core label Feb 1, 2024
@getdave
Copy link
Contributor

getdave commented Feb 1, 2024

✅ I updated this PR with the Backported to Core label to indicate that the backport has successfully merged into WP Core. I also updated the PHP Sync Tracking Issue for WP 6.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backported to WP Core Pull request that has been successfully merged into WP Core [Feature] Block API API that allows to express the block paradigm. [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Block Bindings: Formats not supported in content
4 participants