According to the comments, your code only finds smileys when they use ’
instead of '
. I used Wordpress for a while, and I realized that it replaced some characters with others when sending posts, for the following reason: for ordinary users, replacing '
by its curved variation does not imply any difference in functionality, but makes the posts easier to read by the fact that such symbols are usually used to mark quotes or irony. Microsoft Word does the same thing. Try typing some quotes using "
in the Word you will see that it "fixes" them to curved quotes to a certain side depending on the context unless you disable the filter in the settings.
In Wordpress, this filter is called wptexturize
and changes many characters, replacing them with their curved variants, such as the '
(the source of your problem) and the quotation marks. The problem is that this filter is not applied when writing the post, but when it is saved on the server, so it is really hard to know where the editing comes from.
To disable it, open the file functions.php
Wordpress and, before the last ?>
, add the following to disable overwriting on all posts that will be created/edited in the future:
remove_filter ('category_description', 'wptexturize');
remove_filter ('list_cats', 'wptexturize');
remove_filter ('comment_author', 'wptexturize');
remove_filter ('comment_text', 'wptexturize');
remove_filter ('the_title', 'wptexturize');
remove_filter ('the_content', 'wptexturize');
remove_filter ('the_excerpt', 'wptexturize');
I should warn, however, that this will not affect posts that have already been created, so you will have to re-edit all your posts and, if necessary, replace all ’
of smileys to '
again. This will make it easier to create more text replacement codes for smileys that use characters that wptexturize
modifies.
Why don’t you use
":'(" => 'choro.png',
? That is, quotes to delimit leaving the content free to contain plicas.– Zuul
I tried to use, but it doesn’t work.
– Alexandre Lopes
Define what you mean by "does not work". Gives error, what happens?
– Bacco
Simply does not happen to the conversion. Appears in text format, ie,
:'(
– Alexandre Lopes
You need to see if WP isn’t leaking some value before you get to this function. Test with other symbols (accented letters, etc) to see if the same problem happens. For example
'(á)' => 'teste.png'
.– Bacco
It worked normal with your
(á)
– Alexandre Lopes
Only if you do it with
:'(
It doesn’t make the conversion. Ah! I realized that it changes the accent when I comment:'(
for:’(
– Alexandre Lopes
Any idea of a solution?
– Alexandre Lopes
Test with
':’(' => 'choro.png'
then :)– Bacco
No...... :( :( :( :( Did not work.....
– Alexandre Lopes
If I comment
:\’(
works. But it has to work with:'(
– Alexandre Lopes
I used it like this:
":’(" => 'choro.png',
and worked perfectly when I comment:’(
!! Êbaa.. Only if I comment:'(
does not convert.– Alexandre Lopes