Last active
August 29, 2015 14:08
-
-
Save Zodiac1978/05361a79c0bb3085be3e to your computer and use it in GitHub Desktop.
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 | |
function tl_umlaut_repair( $content ) { | |
/* | |
* Why? | |
* For everyone getting this warning from W3C: "Text run is not in Unicode Normalization Form C." | |
* http://www.w3.org/International/docs/charmod-norm/#choice-of-normalization-form | |
*/ | |
/* | |
* See: http://www.fileformat.info/info/unicode/char/0308/index.htm | |
*/ | |
$content = str_replace( "a\xCC\x88", "ä", $content ); | |
$content = str_replace( "o\xCC\x88", "ö", $content ); | |
$content = str_replace( "u\xCC\x88", "ü", $content ); | |
$content = str_replace( "A\xCC\x88", "Ä", $content ); | |
$content = str_replace( "O\xCC\x88", "Ö", $content ); | |
$content = str_replace( "U\xCC\x88", "Ü", $content ); | |
/* | |
* Requires PHP 5.3+ | |
* Be sure to have the PHP-Normalizer-extension (intl and icu) installed. | |
* See: http://php.net/manual/de/normalizer.normalize.php | |
*/ | |
// $content = normalizer_normalize($content, Normalizer::FORM_C ); | |
return $content; | |
} | |
add_filter( 'content_save_pre', 'tl_umlaut_repair', 10, 1 ); | |
function tl_umlaut_repair_title( $title ) { | |
// Repair post title | |
$title = normalizer_normalize( $title, Normalizer::FORM_C ); | |
return $data; | |
} | |
add_filter( 'title_save_pre' , 'tl_umlaut_repair_title' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment