Skip to content

Instantly share code, notes, and snippets.

@felipelavinz
Created September 23, 2010 20:45
Show Gist options
  • Save felipelavinz/594327 to your computer and use it in GitHub Desktop.
Save felipelavinz/594327 to your computer and use it in GitHub Desktop.
/**
* [[%%ask1: Nombre del Widget]]
* [[%%ask2: Descripción]]
*/
class [[%%ask3: Nombre de la función]] extends WP_Widget {
/** constructor */
function [[%%ask3]]() {
$widget_ops = array('classname' => '[[%%ask3]]', 'description' => '[[%%ask2]]');
$control_ops = array('width' => 400);
$this->WP_Widget('[[%ask3]]', '[[%%ask1]]', $widget_ops, $control_ops);
}
function widget($args, $instance) {
extract( $args );
$title = apply_filters('widget_title', $instance['title']);
?>
<?php echo $before_widget; ?>
<?php if ( $title )
echo $before_title . $title . $after_title; ?>
Hello, World!
<?php echo $after_widget; ?>
<?php
}
function update($new_instance, $old_instance) {
return $new_instance;
}
function form($instance) {
$title = esc_attr($instance['title']);
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label></p>
<?php
}
} // class [[%%ask3]]
// register [[%%ask3]] widget
add_action('widgets_init', create_function('', 'return register_widget("[[%%ask3]]");'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment