You are here

function drupagram_emoji in Drupagram 6

Same name and namespace in other branches
  1. 7 drupagram.inc \drupagram_emoji()

Helper function to handle emoji special characters.

In the future this will be the single point where emoji unicode characters will be replaced with the actual image for it.

This issue is only pertinent to users adding emoji characters to their posts or usernames.

2 calls to drupagram_emoji()
drupagram_account_save in ./drupagram.inc
Saves a InstagramUser object to {drupagram_account}
drupagram_media_save in ./drupagram.inc
Saves a InstagramMedia object to {drupagram}

File

./drupagram.inc, line 96
Instagram API functions

Code

function drupagram_emoji(&$variable) {
  if (is_array($variable)) {
    foreach ($variable as $key => $value) {
      if (empty($value)) {
        continue;
      }
      $variable[$key] = drupagram_emoji($value);
    }
  }
  elseif (is_object($variable)) {
    $variable = (array) $variable;
    foreach ($variable as $key => $value) {
      if (empty($value)) {
        continue;
      }
      $variable[$key] = drupagram_emoji($value);
    }
    $variable = (object) $variable;
  }
  elseif (is_string($variable)) {
    $variable = preg_replace("", "", htmlspecialchars($variable, ENT_NOQUOTES, 'UTF-8', FALSE));
  }
  return $variable;
}