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