Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. /* define it global */
  2. $umlaut_chars['in'] = array( chr(196), chr(228), chr(214), chr(246), chr(220), chr(252), chr(223) );
  3. $umlaut_chars['ecto'] = array( 'Ä', 'ä', 'Ö', 'ö', 'Ü', 'ü', 'ß' );
  4. $umlaut_chars['html'] = array( 'Ä', 'ä', 'Ö', 'ö', 'Ü', 'ü', 'ß' );
  5. $umlaut_chars['feed'] = array( 'Ä', 'ä', 'Ö', 'ö', 'Ü', 'ü', 'ß' );
  6. $umlaut_chars['utf8'] = array( utf8_encode( 'Ä' ), utf8_encode( 'ä' ), utf8_encode( 'Ö' ), utf8_encode( 'ö' ),utf8_encode( 'Ü' ), utf8_encode( 'ü' ), utf8_encode( 'ß' ) );
  7. $umlaut_chars['perma'] = array( 'Ae', 'ae', 'Oe', 'oe', 'Ue', 'ue', 'ss' );
  8.  
  9. /* sanitizes the titles to get qualified german permalinks with correct transliteration */
  10. function de_DE_umlaut_permalinks($title) {
  11. global $umlaut_chars;
  12.  
  13. if ( seems_utf8($title) ) {
  14. $invalid_latin_chars = array( chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe', chr(197).chr(160) => 'S', chr(197).chr(189) => 'Z', chr(197).chr(161) => 's', chr(197).chr(190) => 'z', chr(226).chr(130).chr(172) => 'E' );
  15. $title = utf8_decode( strtr($title, $invalid_latin_chars) );
  16. }
  17.  
  18. $title = str_replace($umlaut_chars['ecto'], $umlaut_chars['perma'], $title );
  19. $title = str_replace($umlaut_chars['in'], $umlaut_chars['perma'], $title );
  20. $title = str_replace($umlaut_chars['html'], $umlaut_chars['perma'], $title );
  21. $title = sanitize_title_with_dashes($title);
  22.  
  23. return $title;
  24. }
  25. add_filter( 'sanitize_title', 'de_DE_umlaut_permalinks' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement