remove utf8 permalink , slug Хөрвүүлэгч

Posted: 10 сар 2, 2011 in php, Wordpress

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);
?>

Advertisements
Сэтгэгдэлүүд
  1. Uranbold хэлдэг:

    Татах линк нь хулихидаад байгаамуу даа хаха

Хариулт үлдээх

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Өөрчлөх )

Twitter picture

You are commenting using your Twitter account. Log Out / Өөрчлөх )

Facebook photo

You are commenting using your Facebook account. Log Out / Өөрчлөх )

Google+ photo

You are commenting using your Google+ account. Log Out / Өөрчлөх )

Connecting to %s