19 Temmuz 2007, 11:21 tarihinde yazılmış olup, 886 kez okunmuş ve 1 yorum almış
Etiketler: Php, plogger
I am from Turkey and I use Turkish characters on gallery names. But I saw that, special Turkish characters not seen correct and folder name seens so bad.. So I change Plogger “sanitize_filename” function with WordPress “sanitize_title” function.. So every special characters convert into correct character (into english) ….
For example;
I => i
space => -
İ=>i
ş=>s
ö=>o
Applying patch
Open plog-functions.php file and find;
PHP:
-
function sanitize_filename($str) {
-
// allow only alphanumeric characters, hyphen, [, ], dot and apostrophe in file names
-
// the rest will be replaced
-
-
}
lines.. And than change it with following;
PHP:
-
/*
-
function sanitize_filename($str) {
-
// allow only alphanumeric characters, hyphen, [, ], dot and apostrophe in file names
-
// the rest will be replaced
-
return preg_replace("/[^\w|\.|'|\-|\[|\]]/","_",$str);
-
}
-
*/
And now go to last line in plog-functions.php file and add following functions before ?> lines.
PHP:
-
/* Fix for sanitize_filename , Hakan Demiray - http://www.dmry.net */
-
function sanitize_filename($title) {
-
-
// Preserve escaped octets.
-
$title =
preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|',
'---$1---',
$title);
-
// Remove percent signs that are not part of an octet.
-
-
// Restore octets.
-
$title =
preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|',
'%$1',
$title);
-
-
$title = plog_remove_accents($title);
-
if (plog_seems_utf8($title)) {
-
-
-
}
-
$title = plog_utf8_uri_encode($title, 200);
-
}
-
-
-
$title =
preg_replace('/&.+?;/',
'',
$title);
// kill entities
-
-
-
-
$title =
trim($title,
'-');
-
-
return $title;
-
}
-
-
-
-
function plog_remove_accents($string) {
-
-
return $string;
-
-
if (plog_seems_utf8($string)) {
-
-
// Decompositions for Latin-1 Supplement
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// Decompositions for Latin Extended-A
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-