0

I recently made up simple Minecraft site about one starting server, instaled plugin called:Minestatus, and getting these errors. Exact same error for one other plugin. I am running 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

Below is the code in widget.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');
0

2 Answers 2

1

Remove "array" from your arguments declaration:

public function widget(array $args, $instance) should be public function widget($args, $instance)

0

The class you should extend may be better Widget not Widgetize.

class Minestatus_Widget extends Widgetize
2
  • I am not some kind of pro in this but i think its related to "Widgetize.php" in the same folder... Jan 6, 2017 at 1:38
  • @Dejviiisek96 this may be a custom solution, in WordPress there is no such file.
    – prosti
    Jan 6, 2017 at 8:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.