From the SimplePie docs here: there is a strip_htmltags
property in the SimplePie object, which among others it has the iframe tag we want to keep.
So, apart from the wp_kses, probably we want to remove the tag from the above property.
For instance, the $rss = fetch_feed( 'http://www.someblog.com/feed/' );
gives us the SimplePie object.
If we var_dump($rss)
or even better “pretty print” it by using:
highlight_string("<?php\n\$rss =\n" . var_export($rss, true) . ";\n?>");
we will see all fetched entries and all properties of the $rss
object.
Among those there is the one we are looking for, and we can isolate it by using:
highlight_string("<?php\n\$rss->strip_htmltags =\n" . var_export($rss->strip_htmltags, true) . ";\n?>");
this will give us something like the below:
<?php
$rss->strip_htmltags =
array (
0 => 'base',
1 => 'blink',
2 => 'body',
3 => 'doctype',
4 => 'embed',
5 => 'font',
6 => 'form',
7 => 'frame',
8 => 'frameset',
9 => 'html',
10 => 'iframe',
11 => 'input',
12 => 'marquee',
13 => 'meta',
14 => 'noscript',
15 => 'object',
16 => 'param',
17 => 'script',
18 => 'style',
);
?>
From the above we note that the key
of the iframe entry is 10. So we use array_splice to remove the entry, like:
// Remove these tags from the list
$strip_htmltags = $rss->strip_htmltags; //get a copy of the strip entries array
array_splice($strip_htmltags, 10, 1); //remove the iframe entry
$rss->strip_htmltags = $strip_htmltags; // assign the strip entries without those we want
Now the iframe entry is out and of the $strip_htmltags
property and probably we are set.
Notice: I couldn’t find a “test” rss feed containing some iframe to test the above. So if anyone can verify it, please provide some feedback.