I have special problem. I’m using WP All Import Pro plugin to import XML to WordPress posts.
I need use WordPress function remove_accents() for strip Czech accents (ÄÅ¡ÄÅžýáÃé) for post slug.
If I set variable manually (ignore $mytitle), all works fine.
function seofriendly_slug($mytitle) {
$finalslug = remove_accents("Test string ÄÅ¡ÄÅžýáÃé");
return $finalslug;
}
OUTPUT: Test string escrzyaie
But if I use variable $mytitle that coming from XML (utf8):
[seofriendly_slug({PRACOVISTE[1]/@nazev})]
Variable is set propertly but remove_accents does not work:
function seofriendly_slug($mytitle) {
$finalslug = remove_accents($mytitle);
return $finalslug;
}
OUTPUT: Test string ÄÅ¡ÄÅžýáÃé
Last info: When I use mb_detect_encoding($mytitle), output is “ASCII” but in XML header is UTF-8.
I get solution from WorkScout theme creator – PureThemes.
Final code: