The called constructor method for WP_Widget

Please advise code fix for

[01-Feb-2016 02:41:42 UTC] PHP Notice: The called constructor method for WP_Widget is deprecated since version 4.3.0! Use
instead. in /wp-includes/functions.php on line 3624

Plugin needs to be updated for WP 4.4.1

I disabled/re-enabled 50 plugins to trace the warning to OA Social Login

Thank you


  • Fred_PinelFred_PinelMember
    edited February 2016
    Thanks for reporting this.
    However, the version 5.0 of the plugin does use the recommended constructor. Also, we do not get this notice in our WP instances.
    To spare you additional trouble, maybe you can add an action hook that logs the backtrace, so we can see who is using this deprecated constructor.
    In your theme's functions.php file (accessible as Administrator), add something like:
    function log_backtrace($class, $version) {
       $bt = wp_debug_backtrace_summary();
       error_log('backtrace: '. $class .', '. $bt);
    add_action( 'deprecated_constructor_run', 'log_backtrace', 10, 2);
    And check the debug.log for the information.

    Hope this helps.
  • Thank you for this code,,,been looking for something like that.

    So how do I read into this:

    [03-Feb-2016 15:42:15 UTC] backtrace: WP_Widget, require('wp-blog-header.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('init'), call_user_func_array, wp_widgets_init, do_action('widgets_init'), call_user_func_array, __lambda_func, register_widget, WP_Widget_Factory->register, oa_social_login_widget->__construct, WP_Widget->WP_Widget, _deprecated_constructor, do_action('deprecated_constructor_run'), call_user_func_array, log_backtrace

    [03-Feb-2016 15:42:15 UTC] PHP Notice: The called constructor method for WP_Widget is deprecated since version 4.3.0! Use
    instead. in /public_html/wp-includes/functions.php on line 3624
  • Hi,

    Which version of the OneAll plugin are you using? Version 5.0 does not seem to have this code, but version 4.6 does.

    So, the backtrace array lists all the nested function calls up to the error.
    The last call is at the end. So you need to read it from the end. In this case, it's our log_backtrace function, called by the do_action we added, itself called by the deprecated constructor (a specific function WP developers added to trigger this action, plus message), itself called by Widget's old-fashion constructor, in turn called by our plugin's constructor (__construct). The culprit :-)
    The previous functions that lead to this call follow, but it is not relevant here.
  • Wordpress says 5.0
  • Claude_SchlesserClaude_SchlesserAdministratorOneAll Team
    Hi Vincent,

    it's possible that we released a Hotfix without updating the plugin version.
    Could you please try to uninstall the plugin and re-install the latest version from the repository?

Sign In or Register to comment.