Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
596 views
in Technique[技术] by (71.8m points)

php - The called constructor method for WP_Widget is deprecated since version 4.3.0

I just updated to WordPress 4.3 and it seems that something is broken.

I get this error that shows up on my page:

Notice: The called constructor method for WP_Widget is deprecated since version 4.3.0! Use __construct() instead. in /mnt/stor13-wc1-ord1/754452/www.eden-festival.com/web/content/securewp/wp-includes/functions.php on line 3457

Is there something that needs to be fixed?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Since php 7 isn't supported anymore, the old php 4 object construct was replaced with __construct(). Wordpress developers created a notice message so the plugin developers would change the way their plugins work (and also so it could run on next php versions). Since php 4 has long been dead, there's no reason to use this style of object construct.

How to fix?

Option 1 - not going to upgrade to newer php versions

just add add_filter('deprecated_constructor_trigger_error', '__return_false');

to your functions.php file it will ignore those notices.

Option 2 - might upgrade to php 7 / prefer dealing with the issue rather than silencing it

If this is a third party plugin, beware that if you make the change yourself and the plugin developer releases an update then it will override your changes. Contacting the plugin developer to fix this issue will be the best option

Find the problematic plugin and change:

parent::WP_Widget

To

parent::__construct


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...