Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#30856 closed enhancement (invalid)

Automatically replace erroneous curly quotes with straight quotes in shortcodes

Reported by: mauteri's profile mauteri Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Shortcodes Keywords: has-patch
Focuses: Cc:

Description

A common error among users I found is that some shortcodes they include in posts contain curly quotes rather than straight quotes for attributes.

An example of this that I just received this weekend from work:
[ione_social_wall id="544aa6d44b76c”]

As you can see, the second quote is a curly quote and can be easily missed if you don't look at it carefully.

I've included a diff for this. I placed the code in formatting.php in wptexturize. If there's a better place, let me know and I'll supply another diff.

Attachments (2)

30856.diff (814 bytes) - added by mauteri 9 years ago.
Adds a str_replace in wptexturize to replace curly quotes with straight quotes in shortcodes
30856.1.diff (1.5 KB) - added by mauteri 9 years ago.
Made this one a bit smarter with a bail feature if it breaks the shortcode.

Download all attachments as: .zip

Change History (6)

@mauteri
9 years ago

Adds a str_replace in wptexturize to replace curly quotes with straight quotes in shortcodes

#1 @mauteri
9 years ago

  • Keywords has-patch added

#2 @GaryJ
9 years ago

  • Keywords needs-patch added; has-patch removed

I think the replacement may need to be a little cleverer if it's going to be done there. Consider something like

[song title='Don’t leave me this way']
----------------^ = curly

which would end up as:

[song title='Don't leave me this way']

@mauteri
9 years ago

Made this one a bit smarter with a bail feature if it breaks the shortcode.

#3 @mauteri
9 years ago

  • Keywords has-patch added; needs-patch removed

Thanks for the feedback.

I've provided a new diff (30856.1.diff) to cover the example you provided. I also put in a bail feature for situations like

[song title='Don’t leave peoples’ shortcodes this way']
--------------------------------^ = script will think curly space is end of attribute value and don't want that

In the rare cases above, the script will just bail and not try to clean up curly quotes. Let me know your thoughts and if you think something like this would work here.

#4 @miqrogroove
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed
  • Version 4.2 deleted

For support, please visit https://wordpress.org/support/

Note: See TracTickets for help on using tickets.