I am running into a problem where I have no idea where to add in a description so it will show up on the widget dashboard. It just keeps displaying the title.
Something else I would love some help with is to add functionality to display the 5 most recent post titles (all categories) and I also do not know how to do that. I will post the code I have now below. Any input will greatly help my web design education.
<?php
/*
Plugin Name: Kevins Textbox
Plugin URI:
Description: A text widget created by Kevin Ullyott for practice in creating widgets
Author: Kevin Ullyott
Version: 1.0
Author URI: http://modmacro.com/
*/
class kevintext extends WP_Widget {
public function __construct() {
parent::WP_Widget(false, $name='Kevins Textbox');
array('description' => __('A text widget created by Kevin Ullyott for practice in creating widgets') );
}
public function widget( $args, $instance ) {
extract( $args );
$headline = $instance['headline'];
$text = $instance['text'];
echo $before_widget;
echo $before_title;
echo "<p class=\"headline\">$headline</p>";
echo $after_title;
echo "<p class=\"text\">$text</p>";
echo $after_widget;
}
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['headline'] = ( $new_instance['headline'] );
$instance['text'] = ( $new_instance['text'] );
return $instance;
}
public function form( $instance ) {
$headline = $instance[ 'headline' ];
$text = $instance[ 'text' ];
?>
<p>
<label for="<?php echo $this->get_field_id( 'headline' ); ?>"><?php _e( 'Headline:' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'headline' ); ?>" name="<?php echo $this->get_field_name( 'headline' ); ?>" type="text" value="<?php echo esc_attr( $headline ); ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id( 'text' ); ?>"><?php _e( 'Text:' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'text' ); ?>" name="<?php echo $this->get_field_name( 'text' ); ?>" type="text" value="<?php echo esc_attr( $text ); ?>" />
</p>
<?php
}
}
add_action( 'widgets_init', create_function('', 'return register_widget("kevintext");') );
?>