Safe to disable wptexturize?

To optimise the speed of my platform (beyond caching, database optimisation, JPEG compression, CSS sprites etc), it has come to my attention that disabling the wptexturize() function may give some minor results.

We can disable this function by using this script (written by our own “observer of everything” toscho):

Read More
foreach ( array (
        'bloginfo'
    ,   'comment_text'
    ,   'comment_author'
    ,   'link_name'
    ,   'link_description'
    ,   'link_notes'
    ,   'list_cats'
    ,   'single_post_title'
    ,   'single_cat_title'
    ,   'single_tag_title'
    ,   'single_month_title'
    ,   'term_description'
    ,   'term_name'
    ,   'the_content'
    ,   'the_excerpt'
    ,   'the_title'
    ,   'nav_menu_attr_title'
    ,   'nav_menu_description'
    ,   'widget_title'
    ,   'wp_title'
    ) as $target )
{
    remove_filter( $target, 'wptexturize', 40 );
}

My question is, how safe is it to disable wptexturize()? When is this function being used? What should I consider when disabling it? The codex page gives an overview but doesn’t detail when it is being used.

Related posts

Leave a Reply

2 comments

  1. wptexturize() (in wp-includes/formatting.php) tries to convert typewriter quotes " and ' into typographically correct pendants like “ or «, depending on current translation files.

    If you cannot type correct quotes, you should not disable it.

    There are some related replacements for dashes and ellipsis (not localized for whatever reason).

    All these replacement are done with expensive regexes, and they are not really safe. <samp>$var["foo"]</samp> for example will be changed, but it shouldn’t.

    Disabling it does no harm, the function is not essential for anything else.

    See also: Ticket #19550 Please provide option to disable wptexturize entirely

  2. Yes, it is absolutely safe to remove the wp_texturize() filter.

    Generally, it is only used as a filter callback. You can see those uses here. Note that you’ll have several remove_filter() calls to make:

    $texturized_text = array(
        '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', 'the_title', 'the_content','the_excerpt', 'comment_text', 'list_cats'
    );
    foreach ( $texturized_text as $text ) {
        remove_filter( $text, 'wptexturize' );
    }
    

    But there are other, non-filter uses as well, such as:

    (See more here.)