TigerXtrm TigerXtrm - 4 months ago 33
PHP Question

Wordpress plugin 'WP_widget' deprecated, how to fix it?

I downloaded a plugin for Wordpress that I'd really like to use. Only problem is it throws a deprecated error during debugging for the use of WP_widget.

Notice: The called constructor method for WP_Widget in SteamApiWidget is deprecated since version 4.3.0! Use
instead. in functions.php on line 3770

So I did some searching but unfortunately simply replacing 'WP_widget' with '__construct()' only managed to break the plugin. And that's about as far as my coding knowledge goes. The two instances where I found 'WP_widget' are down below. What do I need to change to make this work with the current PHP standards?

* Class SteamApiWidget
class SteamApiWidget extends WP_Widget


* @constructor
public function __construct()

$widget_option = array(
'classname' => PLUGIN_SLUG,
'description' => __('A simple WordPress widget for your steam profile.', PLUGIN_LOCALE)

$this->WP_Widget(PLUGIN_SLUG, __(PLUGIN_NAME, PLUGIN_LOCALE), $widget_option);


Replace this:

$this->WP_Widget(PLUGIN_SLUG, __(PLUGIN_NAME, PLUGIN_LOCALE), $widget_option);


parent::__construct(PLUGIN_SLUG, __(PLUGIN_NAME, PLUGIN_LOCALE), $widget_option);

You may have to place it first in the __construct function that contains that line.