Sto afferrando un feed remoto nel mio plugin e alcune voci hanno il codice iframe che voglio conservare. Tuttavia, SimplePie fetch_feed
continua a rimuoverlo. Ecco il mio codice e quello che ho già provato:
kses_remove_filters(); # remove kses filters but SimplePie strips codes anyway
$rss = fetch_feed( 'http://www.someblog.com/feed/' );
$rss_items = $rss->get_items( 0, 2 ); # get two entries for this example
foreach ( $rss_items as $item ) {
# just dump to screen:
echo "<div id='message' class='updated'><p>" . $item->get_content() . "</p></div>";
}
kses_init_filters(); # remove kses filters but SimplePie strips codes anyway
# also tried adding iframe to kses_allowed_html filter:
function se87359_add_filter( &$feed, $url ) {
add_filter('wp_kses_allowed_html', 'se87359_add_allowed_tags');
}
add_filter( 'wp_feed_options', 'se87359_add_filter', 10, 2 );
function se87359_add_allowed_tags($tags) {
// Ensure we remove it so it doesn't run on anything else
remove_filter('wp_kses_allowed_html', 'se87359_add_allowed_tags');
$tags['iframe'] = array(
'src' => true,
'width' => true,
'height' => true,
'class' => true,
'frameborder' => true,
'webkitAllowFullScreen' => true,
'mozallowfullscreen' => true,
'allowFullScreen' => true
);
return $tags;
}
# also made sure not to cache the feed (for testing only):
function do_not_cache_feeds(&$feed) {
$feed->enable_cache(false);
}
add_action( 'wp_feed_options', 'do_not_cache_feeds' );
# in case above doesn't work, set transient lifetime to 1 second:
add_filter( 'wp_feed_cache_transient_lifetime', create_function( '$a', 'return 1;' ) );