Plugin showing error

时间:2017-01-03 作者:Dejviiisek96

我最近制作了一个简单的Minecraft网站,介绍了一个启动服务器,名为:Minestatus的instaled插件,并得到了这些错误。另一个插件的错误完全相同。我正在跑步WP 3.19.4

Warning: Declaration of Minestatus_Widget::widget(array $args, $instance) should be compatible with WP_Widget::widget($args, $instance) in /data/web/virtuals/151993/virtual/www/domains/clashofcraft.eu/wp-content/plugins/minestatus/widget.php on line 6

Warning: Declaration of Minestatus_Widget::form(array $instance) should be compatible with WP_Widget::form($instance) in /data/web/virtuals/151993/virtual/www/domains/clashofcraft.eu/wp-content/plugins/minestatus/widget.php on line 6
下面是小部件中的代码。php

<?php

require dirname(__FILE__) . \'/libs/Widgetize.php\';
require dirname(__FILE__) . \'/libs/ApiClient.php\';

class Minestatus_Widget extends Widgetize
{
    /**
     * Construct
     */
    public function __construct()
    {
        parent::__construct(\'Minestatus\', array(
            \'title\' => \'Server status\',
            \'host\' => \'server.yourserver.com\',
            \'port\' => \'25565\',
            \'show_status\' => \'on\',
            \'show_latency\' => \'on\',
            \'show_players_max\' => \'on\',
            \'show_players_online\' => \'on\',
            \'show_host\' => \'on\',
            \'show_ip\' => \'on\',
            \'show_port\' => \'on\',
            \'show_version\' => \'on\',
            \'show_protocol\' => \'on\',
        ));
    }

    /**
     * @param array $args
     * @param array $instance
     */
    public function widget(array $args, $instance)
    {
        $instance = $this->hydrate($instance);

        // Get ip if localhost
        if (in_array($instance[\'host\'], array(\'127.0.0.1\', \'localhost\'))) {
            $instance[\'host\'] = $_SERVER[\'SERVER_ADDR\'];
        }

        $client = new ApiClient($instance[\'host\'], $instance[\'port\']);
        $status = $client->call();

        require dirname(__FILE__) . \'/templates/widget.phtml\';
    }

    /**
     * @param array $instance
     * @return string|void
     */
    public function form(array $instance)
    {
        $instance = $this->hydrate($instance);
        require dirname(__FILE__) . \'/templates/form.phtml\';
    }

    /**
     * @param $newInstance
     * @param $oldInstance
     * @return array
     */
    public function update($newInstance, $oldInstance)
    {
        $instance = array();
        foreach ($newInstance as $option => $value) {

            if((int) $value > 0 && !in_array($option, array(\'host\'))) {
                $value = (int) $value;
            }
            $instance[$option] = strip_tags(trim($value));
        }
        return $instance;
    }
}

Widgetize::add(\'Minestatus_Widget\');

2 个回复
SO网友:Jamy

从参数声明中删除“array”:

public function widget(array $args, $instance) 应该是public function widget($args, $instance)

SO网友:prosti

你应该延长的课程可能更好WidgetWidgetize.

class Minestatus_Widget extends Widgetize