When a widget is used, in what order are the members used? Obviously, __construct
is first, but what happens next? function widget()
? function form()
?
Which comes first, the chicken or the egg?
It's hard to tell the order in which these functions are called, because they're used in different contexts.
WP_Widget
class has 4 methods:
__construct
- it constructs the widget, so it's always run firstwidget
- it should output the content of given widget, so it's used on front-end in sidebar, when the widget is printedform
- it outputs the options of given widget in admin area, so it's used in admin, when you edit the widgetupdate
- it processes the options form and saves the options, so it's used in admin, when you save the widget optionsBy using logging, I found out that if it has not been constructed, then function form is called, then function widget.