I have a widget for users to enter in the code for an iframe widget that is created on another site. There are a few variations of what the iframe code that is generated from the other site will contain, so I want to strip out everything except for the 6 digits that identify the widget, and then echo back the iframe code with the digits inserted.
I'm not sure why this isn't working … The code I have been using is here:
<?php
$widget_id = $vars['entity']->widget_id;
if ($widget_id) {
$widget_id = preg_replace('<iframe src=(.*?)/widgets/(\d+)(.*?)</iframe>', '$2', $widget_id);
echo '<iframe src="http://website.com/widgets/'.$widget_id.'/player_universal" width="300" height="250"></iframe>';
}
else {
echo "Enter the widget short code";
}