// komodo tool: widget
// ===================
// auto_abbreviation: true
// treat_as_ejs: true
// type: snippet
// version: 1.1.5
// ===================
<% /* Widget Template */ %>

/**
 * new WordPress Widget format
 * Wordpress 2.8 and above
 * @see http://codex.wordpress.org/Widgets_API#Developing_Widgets
 */
class ${1:PREFIX_Name}_Widget extends WP_Widget {

    /**
     * Constructor
     *
     * @return void
     **/
    function $1_Widget() {
        \$widget_ops = array( 'classname' => '${2:CSS class name}', 'description' => '${3:Description}' );
        \$this->WP_Widget( '$2', '${4:Title}', \$widget_ops );
    }

    /**
     * Outputs the HTML for this widget.
     *
     * @param array $args An array of standard parameters for widgets in this theme
     * @param array $instance An array of settings for this widget instance
     * @return void Echoes it's output
     **/
    function widget( \$args, \$instance ) {
        extract( \$args, EXTR_SKIP );
        echo \$before_widget;
        echo \$before_title;
        echo '$4'; // Can set this with a widget option, or omit altogether
        echo \$after_title;

    //
    // Widget display logic goes here
    //

    echo \$after_widget;
    }

    /**
     * Deals with the settings when they are saved by the admin. Here is
     * where any validation should be dealt with.
     *
     * @param array $new_instance An array of new settings as submitted by the admin
     * @param array $old_instance An array of the previous settings
     * @return array The validated and (if necessary) amended settings
     **/
    function update( \$new_instance, \$old_instance ) {

        // update logic goes here
        \$updated_instance = \$new_instance;
        return \$updated_instance;
    }

    /**
     * Displays the form for this widget on the Widgets page of the WP Admin area.
     *
     * @param array $instance An array of the current settings for this widget
     * @return void Echoes it's output
     **/
    function form( \$instance ) {
        \$instance = wp_parse_args( (array) \$instance, array( ${5:array of option_name => value pairs} ) );

        // display field names here using:
        // \$this->get_field_id( 'option_name' ) - the CSS ID
        // \$this->get_field_name( 'option_name' ) - the HTML name
        // \$instance['option_name'] - the option value
    }
}

add_action( 'widgets_init', create_function( '', "register_widget( '$1_Widget' );" ) );