I need to create a simple widget that has a text input field.
I need the widget to create the markup below…
<div class="textwidget">
<div class="avatar">
<div class="avatartext">
<p>CONTENTS OF THE TEXT INPUT HERE</p>
</div>
<div class="avatarimage"></div>
</div>
I’ve started the process of stubbing out the widget with the code below. I’m just not shure how to code the my_avatar() function…
function my_avatar()
{
//Widget markup goes here. How to pull the widget text entry?
}
register_activation_hook(__FILE__, 'my_avatar');
class My_Widget_Avatar extends WP_Widget {
function My_Widget_Avatar() {
$widget_ops = array( 'classname' => 'widget_avatar', 'description' => __( "My Avatar Widget" ) );
$this->WP_Widget('my_avatar', __('My Avatar'), $widget_ops);
}
}
add_action('widgets_init', create_function('', "register_widget('My_Widget_Avatar');"));
Complete code: