Skip to content

Instantly share code, notes, and snippets.

@plasticmind
Created November 28, 2012 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plasticmind/4162908 to your computer and use it in GitHub Desktop.
Save plasticmind/4162908 to your computer and use it in GitHub Desktop.
Remove the second space after a period in WordPress posts
// See: http://www.jetmore.org/john/blog/2012/03/multiple-spaces-after-period-in-wordpress/
function gist_kill_double_space( $content ) {
if ( seems_utf8( $content ) ) {
$clean_content = preg_replace( '/[\p{Z}\s]{2,}/u', ' ', $content );
} else {
$clean_content = preg_replace( '/\s\s+/', ' ', $content );
}
return $clean_content;
}
add_filter( 'the_content', 'gist_kill_double_space' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment