first, it was replacing spaces with _, which is not search-engine friendly; every SEO expert I’ve ever talked with recommends using dashes (-) rather that underscores to represent spaces; so now spaces will get replaced with a dash (-)
second (and what is really causing the problem), it was using the regexp /\W/ to identify all "special characters" and simply remove them; I do not believe this is correct so I am changing this to more closely match the behavior of WordPress in this area (updates when I get it done)
function stripAlias($alias) {
$alias = strip_tags($alias);
$alias = strtolower($alias);
$alias = preg_replace('/&.+?;/', '', $alias); // kill entities
$alias = preg_replace('/[^\.%a-z0-9 _-]/', '', $alias);
$alias = preg_replace('/\s+/', '-', $alias);
$alias = preg_replace('|-+|', '-', $alias);
$alias = trim($alias, '-');
return $alias;
}This discussion is closed to further replies. Keep calm and carry on.