0
votes

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 __construct() 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

and

/**
 * @constructor
 */
public function __construct()
{
    $this->initPluginConstants();

    $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);
    $this->registerScriptsAndStyles();
}
1

1 Answers

2
votes

Replace this:

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

with

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.