Skip to content

Commit eb7c436

Browse files
committed
Add emoji shortcodes to parser
1 parent 7cd6dff commit eb7c436

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

include/parser.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ function parse_signature($text)
10891089
//
10901090
function sva_do_for_only_text($text, $do_smilies)
10911091
{
1092-
if (! $do_smilies || '' === $text)
1092+
if ('' === $text)
10931093
return $text;
10941094

10951095
if (false === strpos($text, '<'))
@@ -1102,10 +1102,25 @@ function sva_do_for_only_text($text, $do_smilies)
11021102
if ('<' === $cur[0])
11031103
continue;
11041104

1105+
$cur = preg_replace_callback('%:[\w\-+]++:%', 'sva_do_emoji', $cur);
1106+
11051107
if ($do_smilies)
11061108
$cur = do_smilies($cur);
11071109
}
11081110
unset($cur);
11091111

11101112
return implode('', $arr);
11111113
}
1114+
1115+
//
1116+
// Обработчик emoji
1117+
//
1118+
function sva_do_emoji($matches)
1119+
{
1120+
static $emoji;
1121+
1122+
if (! isset($emoji))
1123+
$emoji = include PUN_ROOT.'include/emoji.inc.php';
1124+
1125+
return $emoji[substr($matches[0], 1, -1)] ?? $matches[0];
1126+
}

0 commit comments

Comments
 (0)