wpuntexturize

Author:Scott Reilly
Version:1.7
First released:2009-05-28
Last update:2019-06-11
Compatibility:WP 1.5 – 5.2.2
Download:[ zip ]
Description:

Prevent WordPress from displaying single and double quotation marks as their curly alternatives.

Extended 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 also converts 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:

  • none

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' );

Find out more at the plugin’s WordPress Plugin Repository page.

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

Frequently Asked Questions

Q. Why are certain characters in my posts still being replaced by their HTML entity encoded version?
A. 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.

Q. What text does this plugin modify/filter?
A. 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.

Q. Does this plugin include unit tests?
A. Yes.

Release Log

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

1.6.3 (2019-03-04)

  • New: Add inline documentation for hooks
  • Change: Rename readme.txt section from ‘Filters’ to ‘Hooks’
  • Change: Note compatibility through WP 5.1+
  • Change: Update copyright date (2019)
  • Change: Update License URI to be HTTPS

1.6.2 (2017-11-09)

  • New: Add README.md
  • Change: Add GitHub link to readme
  • Change: Minor readme tweak regarding suggested location for custom code
  • Change: Note compatibility through WP 4.9+
  • Change: Update copyright date (2018)
  • Change: Minor whitespace tweaks in unit test bootstrap

Full changelog is available in [CHANGELOG.md](CHANGELOG.md).

Copyright & Disclaimer

Copyright © 2009-2019 by Scott Reilly (aka coffee2code)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Discussion / Support

Have any questions, comments, or suggestions? Please provide them via the plugin’s WordPress.org support forum. I’ll do my best to reply in a timely fashion and help as best I can.

Unfortunately, I cannot provide guaranteed support, nor do I provide support via any other means.

Was this plugin useful useful to you? Consider giving it a rating. If you’re inclined to give it a poor rating, please first post to the support forum to give me a chance to address or explain the situation.