Wciągam zdalny kanał do mojej wtyczki, a niektóre wpisy mają kod iframe, który chcę zachować. Jednak SimplePie fetch_feed
wciąż go rozbiera . Oto mój kod i to, co próbowałem już:
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;' ) );