How to write a widget

You will need to make the following files to make a widget.
1. Folder with the widget name and 2 files inside
-1a. widget.php
-1b. config.xml

Step 1

in the config.xml file write out your configurations

is the name of the class in the widget file.
is your widget name.
is the description for this widget.
is the version for the widget.

Step 2

Once you have this done, open up your widget.php
You will need 3 functions in your widget.php class

  • get_content() – returns a value for the content to be displayed
    get_config() – returns a value for the configuration to be displayed
    update_config($values)
  • *NOTE* Do NOT have any ‘echo’ or ‘print’ inside the class as this will be detected before it launches the widget. Echo exclusion is because of formatting purposes.

    Example

    It is important that you understand the naming convention of your properties names to be

    .
    Remember to have a submit button named ‘widget_update’ and a hidden value name class with your class filename inside or else your codes will NOT load.

    Step 3

    Put your folder with the files inside into the widgets folder and you’re set to go!