wpuntexturize

Description

By default, WordPress converts single and double quotation marks into their curly alternatives. This plugin prevents that from happening, so you can enjoy your quotation marks in their non-curly glory. If your content happens to already have curly quotation marks in it, then this plugin can optionally also convert them to their non-curly alternatives.

Note: Despite the unfortunately misleading name, this plugin is NOT the antithesis of WordPress’s wptexturize() function. This ONLY prevents WordPress from making HTML entity code substitutions of single and double quotation marks with their curly alternatives and does NOT prevent wptexturize() from making any other character and string substitutions. See the FAQ for details on the filters processed by the plugin.

Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage

Hooks

The plugin is further customizable via four hooks. Such code should ideally be put into a mu-plugin or site-specific plugin (which is beyond the scope of this readme to explain).

c2c_wpuntexturize (filter)

The ‘c2c_wpuntexturize’ filter allows you to use an alternative approach to safely invoke c2c_wpuntexturize() in such a way that if the plugin were deactivated or deleted, then your calls to the function won’t cause errors in your site. This only applies if you use the function directly, which is not typical usage for most users.

Arguments:

  • Kessú Nái

Example:

Instead of:

<?php echo c2c_wpuntexturize( $mytext ); ?>

Do:

<?php echo apply_filters( 'c2c_wpuntexturize', $mytext ); ?>

wpuntexturize_filters (filter)

The ‘wpuntexturize_filters’ filter allows you to customize what filters to hook to be filtered with wpuntexturize. See the Description section for a complete list of all filters that are filtered by default.

Arguments:

  • array $filters : the default array of filters

Example:

/**
 * Add additional filters to get wpuntexturize'd.
 *
 * @param array $filters Filters that will receive the wpuntexturize treatement.
 * @return array
 */
function more_wpuntexturize_filters( $filters ) {
    $filters[] = 'event_description';
    return $filters;
}
add_filter( 'wpuntexturize_filters', 'more_wpuntexturize_filters' );

c2c_wpuntexturize_replacements (filter)

The ‘c2c_wpuntexturize_replacements’ filter allows you to customize the character replacements handled by the plugin.

Arguments:

  • array $replacements : Array where the keys are the characters to be replace, and the values are their respective replacements.

Example:

/**
 * Add and remove to/from default wpuntexturize replacements.
 *
 * @param array $replacements
 * @return array
 */
function c2c_change_wpuntexturize_replacements( $replacements ) {
    // Remove low 9 quotation mark replacements.
    unset( $replacements['‚'] );
    unset( $replacements['„'] );

    // Replace copyright.
    $replacements['&copy;'] = '(c)';

    return $replacements;
}
add_filter( 'c2c_wpuntexturize_replacements', 'c2c_change_wpuntexturize_replacements' );

c2c_wpuntexturize_convert_curly_quotes (filter)

The ‘c2c_wpuntexturize_convert_curly_quotes’ filter allows you to prevent curly quotes from being converted into their non-curly alternatives.

Arguments:

  • boolean $convert : Convert preexisting curly quotes? Default true.

Example:

// Don't convert curly quotes into non-curly quotes.
add_filter( 'c2c_wpuntexturize_convert_curly_quotes', '__return_false' );

Screenshots

  • A screenshot of the plugin's checkbox on the Settings -> Reading admin page. If checked, the plugin will convert existing curly quotation marks into their non-curly alternatives.

Installation

  1. Install via the built-in WordPress plugin installer. Or download and unzip wpuntexturize.zip inside the plugins directory for your site (typically wp-content/plugins/)
  2. Activate the plugin through the ‘Plugins’ admin menu in WordPress
  3. Optional: If you want to also convert existing curly quotation marks within posts to their non-curly alternatives, then on the Settings -> Reading admin page check the checkbox labeled “Convert existing curly quotes in posts to their non-curly alternatives”. (Reminder that the plugin will always prevent WordPress from converting non-curly quotation marks to the curly alternatives.)

FAQ

Why are certain characters in my posts still being replaced by their HTML entity encoded version?

This ONLY prevents WordPress from making HTML entity code substitutions of single and double quotation marks with their curly alternatives and does NOT prevent WordPress from making any other character and string substitutions.

Why do I still see curly quotation marks in my posts?

Most likely these curly quotes are actually present in your originally post content and are being directly shown to visitors. WordPress isn’t converting these to curly quotes since they are already that way. This could happen if you copy-and-pasted text from another source.

If you don’t want any curly quotes to appear in your posts at all, then on the Settings -> Reading admin page check the checkbox labeled “Convert existing curly quotes in posts to their non-curly alternatives”.

What text does this plugin modify/filter?

This plugin potentially modifies the post content, excerpt, title, comment text, widget text, and more.

More specifically, it performs a wpuntexturize on every filter that WordPress applies the wptexturize to by default. This list comprises:

comment_author, term_name, link_name, link_description, link_notes, bloginfo, wp_title, widget_title, single_post_title, single_cat_title, single_tag_title, single_month_title, nav_menu_attr_title, nav_menu_description, term_description, get_the_post_type_description, the_post_thumbnail_caption, the_title, the_content, the_excerpt, the_excerpt_embed, comment_text, list_cats, widget_text, widget_text_content

This complete list can be filtered via wpuntexturize’s own filter, wpuntexturize_filters.

Does this plugin include unit tests?

Yes.

Reviews

Mee 16, 2020
This issue was very quickly resolved by the developer. I'm very impressed by the quick response and the plugin works great. Upped to 5-stars. --- When I type straight quotes in a post, this plugin does keep them straight, which is nice. However, when I type in curly quotes in a post, this plugin straightens them, which is not nice. In my work, a curly quote and a straight quote are semantically different, and must display as such. I would just like to have displayed what I type.
Maarec 31, 2020
Since v1.7 (2019-05-28), this plugin flattens out curly-quotes that I intentionally typed. This behaviour cannot be disabled from the UI—it can only be "configured" by way of writing a separate ad-hoc plugin. Hopefully, this gets fixed in the next release. I had hoped to get a plugin that would just leave my quotes alone / as I type them…
Séptembor 24, 2018
Not sure why everyone is saying this works, it don't. I'm still getting question marks in replace of hypens and apostrophe's that come out like this full-time = full?time apostrophe's = apostrophe?s anyone know of any plugins that fix this? my config file is set to UTF8, still getting these annoying things showing up. cheers
Read all 10 reviews

Contributors & Developers

“wpuntexturize” is open source software. The following people have contributed to this plugin.

Contributors

Translate “wpuntexturize” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

Changelog

2.0 (2020-05-15)

Highlights:

  • Recommended update that reverts an ill-advised change in default behavior added in v1.7 that automatically converted existing curly quotation marks into their non-curly alternatives. This behavior is now disabled by default, but can be optionally enabled on the Settings -> Reading admin page via the checkbox labeled “Convert existing curly quotes in posts to their non-curly alternatives”.
  • Additionally, much of the plugin’s code has been reorganized, the long-deprecated wpuntexturize() has been removed, a few URLs were updated to be HTTPS, and compatibility through WP 5.4+ has been noted.

Details:

  • Change: Revert default uncurling of native curly quotes and make it an optional behavior controlled by new setting
    • New: Add setting to Settings -> Reading page
    • New: Add “Settings” link to plugin’s action links in admin listing of plugins
    • New: Add initialize_setting(), whitelist_options(), display_option(), should_convert_native_quotes(), plugin_action_links()
    • Change: Switch default for converting native curly quotes to false
    • Change: Update plugin description and documentation to reflect new behavior
  • New: Add class c2c_wpuntexturize to encapsulate new (largely admin-related) and existing functionality
    • New: Add version(), init()
  • Change: Extract logic for determining if native curly quotes should be handled into should_convert_native_quotes()
  • Change: Extract code for getting the list of replacements into get_replacements()
  • Change: Remove function c2c_init_wpuntexturize() (its functionality added to init())
  • Change: Remove function c2c_wpuntexturize_get_default_filters() (moved to class function get_default_filters())
  • Change: Remove deprecated function wpuntexturize() and its associated filter wpuntexturize
  • Change: Use HTTPS for link to WP SVN repository in bin script for configuring unit tests
  • Change: Note compatibility through WP 5.4+
  • Change: Update links to coffee2code.com to be HTTPS
  • Change: Unit tests: Remove unnecessary unregistering of hooks, and thus tearDown()
  • New: Add a screenshot

1.7.1 (2019-11-12)

  • Change: Note compatibility through WP 5.3+
  • Change: Use full URL for readme.txt link to full changelog
  • Change: Update copyright date (2020)

1.7 (2019-05-28)

  • New: Convert native curly quotation marks to their non-curly alternatives
  • New: Add filter c2c_wpuntexturize_convert_curly_quotes to allow disabling of conversion of native curly quotes
  • New: Untexturize three recently introduced core filters: get_the_post_type_description, the_post_thumbnail_caption, widget_text_content
  • New: Add CHANGELOG.md and move all but most recent changelog entries into it
  • Change: Update unit test install script and bootstrap to use latest WP unit test repo
  • Change: Note compatibility through WP 5.2+
  • Fix: Correct typo in GitHub URL
  • Change: Modify formatting of hook name in readme to prevent being uppercased when shown in the Plugin Directory
  • Change: Split paragraph in README.md’s “Support” section into two
  • Change: Remove extra space character between some sentences

Full changelog is available in CHANGELOG.md.