<?php

if(!defined('ABSPATH'))
    exit;

class SyrusWidgets {

    public function initialize() {
        $this->register_sidebars();
        $this->register_widgets();
    }

    private function register_sidebars() {

    }

    private function register_widgets() {
        register_widget("Syrus_Categories_Widget");
    }
}

class Syrus_Categories_Widget extends WP_Widget{
    
    function __construct(){
        parent::__construct(
            'syrus_theme_categories_widget',
            "Syrus Theme Categories Widget",
            [
                'description' => "Questo widget permette di inserire delle categorie a piacimento",
            ]
        );
    }

    public function widget($args,$instance){

    }

    public function form($instance){
        $categories = get_categories();
        $i = 0;

        echo '<input type="text" name="input-title" value="" placeholder="Inserisci titolo widget" class="input-title-syrus-theme-categories-widget"></input>';

        foreach($categories as $cat){
            wp_dropdown_categories([
                'show_count' => true,
                'name' => "select-cat[]",
                'class' => "select-cat-syrus-theme-categories-widget",
                'show_option_none' => "Nessuna categoria",
            ]);
            
            $i++;
        }

    }

    public function update($new_instance,$old_instance){

    }

}