Posted on Leave a comment

Iframe Widget for my WPYUI.com Themes

Linkable and Clickable Entry Meta and Byline using Hybrid WordPress Theme

Iframe widget for my WPYUI theme came into my need when I wanted to figure out my front-page or home-page layout. I wanted to display some Facebook and twitter updates on my front page, but in an “iframe” so that visitors can scroll down the content. That way it does not take up space on the front page.

Here is what I found. Let us do it in order, in four simple steps only.

First to do is to copy this code:

/** * Simplified variant of the native text widget class. * https://wordpress.stackexchange.com/questions/19207/adding-iframe-content-to-sidebar-widget * @author Fuxia Scholz * @version 1.0 */ class Unfiltered_Text_Widget extends WP_Widget { /** * @uses apply_filters( ‘magic_widgets_name’ ) */ public function __construct() { // You may change the name per filter. // Use add_filter( ‘magic_widgets_name’, ‘your custom_filter’, 10, 1 ); $widgetname = apply_filters( ‘magic_widgets_name’, ‘Unfiltered Text’ ); parent::__construct( ‘unfiltered_text’ , $widgetname , array( ‘description’ => ‘Pure Markup’ ) , array( ‘width’ => 300, ‘height’ => 150 ) ); } /** * Output. * * @param array $args * @param array $instance * @return void */ public function widget( $args, $instance ) { echo $instance[‘text’]; } /** * Prepares the content. Not. * * @param array $new_instance New content * @param array $old_instance Old content * @return array New content */ public function update( $new_instance, $old_instance ) { return $new_instance; } /** * Backend form. * * @param array $instance * @return void */ public function form( $instance ) { $instance = wp_parse_args( (array) $instance, array( ‘text’ => ” ) ); $text = format_to_edit($instance[‘text’]); ?>