Created
July 29, 2013 18:51
-
-
Save bavington/6106687 to your computer and use it in GitHub Desktop.
Boilerplate for creating a simple Widget Plugin in Wordpress.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: My Widget Plugin | |
Plugin URI: http://twitter.com/jamesbavington | |
Description: A simple plugin that adds a simple widget | |
Version: 0.1 | |
Author: bavington | |
Author URI: http://twitter.com/jamesbavington | |
License: GPL2 | |
*/ | |
class wp_my_plugin extends WP_Widget { | |
// constructor | |
function wp_my_plugin() { | |
/* ... */ | |
} | |
// widget form creation | |
function form($instance) { | |
/* ... */ | |
} | |
// widget update | |
function update($new_instance, $old_instance) { | |
/* ... */ | |
} | |
// widget display | |
function widget($args, $instance) { | |
extract( $args ); | |
echo $before_widget; // pre-widget code from theme | |
/* ... */ | |
echo $after_widget; // post-widget code from theme | |
} | |
} | |
// register widget | |
add_action('widgets_init', create_function('', 'return register_widget("wp_my_plugin");')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment