Return to Snippet

Revision: 49357
at July 20, 2011 20:03 by smashprogrammer


Initial Code
add_action("widgets_init", array('Widget_name', 'register'));
class Widget_name {
  function control(){
    echo 'I am a control panel';
  }
  function widget($args){
    echo $args['before_widget'];
    echo $args['before_title'] . 'Your widget title' . $args['after_title'];
    echo 'I am your widget';
    echo $args['after_widget'];
  }
  function register(){
    register_sidebar_widget('Widget name', array('Widget_name', 'widget'));
    register_widget_control('Widget name', array('Widget_name', 'control'));
  }
}

Initial URL

                                

Initial Description

                                

Initial Title
wordpress - register a widget in function.php

Initial Tags
php, wordpress

Initial Language
PHP