The called constructor method for WP_Widget is deprecated since version 4.3.0

前端 未结 6 613
一生所求
一生所求 2020-12-13 13:28

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 construct

6条回答
  •  生来不讨喜
    2020-12-13 13:58

    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

提交回复
热议问题