Skip Navigation

[Resolved] Single Line Fields remove wptexturize on Single Quotes (apostrophes)

This support ticket is created 6 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 6 years, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#629795

Normally, in WYSIWYG/Body content, if you use 'apostrophes' it will automatically convert these to left/right single quotes. Most people around the internet don't want this. But in the case I DO!

When using a Single Line Field, there is no such wptexturize conversion. But I need this to happen. I can't get my users to input with special characters, and the apostrophes aren't look good.

SO:

Is there a function I can use to do this conversion? The 1st apostrophe would need to become a left single quote, and the second a right single quote. Plus, added bonus, if there is a second set also convert that.

Any thoughts on fixing this?

(I also don't want to use a WYSIWYG field because it's way too big and cumbersome and opens up many other new issues of what people might input incorrectly)

THANK IN ADVANCE!

#629893

Hello,

There isn't such a built-in feature within Toolsets, it needs custom codes, for example you can try these:
1) When user input text into custom single line field, and save the post, Use WordPress action hook save_post to trigger a custom PHP function:
https://codex.wordpress.org/Plugin_API/Action_Reference/save_post

2) In the custom PHP function, get the custom single line field value:
https://developer.wordpress.org/reference/functions/get_post_meta/
And change it to what you want:
https://developer.wordpress.org/reference/functions/update_post_meta/

#629912

Hi Luo,

Thank you for the links. I already understand those items (although direct reference links are always helpful since it's been a while).

Other than me running preg replace, do you think there is another option? Such as somehow connect into wptexturize? I've never dealt with that before and perhaps you can point me towards the correct approach.

#629917

There is a built-in function wptexturize() within WordPress core:
https://developer.wordpress.org/reference/functions/wptexturize/
Replaces common plain text characters into formatted entities

You can use it to change the text, in the step 2) I mentioned in post:
https://toolset.com/forums/topic/single-line-fields-remove-wptexturize-on-single-quotes-apostrophes/#post-629893

For your reference.