admin管理员组文章数量:1125368
Just updated my local and live installs for a side project to 4.2 in order to take advantage of the newly added Emoji features. Emoji are working just fine on my local machine, but they seem to not be working as comments on the live version.
Local
- emoji in post title - working
- emoji in post content - working
- emoji in comments - working
Live
- emoji in post title - working
- emoji in post content - working
- emoji in comments - not working
Troubleshooting
- Theme - Tried activating Twenty Fifteen; didn't work.
- Plugins - Tried deactivating all plugins; didn't work.
- Theme + Plugins - Tried activating Twenty Fifteen and deactivating all plugins; didn't work.
- Normal comments - Regular characters save and display as comments just fine.
- Emoji - they display in the 'comment field' when adding a comment, but once submitted, the seem to be stripped out. In wp-admin an emoji comment just seems to be blank with no text at all.
I have tried all of the basic troubleshooting I can think of, are there any other things I am not thinking of?
Just updated my local and live installs for a side project to 4.2 in order to take advantage of the newly added Emoji features. Emoji are working just fine on my local machine, but they seem to not be working as comments on the live version.
Local
- emoji in post title - working
- emoji in post content - working
- emoji in comments - working
Live
- emoji in post title - working
- emoji in post content - working
- emoji in comments - not working
Troubleshooting
- Theme - Tried activating Twenty Fifteen; didn't work.
- Plugins - Tried deactivating all plugins; didn't work.
- Theme + Plugins - Tried activating Twenty Fifteen and deactivating all plugins; didn't work.
- Normal comments - Regular characters save and display as comments just fine.
- Emoji - they display in the 'comment field' when adding a comment, but once submitted, the seem to be stripped out. In wp-admin an emoji comment just seems to be blank with no text at all.
I have tried all of the basic troubleshooting I can think of, are there any other things I am not thinking of?
Share Improve this question asked Apr 24, 2015 at 17:53 Stephen S.Stephen S. 1,0292 gold badges13 silver badges21 bronze badges2 Answers
Reset to default 1I have just solved this!
The emoji needs to be converted to UTF8 encoded string while storing in MySQL database and of course your database column collation must be utf8mb4:
<?php utf8_encode($comment); ?>
Then while displaying do the reverse: <?php utf8_decode($comment); ?>
I'm sorry I don't have code for WordPress as I use it only as a CMS to store the data and use another PHP MVC framework to fetch it for API.
Hope this helps.
It seems you need to change the Collation
for the wp_comments
and wp_commentmeta
tables on your Live server to utf8mb4_unicode_ci
.
本文标签: Troubleshooting Emoji in Comments
版权声明:本文标题:Troubleshooting Emoji in Comments 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736631330a1945785.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论