Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; WP_Widget_PostViews has a deprecated constructor in ***** /wp-content/plugins/wp-postviews/wp-postviews.php on line 670
Invalid comment status.
百度了一把,发现是函数和类构造名称冲突了,解决办法如下:
编辑 wp-postviews.php 这个文件,定位到 670 行如下代码:
class WP_Widget_PostViews extends WP_Widget { // Constructor function WP_Widget_PostViews() { $widget_ops = array('description' => __('WP-PostViews views statistics', 'wp-postviews')); $this->WP_Widget('views', __('Views', 'wp-postviews'), $widget_ops); }
很明显,function 名称和 class 冲突了,所以我们只要把 function 名称改成 __construct 即可:
class WP_Widget_PostViews extends WP_Widget { // Constructor function __construct() { $widget_ops = array('description' => __('WP-PostViews views statistics', 'wp-postviews')); $this->WP_Widget('views', __('Views', 'wp-postviews'), $widget_ops); }
保存后这个错误就解决了,如果遇到类似的报错,也可以参考解决了。