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

Avoid get_the_title texturization when auto-composing tweet #73

Merged
merged 2 commits into from
Feb 3, 2020

Conversation

johnwatkins0
Copy link
Member

@johnwatkins0 johnwatkins0 commented Jan 30, 2020

Description of the Change

This would close #72 .

@rickalee Discovered that some undecoded special characters (hyphens/dashes and quotation marks, specifically) were appearing in tweets generated by this plugin. On closer inspection, I found that the WP core function get_the_title was being used to generate the tweet body. That function applies several filters, one of which (unless overridden) is wptexturize. This is where the characters were coming from.

To fix it, I removed get_the_title in favor of accessing post_title from the WP post object directly.

This issue only occurred when the post title was tweeted, not when custom share text was entered.

Alternate Designs

We could alternatively continue to use get_the_title and selectively disable only the default filters causing the character issues. In this scenario, though, we would need to immediately re-add any removed filters to avoid causing side effects elsewhere, and this could become complicated. Probably not worth the effort.

Benefits

Characters in Tweets appear as expected.

Possible Drawbacks

Verification Process

Create a post whose title contains dashes and quotation marks. Turn on autosharing for the post. Publish the post. Verify that the characters appear as expected.

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests passed.

Applicable Issues

Resolves #72

Changelog Entry

Bypass character texturization when the post title is tweeted

@johnwatkins0 johnwatkins0 marked this pull request as ready for review January 30, 2020 23:17
@johnwatkins0 johnwatkins0 self-assigned this Jan 30, 2020
@johnwatkins0 johnwatkins0 added this to the 1.1.0 milestone Jan 30, 2020
@johnwatkins0 johnwatkins0 added the type:bug Something isn't working. label Jan 30, 2020
@jeffpaul jeffpaul requested a review from dinhtungdu January 31, 2020 00:22
Copy link
Contributor

@dinhtungdu dinhtungdu left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@johnwatkins0 johnwatkins0 merged commit 2547668 into develop Feb 3, 2020
@johnwatkins0 johnwatkins0 deleted the fix/characters-in-tweet branch February 3, 2020 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Escaped characters appearing in tweets
2 participants