Created
June 28, 2013 09:09
-
-
Save matherton/5883487 to your computer and use it in GitHub Desktop.
Worpress OO Plugin template
This file contains hidden or 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
| // http://wp.tutsplus.com/tutorials/plugins/two-ways-to-develop-wordpress-plugins-object-oriented-progamming/ | |
| class My_Widget extends WP_Widget { | |
| public function __construct() { | |
| // widget actual processes | |
| } | |
| public function form( $instance ) { | |
| // outputs the options form on admin | |
| } | |
| public function update( $new_instance, $old_instance ) { | |
| // processes widget options to be saved | |
| } | |
| public function widget( $args, $instance ) { | |
| // outputs the content of the widget | |
| } | |
| } | |
| class DemoPlugin { | |
| public function __construct() { | |
| load_plugin_textdomain( 'demo-plugin', false, dirname( plugin_basename( __FILE__ ) ) . '/lang' ); | |
| //register hooks using an array with two indexes: the first being $this and the second being the name of the function. | |
| add_action( 'wp_enqueue_scripts', array( $this, 'register_plugin_styles' ) ); | |
| add_action( 'wp_enqueue_scripts', array( $this, 'register_plugin_scripts' ) ); | |
| add_filter( 'the_content', array( $this, 'append_post_notification' ) ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment