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

Decode hmtl entities in placeholders #5557

Merged
merged 1 commit into from
Mar 14, 2018

Conversation

jahvi
Copy link
Contributor

@jahvi jahvi commented Mar 11, 2018

Description

This is my attempt at fixing #4933, I'm using decodeEntities to decode special HTML characters that might be present on the post title / content when using custom placeholders using the write_your_story or enter_title_here filters.

How Has This Been Tested?

  1. Set new post title and content placeholder using special characters.
  2. Checked that the placeholders render the special character itself and not the entity code.

Screenshots (jpeg or gifs if applicable):

Before After
screen shot 2018-03-11 at 3 47 31 pm screen shot 2018-03-11 at 3 49 01 pm

Types of changes

Fixes #4933

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code has proper inline documentation.

@jahvi jahvi force-pushed the fix/decode-entities-in-placeholders branch from cc26f8b to b22a072 Compare March 11, 2018 15:58
Copy link
Member

@aduth aduth left a comment

Choose a reason for hiding this comment

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

Looks good, thanks. Left one question.

@@ -24,7 +25,7 @@ export function DefaultBlockAppender( { isLocked, isVisible, onAppend, showPromp
return null;
}

const value = placeholder || __( 'Write your story' );
const value = decodeEntities( placeholder ) || __( 'Write your story' );
Copy link
Member

Choose a reason for hiding this comment

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

Should we decode entities in the translated string as well, in case the translation includes entities?

Might speak to a broader point of whether we should want to bake this into the behavior of __ automatically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Baking it into __ automatically sounds like a good idea, I wonder if there's a case where you wouldn't want this in a translation.

@jahvi
Copy link
Contributor Author

jahvi commented Mar 13, 2018

Looks like #5490 can potentially take care of encoding __ strings, as mentioned in #4933 it might be worth changing this to a filter instead, I can change my PR if that's the best way to go.

@aduth aduth force-pushed the fix/decode-entities-in-placeholders branch from b22a072 to d369943 Compare March 14, 2018 00:46
@aduth aduth merged commit 29e8b54 into WordPress:master Mar 14, 2018
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.

The enter_title_here and escaped HTML might display encoded characters
2 participants