- if (is_array($emojis_array)) {
- foreach ($emojis_array as $emoji) {
- $emojis['texts'][] = ':' . $emoji['shortcode'] . ':';
- $emojis['icons'][] = '<img class="emoji mastodon" src="' . proxy_url($emoji['static_url']) . '" alt=":' . $emoji['shortcode'] . ':" title=":' . $emoji['shortcode'] . ':"/>';
+function mastodoncustomemojis_fetch_custom_emojis_for_url($api_base_url)
+{
+ $return = ['texts' => [], 'icons' => []];
+
+ $api_url = $api_base_url . '/api/v1/custom_emojis';
+
+ $fetchResult = Network::fetchUrlFull($api_url);
+
+ if ($fetchResult->isSuccess()) {
+ $emojis_array = json_decode($fetchResult->getBody(), true);
+
+ if (is_array($emojis_array) && count($emojis_array)) {
+ foreach ($emojis_array as $emoji) {
+ if (!empty($emoji['shortcode']) && !empty($emoji['static_url'])) {
+ $return['texts'][] = ':' . $emoji['shortcode'] . ':';
+ $return['icons'][] = '<img class="emoji mastodon" src="' . ProxyUtils::proxifyUrl($emoji['static_url']) . '" alt=":' . $emoji['shortcode'] . ':" title=":' . $emoji['shortcode'] . ':"/>';