WP 4.3, WP_Widget syntax and older versions of Roots

Ran into this error today when I updated a production site that uses roots 6.5.x to WP 4.3.

Notice: The called constructor method for WP_Widget is deprecated since version 4.3.0! Use
instead. in /var/www/dev.ecotrust.org/wordpress/wp-includes/functions.php on line 3457

Thought I’d share the solution here in case anyone else runs into it. As you can see, WP doesn’t actually give you any sort of trace.

In /your-theme/lib/widgets.php change:

$this->WP_Widget('widget_roots_vcard', __('Roots: vCard', 'roots'), $widget_ops);


parent::__construct('widget_roots_vcard', __('Roots: vCard', 'roots'), $widget_ops);

Seems to work just fine.

More info from the WP team here for the curious: https://gist.github.com/chriscct7/d7d077afb01011b1839d


Yeah, this is a result of the deprecated PHP4 constructors, which are getting removed in PHP7. WordPress 4.3 is preparing to be PHP7 compatible, so it’s removing those.