Archive for the ‘Wordpress’ Category

<?php
/*

Plugin Name: cp1251 to utf8 Mongolian cryllic

*/
function cp1251_utf8($word)
{
$cyr_lower_chars = array(
‘е’,’щ’,’ф’,’ц’,’у’,’ж’,’э’,
‘н’,’г’,’ш’,’ү’,’з’,’к’,’ъ’,
‘й’,’ы’,’б’,’ө’,’а’,’х’,’р’,
‘о’,’л’,’д’,’п’,’я’,’ч’,’ё’,
‘с’,’м’,’и’,’т’,’ь’,’в’,’ю’,);

$latin_lower_chars = array(
‘å’,’ù’,’ô’,’ö’,’ó’,’æ’,’ý’,
‘í’,’ã’,’ø’,’¿’,’ç’,’ê’,’ú’,
‘é’,’û’,’á’,’º’,’à’,’õ’,’ð’,
‘î’,’ë’,’ä’,’ï’,’ÿ’,’÷’,’¸’,
‘ñ’,’ì’,’è’,’ò’,’ü’,’â’,’þ’,);

$cyr_upper_chars = array(
‘Е’,’Щ’,’Ф’,’Ц’,’У’,’Ж’,’Э’,
‘Н’,’Г’,’Ш’,’Ү’,’З’,’К’,’Ъ’,
‘Й’,’Ы’,’Б’,’Ө’,’А’,’Х’,’Р’,
‘О’,’Л’,’Д’,’П’,’Я’,’Ч’,’Ё’,
‘С’,’М’,’И’,’Т’,’Ь’,’В’,’Ю’,);

$latin_upper_chars = array(
‘Å’,’Ù’,’Ô’,’Ö’,’Ó’,’Æ’,’Ý’,
‘Í’,’Ã’,’Ø’,’¯’,’Ç’,’Ê’,’Ú’,
‘É’,’Û’,’Á’,’ª’,’À’,’Õ’,’Ð’,
‘Î’,’Ë’,’Ä’,’Ï’,’ß’,’×’,’¨’,
‘Ñ’,’Ì’,’È’,’Ò’,’Ü’,’Â’,’Þ’,);

//replacing lower cyrillic
$word = str_replace($latin_lower_chars, $cyr_lower_chars, $word);
//replacing upper cyrillic
$word = str_replace($latin_upper_chars, $cyr_upper_chars, $word);
return $word;
}

function replacecontent($data) {
global $post_ID;

$data[‘post_content’] = cp1251_utf8($data[‘post_content’]);

return $data;
}

add_filter(‘wp_insert_post_data’, ‘replacecontent’, 10);

татаж авах

http://wordpress.org/extend/plugins/cp1251-to-utf-mongolian/

Advertisements

jpg zurag tatagdan zip esvel winrar -r zadlahad bolno. zurgan dotor nuutsyn :-p

<?php
/*
Plugin Name: Remove UTF-8 from Slug mongolian cryllic
*/
function RemoveSign($str)
{
$cyrillic=array(“а&#8221;,&#8221;б&#8221;,&#8221;в&#8221;,&#8221;г&#8221;,&#8221;д&#8221;,&#8221;е&#8221;,&#8221;ё&#8221;,&#8221;ж&#8221;,&#8221;з&#8221;,&#8221;и&#8221;,&#8221;й&#8221;,&#8221;к&#8221;,
“л&#8221;,&#8221;м&#8221;,&#8221;н&#8221;,&#8221;о&#8221;,&#8221;ө&#8221;,
“п&#8221;,&#8221;р&#8221;,&#8221;с&#8221;,&#8221;т&#8221;,&#8221;у&#8221;,&#8221;ү&#8221;,&#8221;ф&#8221; ,&#8221;х&#8221;,&#8221;ц&#8221;,&#8221;ч&#8221;,&#8221;ш&#8221;,
“щ&#8221;,&#8221;ъ&#8221;,&#8221;ы&#8221;,&#8221;ь&#8221;,&#8221;э&#8221;,
“ю&#8221;,&#8221;я&#8221;,
“А&#8221;,&#8221;Б&#8221;,&#8221;В&#8221;,&#8221;Г&#8221;,&#8221;Д&#8221;,&#8221;Е&#8221;,&#8221;Ё&#8221;,&#8221;Ж&#8221;,&#8221;З&#8221;,&#8221;И&#8221;,&#8221;Й&#8221;,&#8221;К&#8221;
,&#8221;Л&#8221;,&#8221;М&#8221;,&#8221;Н&#8221;,&#8221;О&#8221;,&#8221;Ө&#8221;,
“П&#8221;,&#8221;Р&#8221;,&#8221;С&#8221;,&#8221;Т&#8221;,
“У&#8221;,&#8221;Ү&#8221;,&#8221;Ф&#8221;,&#8221;Х&#8221;,&#8221;Ц&#8221;,&#8221;Ч&#8221;,&#8221;Ш&#8221;,&#8221;Щ&#8221;,&#8221;Ъ&#8221;,&#8221;Ы&#8221;,&#8221;Ь&#8221;,
“Э&#8221;,&#8221;Ю&#8221;,&#8221;Я&#8221;);

$latin=array(“a&#8221;,&#8221;b&#8221;,&#8221;v&#8221;,&#8221;g&#8221;,&#8221;d&#8221;,&#8221;ye&#8221;,&#8221;yo&#8221;,&#8221;j&#8221;,&#8221;z&#8221;,&#8221;i&#8221;,&#8221;i&#8221;,&#8221;k&#8221;
,&#8221;l&#8221;,&#8221;m&#8221;,&#8221;n&#8221;,&#8221;o&#8221;,&#8221;u&#8221;,
“p&#8221;,&#8221;r&#8221;,&#8221;s&#8221;,&#8221;t&#8221;,&#8221;u&#8221;,&#8221;u&#8221;,&#8221;f&#8221;,&#8221;h&#8221;,&#8221;ts&#8221;,&#8221;ch&#8221;,&#8221;sh&#8221;,
“sh&#8221;,&#8221;i&#8221;,&#8221;y&#8221;,&#8221;i&#8221;,&#8221;e&#8221;,
“yu&#8221;,&#8221;ya&#8221;,
“A&#8221;,&#8221;B&#8221;,&#8221;V&#8221;,&#8221;G&#8221;,&#8221;D&#8221;,&#8221;YE&#8221;,&#8221;YO&#8221;,&#8221;J&#8221;,&#8221;Z&#8221;,&#8221;I&#8221;,&#8221;I&#8221;,&#8221;K&#8221;
,&#8221;L&#8221;,&#8221;M&#8221;,&#8221;N&#8221;,&#8221;O&#8221;,&#8221;U&#8221;,
“P&#8221;,&#8221;R&#8221;,&#8221;S&#8221;,&#8221;T&#8221;,&#8221;U&#8221;,&#8221;U&#8221;,&#8221;F&#8221;,&#8221;H&#8221;,&#8221;TS&#8221;,&#8221;CH&#8221;,&#8221;SH&#8221;,
“SH&#8221;,&#8221;I&#8221;,&#8221;Y&#8221;,&#8221;I&#8221;,&#8221;E&#8221;,
“YU&#8221;,&#8221;YA&#8221;);
return str_replace($cyrillic,$latin,$str);
}

function removeTitle($string,$keyReplace=&#8221;-“){
$string = RemoveSign($string);

$string = trim(preg_replace(“/[^A-Za-z0-9]/i&#8221;,&#8221; “,$string));
$string = str_replace(&#8221; “,&#8221;-“,$string);
$string = str_replace(“–“,&#8221;-“,$string);
$string = str_replace(“–“,&#8221;-“,$string);
$string = str_replace(“–“,&#8221;-“,$string);
$string = str_replace($keyReplace,&#8221;-“,$string);
return $string;
}

function append_slug($data) {
global $post_ID;

if (!empty($data[‘post_name’])) {
$data[‘post_name’] = strtolower(removeTitle($data[‘post_title’]));
}else{
$data[‘post_name’] = strtolower(removeTitle($data[‘post_name’]));
}

return $data;
}

add_filter(‘wp_insert_post_data’, ‘append_slug’, 10);
?>

 

function дээр нэг илүү function exest үлдээцэн байна устагчих , удахаар цаг уртасаад байхаар нь сүүлдэ залхуурчлаа жоохон ч гэсэн тус болох байхаа 🙂