Skip Navigation

[Resolved] Toolset WooCommerce Views plugin makes curly quotes straight in Classic Editor

This support ticket is created 5 years, 1 month 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/Karachi (GMT+05:00)

This topic contains 5 replies, has 2 voices.

Last updated by willD-2 5 years, 1 month ago.

Assisted by: Waqar.

Author
Posts
#1603929
Screen Shot 2020-04-28 at 10.59.43.png
Screen Shot 2020-04-28 at 10.59.05.png

Hi,

I hope you can help – I've been pulling my hair out all morning to try and work out why rich text entered into the classic-editor cell on a CPT is displaying oddly. The issue is that all of the apostrophes and speech marks were displaying as straight rather than curly. I did the usual checks, and turned plugins off one by one, and it seems that Toolset WooCommerce Views plugin is the culprit – if it's deactivated the post type has curly quotes and apostrophes, but if I activate it again they become straight – you can see what I mean in the two screenshots attached.

I've done lots of Googling and can't find any answers, so hope you have a fix!

Thanks,

Will

#1605115

Hi Will,

Thank you for contacting us and I'd be happy to assist.

I've performed some initial tests on my website, but couldn't reproduce this behavior.
( used a number of curly quotes and apostrophes characters from this chart at hidden link )

Can you please share temporary admin login details, along with the link to a page where these characters can be seen?

Note: Your next reply will be private and please make a complete backup copy, before sharing the access details.

regards,
Waqar

#1607051

Hi Will,

Thank you for sharing the admin access.

To test, I copied a curly quote character from the chart mentioned in my last reply ( screenshot: hidden link ) and pasted it in the content of the author post "Eliza Haywood", which stayed as it is:
( hidden link )

Back-end: hidden link
Front-end: hidden link

Likewise, if you'll check the product post "Fantomina", you'll note that different characters have been saved in the text of the reviews:
( hidden link )
Back-end: hidden link

And they are shown on the front-end correctly too:
Front-end: hidden link

Note: The different fonts can show these characters differently, so in case of any confusion, it is best to copy them first into any standard text editor to see how they're rendered in a standard environment.

Please let me know if you still feel something is out of place along with the exact steps to replicate and I'll perform further investigation.

regards,
Waqar

#1607067

Hi Waqar,

Unfortunately this doesn't answer my question – I know I can look up the correct smart quotes, but that takes time. I'm sure you know this already, so forgive me for lecturing, but normally in WordPress you can type an apostrophe or quote marks with your keyboard, and they are output correctly as curly quote marks. The Toolset Woocommerce Views plugin prevents this from working – if you deactivate the plugin and navigate to the page, the curly quotes are displayed correctly; if you activate the plugin again, the curly quotes translate back into straight quotes. As this is a content-heavy site, I can't keep looking up the html entities every time I need an apostrophe – and it seems to me that, since the text looks fine when the plugin is deactivated, it must be a glitch.

Is there anything you can do to help fix this?

Best wishes,

Will

#1608219

Hi Will,

Thank you for sharing further details and for clearing this up.

I've performed some testing and research and here are my findings:

1. Your expectation of automatic conversion of straight quotes into curly ones is correct for the text coming from the post's content/body, as WordPress applies "wptexturize" filter for some special formatting rules.

You can read more about that filter from these resources:
https://developer.wordpress.org/reference/functions/wptexturize/
hidden link

However, this filter is not applied to the text coming from the custom fields and from shortcodes, and for that text's automatic formatting, you'll need some custom function or shortcode.

2. Your observation is correct about the Toolset WooCommerce Views plugin too.

In my tests, I was able to reproduce this behavior that if Toolset WooCommerce Views plugin is active, this special formatting is not applied to the post's content/body, if it is being shown through a layout.

I've shared this report to concerned team for further review and will keep you updated through this ticket.

3. I managed to make this automatic formatting work for text coming from custom fields and post/body, using a custom shortcode:


add_shortcode('get-texturize-output', 'get_texturize_output_fn');
function get_texturize_output_fn($atts) {

	$a = shortcode_atts( array(
		'field' => '',
		'id' => '',
	), $atts );

	if ($a['field'] == 'body') {
		$content = apply_filters( 'the_content', get_the_content() );
		$content = wptexturize( $content );
	}
	else
	{
		$content = wptexturize( get_post_meta( $a['id'],$a['field'],true) );
	}

	ob_start();
	echo $content;
	return ob_get_clean();
}

The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through active theme's "functions.php" file.

This shortcode accepts two attributes "id" and "field".

To get the current post's content/body in your layout, you can use:


[get-texturize-output field="body" id="[wpv-post-id]"]

And to get the current post's custom field value, you can use:


[get-texturize-output field="wpcf-field-slug" id="[wpv-post-id]"]

Note: you'll replace "field-slug" with the actual slug of your desired custom field.

I hope this helps and please let me know how it goes.

regards,
Waqar

#1608239

Hi Waqar,

Many thanks for this – if I use the shortcode that fixes everything for me – I'll use that in future instead of the post body field slug. Very strange! But glad you managed to find something to sort it out.

All best, and thanks again,

Will