Add removeaccents for use in sanitize_title to remove accents from characters so that they can be used in permalinks. Bust the functionality in sanitize_title out into a replaceable filter.

git-svn-id: http://svn.automattic.com/wordpress/trunk@1333 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
rboren 2004-05-21 08:37:55 +00:00
parent 7f87f4c6d3
commit d267a0f119
1 changed files with 31 additions and 14 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
add_action('sanitize_title', 'convert_spaces_to_dashes'); add_action('sanitize_title', 'sanitize_title_with_dashes');
function wptexturize($text) { function wptexturize($text) {
$output = ''; $output = '';
@ -78,21 +78,38 @@ function wpautop($pee, $br = 1) {
return $pee; return $pee;
} }
function sanitize_title($title) { function removeaccents($string){
$title = strtolower($title); $encoded_ligatures = array('Þ' => 'TH', 'þ' => 'th', 'Ð' => 'DH',
$title = preg_replace('/&.+?;/', '', $title); // kill entities 'ð' => 'dh', 'ß' => 'ss', 'Œ' => 'OE',
$title = preg_replace('/[^a-z0-9 _-]/', '', $title); '°' => 'oe', 'Æ' => 'AE', 'æ' => 'ae',
$title = do_action('sanitize_title', $title); 'µ' => 'u');
$title = trim($title);
return $title; foreach ($encoded_ligatures as $key => $value) {
$ligatures[utf8_decode($key)] = $value;
}
return strtr(strtr($string,
utf8_decode('ŠŽšžŸÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖØÙÚÛÜÝàáâãäåçèéêëìíîïñòóôõöøùúûüýÿ'),
'SZszYAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy'), $ligatures);
} }
function convert_spaces_to_dashes($content) { function sanitize_title($title) {
$content = preg_replace('/\s+/', ' ', $content); $title = do_action('sanitize_title', $title);
$content = str_replace(' ', '-', $content);
$content = preg_replace('|-+|', '-', $content);
return $content; return $title;
}
function sanitize_title_with_dashes($title) {
$title = removeaccents($title);
$title = strtolower($title);
$title = preg_replace('/&.+?;/', '', $title); // kill entities
$title = preg_replace('/[^a-z0-9 _-]/', '', $title);
$title = preg_replace('/\s+/', ' ', $title);
$title = str_replace(' ', '-', $title);
$title = preg_replace('|-+|', '-', $title);
$title = trim($title);
return $title;
} }
function convert_chars($content, $flag = 'obsolete') { function convert_chars($content, $flag = 'obsolete') {