如何修复这个被删除的PHP4 Style构造函数问题?

时间:2016-08-05 21:50:25

标签: php wordpress

在测试我的插件与PHP7的兼容性时,我看到我的插件中只有一个错误。

FOUND 1 ERROR AFFECTING 1 LINE

246 | ERROR | Deprecated PHP4 style constructor are not supported since PHP7

下面链接的是GitHub上托管的文件,以便您可以看到它。

https://github.com/warfare-plugins/social-warfare/blob/master/functions/widgets.php

Line 246: function widget($args, $instance) {

这是一个用于创建WordPress小部件的类,但在谷歌搜索之后,我无法完全看到它试图对弃用的构造函数方法说些什么。它没有使用与它所在类相同的名称。

所以,无论如何,我需要在该行上做些什么才能使这个完整的PHP7准备就绪?

1 个答案:

答案 0 :(得分:2)

更改

function swp_popular_posts_widget() {
    parent::__construct(false, $name = 'Social Warfare: Popular Posts' );
}

function __construct() {
    parent::__construct(false, $name = 'Social Warfare: Popular Posts' );
}