Key Takeaways:
Registering new widgets is a complex process. It may be undertaken in a theme or a plugin, depending on whether the widget is primarily presentational or functional.
The Widgets API is object-oriented. Every new widget adds its functionality by extending a base class, called WP_Widget.
The key functions in widget creation include: __construct(), which sets the widget's base variables; form(), which creates user-editable variables for the widget; update(), which allows the widget to be updated with new user-submitted variables; and widget(), which prints out the widget's code as HTML.
Widgets are a powerful part of WordPress, that make adding custom functionality to defined areas simple and user-friendly. In this chapter, we'll describe the process of registering your own widgets for use.
Deciding Whether to Register Widgets through a Theme or Plugin
Widgets can be sanely registered in two places:
Your theme's functions.php
A custom plugin
Widgets often straddle ...