Yesterday, I created a WordPress plugin for MegaStar CINeBLOG to help them build a nicer permalinks which is automatically generated from a post title by removing all Vietnamese accents.
I’ve used WordPress for 3 years but honestly, it’s my first WordPress plugin :). It’s so simple but do a great job, useful & friendly for SEO and easy for people to read.
If you guys have no experiences on creating a WordPress plugin and want to start one, before you do anything, please read the guideline from WordPress on Writing a Plugin first because there are some rules/standards you need to follow.
I’ll paste all my plugin source code below because it just includes 1 php named: “remove-vietnamese-accents.php” file which contains some code line:
[php] <?php/*
Plugin Name: Remove Vietnamese Accents From The Permalinks
Plugin URI: http://4rapiddev.com
Description: The plugin is so simple but do a great job by removing all Vietnamese Accents when build the permalinks from post title. It’s useful & friendly for SEO and easy for people to read.
Author: Hoan Huynh
Version: 1.0
Author URI: http://4rapiddev.com
*/
function remove_vietnamese_accents($str) {
$accents_arr=array(
"à","á","ạ","ả","ã","â","ầ","ấ","ậ","ẩ","ẫ","ă",
"ằ","ắ","ặ","ẳ","ẵ","è","é","ẹ","ẻ","ẽ","ê","ề",
"ế","ệ","ể","ễ",
"ì","í","ị","ỉ","ĩ",
"ò","ó","ọ","ỏ","õ","ô","ồ","ố","ộ","ổ","ỗ","ơ",
"ờ","ớ","ợ","ở","ỡ",
"ù","ú","ụ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ",
"ỳ","ý","ỵ","ỷ","ỹ",
"đ",
"À","Á","Ạ","Ả","Ã","Â","Ầ","Ấ","Ậ","Ẩ","Ẫ","Ă",
"Ằ","Ắ","Ặ","Ẳ","Ẵ",
"È","É","Ẹ","Ẻ","Ẽ","Ê","Ề","Ế","Ệ","Ể","Ễ",
"Ì","Í","Ị","Ỉ","Ĩ",
"Ò","Ó","Ọ","Ỏ","Õ","Ô","Ồ","Ố","Ộ","Ổ","Ỗ","Ơ",
"Ờ","Ớ","Ợ","Ở","Ỡ",
"Ù","Ú","Ụ","Ủ","Ũ","Ư","Ừ","Ứ","Ự","Ử","Ữ",
"Ỳ","Ý","Ỵ","Ỷ","Ỹ",
"Đ"
);
$no_accents_arr=array(
"a","a","a","a","a","a","a","a","a","a","a",
"a","a","a","a","a","a",
"e","e","e","e","e","e","e","e","e","e","e",
"i","i","i","i","i",
"o","o","o","o","o","o","o","o","o","o","o","o",
"o","o","o","o","o",
"u","u","u","u","u","u","u","u","u","u","u",
"y","y","y","y","y",
"d",
"A","A","A","A","A","A","A","A","A","A","A","A",
"A","A","A","A","A",
"E","E","E","E","E","E","E","E","E","E","E",
"I","I","I","I","I",
"O","O","O","O","O","O","O","O","O","O","O","O",
"O","O","O","O","O",
"U","U","U","U","U","U","U","U","U","U","U",
"Y","Y","Y","Y","Y",
"D"
);
return str_replace($accents_arr,$no_accents_arr,$str);
}
add_filter(‘sanitize_title’, ‘remove_vietnamese_accents’, 1);
?>
[/php]
If you want, you can download my plugin. It’s free to use, of cause.