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: unescape Gutenberg title value #1497

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

eteubert
Copy link
Member

issue #1495

Get ready for some WordPress nonsense.

The Gutenberg editor has two modes: visual and code. We access the title data with its official API: select('core/editor').getEditedPostAttribute('title').

Scenario: User types Foo & Bar into the title field.

In the code mode (the one probably barely anyone uses), the behavior is as expected. The value is Foo & Bar.

In the visual mode, the value is ... 🥁 ... escaped! Foo & Bar!

So the user types the same thing, but the end value in the JS API is different, depending on a view mode? Makes total sense! Anyway, we use htmlEntities.decodeEntities then when accessing the title value to ensure the title is always unescaped. Looks fine in the frontend now (and that's the current state of this PR).

All good now? God no! Because WordPress actually persists the escaped title data in the database! So the title data in the feed is broken. Needs some more work and testing of various settings to ensure the value in the feed is always correct. And maybe check if only & is affected or also emojis etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant