How to use 'inside an array?

1

I'm facing a problem with an adaptation in functions.php of my theme Wordpress .

What happens, I want to put:

':'(' => 'choro.png',

Only it is not possible for the second '

I tried to use:

':\'(' => 'choro.png',

It just does not work.

I'm making an adaptation in my smilyes, what should happen is that when a person puts :'( there is a crying face, just because the code is: ' conversion.

I have already made several adaptations like: :) ;) :( :| all worked fine, only :'( does not work.

    
asked by anonymous 06.07.2014 / 02:34

4 answers

7

According to the comments, your code only finds the smileys when they use instead of ' . I used WordPress for a while, and I realized that it replaced some characters with others in the time of sending the posts, for the following reason: for ordinary users, replacing ' with its curved variation does not imply any difference in functionality, but leaves the posts easier to read by the fact that such symbols are generally used to mark quotations or irony. Microsoft Word does the same thing. Try typing some quotations using " in Word so you'll see that it "corrects" them for 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 source of your problem) and the quotation marks. The problem is that this filter is not applied at the time of writing the post, but when it is saved on the server, so it's really hard to know where the edit comes from.

To turn it off, open WordPress's functions.php file, and before the last ?> , add the following to disable substitution for 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 you, 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.

    
07.07.2014 / 06:21
1

try adding two more slashes, as it is likely that the string to be parsed with addslashes or magic quotes ...

<?php
    ':\\'(' => "choro.png",
?>
    
28.07.2014 / 02:46
0

Use this way:

<?php
    ":'(" => "choro.png",
?>
    
07.07.2014 / 03:21
0

Use double quotation marks as a delimiter, and feel free to use single quotation marks within the value of it:

<?php
    ":'(" => "choro.png",
?>
    
07.07.2014 / 17:24