Codex tools: Log in / create account
This article is marked as in need of editing. You can help Codex by editing it.
Basically a widget is a PHP function that echoes string data to STDOUT when called. To turn such a PHP function into a Wordpress Widget it must be registered as such. This is done by a so called PHP callback (a so called Pseudo-Type in PHP documentation) that is registered by a wordpress widget API function.
register_sidebar_widget($callback);
That is basically all you need to do at least.
Wordpress API is located in wp-includes/widgets.php . There you find the sourcecode to all existing widget functions.
Practically it is advised to not use the functions starting with wp_.
Example: To register a widget take the register_sidebar_widget function not the wp_register_sidebar_widget in your php code.
Sidenote: If you do not use wp_ you can not use all the functions that some widgets might want to use. If you use wp_ you risk that your widget breaks which each update.
Widgets can be conded sothat they can exist one time or they can exist multiple times. Wordpress is doing the work for you to instatiate your Widget multiple times if you follow some rules.
Widgets can provide their own configuration Panel with them. This is a very nice feature.