This article is written specifically for the Anghunk theme development documentation.
https://github.com/98fuel/Anghunk
The solution was completed with the assistance of Dreaming Stars.
Introduction#
Anghunk comments carry many beautiful emojis, but under normal circumstances, the Typecho backend cannot parse these emojis correctly. As shown in the figure below;
However, after I parse the emojis, it can become like the one below. If you need this functionality in the theme, you can follow the steps I outline below for modification.
Modification#
Open the /admin/manage-comments.php
file and insert the following at the header:
/*
* Parse emojis
*/
function getparseBiaoQingComment($content) {
$emopath=$_SERVER['REQUEST_SCHEME'].":". DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . $_SERVER['HTTP_HOST'];
$emo = false;
global $emo;
if(!$emo) {
$emo = json_decode(file_get_contents(dirname(dirname(dirname(__FILE__))).'/zburu.com/usr/themes/Anghunk/libs/OwO.json'), true);
}
foreach ($emo as $v) {
if($v['type'] == 'image') {
foreach ($v['container'] as $vv) {
$emoaa="::".$v['name'].":".$vv['icon']."::";
$content = str_replace($emoaa, ' <img style="max-height:40px;vertical-align:middle;" src="'.$emopath.'/usr/themes/Anghunk/libs/emotion/'.$v['name'].'/'.$vv['icon'] .'.png" alt="'.$vv['text'] .'"> ', $content);
}
}
}
return $content;
}
Note the position where I placed it, it must be between <?php ... ?>
Find line 166
, modify it, and replace the code in the tag with the one noted below.
<div class="comment-content">
<!-- Parse and output comments with emojis -->
<?php $con=$comments->content; echo getparseBiaoQingComment($con); ?>
</div>
After returning to the backend comment list, you will see that the comments have been successfully parsed. This method is only applicable to the Anghunk theme.