admin管理员组文章数量:1332345
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?
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?
Share Improve this question edited May 27, 2020 at 8:46 Krzysiek Dróżdż 25.5k9 gold badges53 silver badges74 bronze badges asked May 27, 2020 at 8:40 GreatDayDanGreatDayDan 153 bronze badges2 Answers
Reset to default 1It'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 options
By using logging, I found out that if it has not been constructed, then function form is called, then function widget.
本文标签: widgetsfor class wpwidgetin what order are the member functions called
版权声明:本文标题:widgets - for class wp_widget, in what order are the member functions called? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742327988a2454111.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论