Created
December 6, 2012 21:14
-
-
Save thefuxia/4228493 to your computer and use it in GitHub Desktop.
T5 Strip double spaces in posts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: T5 Strip double spaces in posts | |
* Description: Replaces [space + no-break-space] with a regular space. | |
* Plugin URI: http://wordpress.stackexchange.com/questions/75197/remove-double-space-after-a-period | |
* Version: 2012.12.06 | |
* Author: Thomas Scholz | |
* Author URI: http://toscho.de | |
* Licence: MIT | |
* License URI: http://opensource.org/licenses/MIT | |
*/ | |
add_filter( 'wp_insert_post_data', 't5_strip_double_spaces', 20 ); | |
/** | |
* Filter post content. | |
* | |
* @wp-hook wp_insert_post_data | |
* @param array $data | |
* @return array | |
*/ | |
function t5_strip_double_spaces( $data ) | |
{ | |
// see http://www.fileformat.info/info/unicode/char/a0/index.htm | |
$pattern = "~ \x{C2}\x{A0}~m"; | |
$data['post_content'] = preg_replace( $pattern, ' ', $data['post_content'] ); | |
return $data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment