A very simple custom Wordpress widget.
/**
* Copyright Widget
*/
class my_custom_copyright_widget extends WP_Widget {
/** constructor */
function my_custom_copyright_widget() {
parent::WP_Widget(false, $name = 'Copyright Text');
}
/** @see WP_Widget::widget */
function widget($args, $instance) {
extract( $args );
// these are our widget options
$text = $instance['text']; // single value
$localize_array = array(
'text' => $text,
);
//echo $before_widget; // start widget display code ?>
<span class="copyright">
<?php echo $text; ?>
</span>
<?php
}
/** @see WP_Widget::update */
function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['text'] = strip_tags($new_instance['text']);
return $instance;
}
/** @see WP_Widget::form */
function form($instance) {
$text = esc_attr($instance['text']);
?>
<p>
<label for="<?php echo $this->get_field_id('text'); ?>"><?php _e('Text:'); ?></label>
<textarea rows="3" class="widefat" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>" type="text" value=""><?php echo $text; ?></textarea>
</p>
<?php
}
}
// register Copyright widget
add_action('widgets_init', create_function('', 'return register_widget("my_custom_copyright_widget");'));