apply_filters() function in wordpress
hey guys im really frustrated
im looking for a way to retrieve back my slug to the normal text as wordpress does
in wordpress there is a function to do so :
apply_filters('editable_slug', $slug)
i search all related files to find what this function does, but couldn't understand a bit.
as ypu may know , making a slug out of a normal text is a easy job , but when its converted , for Utf-8 languages such as Arabic , words will be changed to unread开发者_如何学Pythonable unicodes .
e.g. :
http://localhost/page/%d8%a7%d9%84%d9%84%d9%87
do you know how this function works in wordpress ?
apply_filters('editable_slug', $slug)
and how i can do the same in my own php project ?
Call rawurldecode on the percent-encoded form -- this will give you the text in UTF-8 encoding. If your webpage encoding is UTF-8, you just have to call htmlspecialchars($str, ENT_NOQUOTES, 'UTF-8').
Example:
$str = rawurldecode('%d8%a7%d9%84%d9%84%d9%87');
echo htmlspecialchars($str, ENT_NOQUOTES, 'UTF-8');
Check out this question: Unicode characters in URLs for some good background.
The URL you show looks okay basically - it's the proper percent encoded representation of the arabic characters in question.
You should be able to display them in proper arabic on your web page. Copy+pasting will give you the URLencoded form, which is a good thing because that way, your permalinks will work in non-UTF-8-speaking clients as well.
精彩评论