public

Unfiltered Text Widget

  • Download Gist
class.Unfiltered_Text_Widget.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
<?php # -*- coding: utf-8 -*-
 
/**
* Simplified variant of the native text widget class.
*
* Usage:
* add_action( 'widgets_init', array ( 'Unfiltered_Text_Widget', 'register' ), 20 );
*
* @author Thomas Scholz aka toscho http://toscho.de
* @version 2012.01.05
*/
class Unfiltered_Text_Widget extends WP_Widget
{
/**
* Constructor.
*/
public function __construct()
{
parent::__construct(
'unfiltered_text'
, __( 'Unfiltered Text', 't5_theme' )
, array( 'description' => __( 'Pure Markup', 't5_theme' ) )
, 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 = esc_textarea( $instance['text'] );
?>
<textarea class="widefat" rows="7" cols="20" id="<?php
echo $this->get_field_id( 'text' );
?>" name="<?php
echo $this->get_field_name( 'text' );
?>"><?php
echo $text;
?></textarea>
<?php
}
 
/**
* Registers this widget.
*
* @return void
*/
public static function register()
{
register_widget( __CLASS__ );
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.