Advertisement
lion_neel

Function Reference/register widget

Jun 15th, 2013
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.80 KB | None | 0 0
  1.  /*Description
  2. ================*/
  3.  
  4. Registers a widget.
  5.  
  6.  /*Usage
  7. ================*/
  8.  
  9. <?php register_widget( $widget_class ) ?>
  10.  
  11.  /*Parameters
  12. ================*/
  13.  
  14. $widget_class
  15.     (object) The name of a class[div] that extends WP_Widget
  16.  
  17. /*Example
  18. =========*/
  19.  
  20. class MyNewWidget extends WP_Widget {
  21.  
  22.     function MyNewWidget() {
  23.         // Instantiate the parent object
  24.         parent::__construct( false, 'My New Widget Title' );
  25.     }
  26.  
  27.     function widget( $args, $instance ) {
  28.         // Widget output
  29.     }
  30.  
  31.     function update( $new_instance, $old_instance ) {
  32.         // Save widget options
  33.     }
  34.  
  35.     function form( $instance ) {
  36.         // Output admin widget options form
  37.     }
  38. }
  39.  
  40. function myplugin_register_widgets() {
  41.     register_widget( 'MyNewWidget' );
  42. }
  43.  
  44. add_action( 'widgets_init', 'myplugin_register_widgets' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement