/**
* Replace embeddable URLs with the embed code.
*
* @param string $text
*
* @return string
*/
public static function OEmbed($text)
{
$embera = new Embera();
if ($data = $embera->getUrlInfo($text)) {
$table = [];
foreach ($data as $url => $service) {
if (!empty($service['html'])) {
$table[$url] = $service['html'];
}
}
foreach ($table as $url => $replacement) {
$text = preg_replace('~(?<![\'\\"])' . preg_quote($url) . '(?![\'\\"])(?!\\</a\\>)~', $replacement, $text);
}
}
return $text;
}