1

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?

2 Answers 2

1

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 first
  • widget - it should output the content of given widget, so it's used on front-end in sidebar, when the widget is printed
  • form - it outputs the options of given widget in admin area, so it's used in admin, when you edit the widget
  • update - it processes the options form and saves the options, so it's used in admin, when you save the widget options
0

By using logging, I found out that if it has not been constructed, then function form is called, then function widget.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.