WordPress.org

Support

Support » Requests and Feedback » Please give us the option to turn of smart “quotes”

Please give us the option to turn of smart “quotes”

  • harishankar
    Member

    @harishankar

    Smart quotes make pasted code useless. Most programming code uses just ordinary double quotes and single quotes. Using other characters renders posted code useless.

    I hope the WP developers give us a way to turn off smart quotes, because it’s a serious problem when you paste code on your blog and expect users to have to manually convert the quotes to ordinary single and double quotes.

Viewing 14 replies - 1 through 14 (of 14 total)
  • Samuel Wood (Otto)
    WordPress.org Tech Dude

    @otto42

    Smart quotes are performed by the wptexturize function. You can disable them by determining what the filter is and disabling it in your theme.

    Example: Your post content is filtered through “the_content”. So you want to turn off wptexturize for that filter. You do so by adding this to your theme’s functions.php file:
    remove_filter('the_content', 'wptexturize');

    If you wanted to do it for comments instead, you’d do this:
    remove_filter('comment_text', 'wptexturize');

    And so on. The idea is to figure out exactly where you want to remove the filter from.

    harishankar
    Member

    @harishankar

    I’ve created my own theme for my blog (from scratch) so I don’t have a functions.php file for it.

    Should I create one. Or can that line be added to index.php or header.php?

    Samuel Wood (Otto)
    WordPress.org Tech Dude

    @otto42

    No, it must be in functions.php. So just create one. Make sure that it starts with <?php and ends with ?> and has NO blank lines or whitespace outside of those tags. The file must not produce any output.

    harishankar
    Member

    @harishankar

    Thank you. I will try it out.

    There’s also the option of using one of the plugins that do this automatically for you…

    Try TextControl for one, which will let you change it globally, or Alex King has one that does it post by post with custom settings.

    All you need to do is do a google search, that’s what I did.

    viciouslime
    Member

    @viciouslime

    Thank you so much for this thread!!!

    amandabee
    Member

    @amandabee

    Thanks.

    I’m spamming this thread with keywords in case anyone else is looking for this by searching for help turning of extended characters or fancy quotes or curly quotes.

    Got that? extended characters or fancy quotes or curly quotes — these terms are wrong! You should be searching for smart quotes.

    alexgenaud
    Member

    @alexgenaud

    Thanks everyone. This post was very useful to me. In addition, I’ve found ampersand (&) conversion to the numeric character reference 038 very annoying. Disabling wptexturize does not do the trick.

    grep -r 038 wp-*

    Added lines to ‘wp-includes/formatting.php’ line 396 (WordPress 2.2.2) (ironically, the code below is likely to get messed up):

    // Converts lone & characters into & (a.k.a. &amp;)
    $content = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/i', '&#038;$1', $content);
    // unless it's lead by double hashes
    $content = str_replace('##&#038;', '&', $content);

    Now, whenever I need a real ampersand I precede it with two hashes (##&). I don’t suppose that’s “the right thing” to do. Any other suggestions?

    mlanger
    Member

    @mlanger

    I’d just like WordPress to automatically turn off smart quotes for any text within <code></code> tags. Is there any way to hack WordPress to get that effect? I don’t mind typing in the codes for other stuff (like < and >).

    StrangeAttractor
    Member

    @strangeattractor

    There’s a plugin called WP-untexturize. That did the trick for me.

    I agree that this should be something you can turn off without a plug-in, though — it’s annoying that smart quotes are the default. Smart quotes look bad with certain fonts, and also can mess up apostrophes.

    You can find the plugin here:

    Plugin: wpuntexturize

    I just released a plugin that disables smart quotes (currently only apostrophes and quotation marks) only within code blocks. I’d love to get your feedback on it. It can be downloaded from my site: http://www.planetmike.com

    ffosterdd
    Member

    @ffosterdd

    I just released a plugin that disables smart quotes (currently only apostrophes and quotation marks) only within code blocks. I’d love to get your feedback on it. It can be downloaded from my site: http://www.planetmike.com

    It took me a while to find the quote, for others you may have more downloaders if you link directly to the page of this plugin.

    ffosterdd
    Member

    @ffosterdd

    or I guess I could do it for you: (http://www.planetmike.com/plugins/codequote/)

    Smart quotes are great, and should be on by default, but they should be turned off within code and pre tags, and there should be a tag for turning them off in other situations.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Please give us the option to turn of smart “quotes”’ is closed to new replies.