Skip to content

Instantly share code, notes, and snippets.

@ChangJoo-Park
Forked from matiskay/widget-skeleton.php
Created August 26, 2013 23:59
Show Gist options
  • Save ChangJoo-Park/6348158 to your computer and use it in GitHub Desktop.
Save ChangJoo-Park/6348158 to your computer and use it in GitHub Desktop.
<?php
class Widget_Name extends WP_Widget {
function Widget_Name() {
$widget_opts = array(
'classname' => 'your-awesome-class',
'description' => 'Your awesome Description',
);
$this->WP_Widget('your_awesome_cool_name', 'Awesome Title', $widget_opts);
}
// widget outputs the widget content.
function widget($args, $instance) {
}
// displays the form which shows on the Widgets management panel.
function form($instance) {
$output = '';
$instance = (array) $instance;
$instance = wp_parse_args($instance, array('number' => 2 ));
$title = esc_attr($instance['title']);
// More Code
echo $output;
}
// updates the widget options when saved.
function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
return $instance;
}
}
// Load and Register the widget
add_action('widgets_init', 'awesome_plugin_name_load_widgets');
function awesome_plugin_name_load_widgets() {
register_widget('Widget_Name');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment