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):
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.
wptexturize()
(inwp-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
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:But there are other, non-filter uses as well, such as:
get_archives_link()
gallery_shortcode()
(See more here.)