<?php

class Inoby_Newsletter_Widget extends WP_Widget {
  function __construct() {
    $widget_options = [
      "classname" => "Inoby_Newsletter_Widget",
      "description" => "Inoby newsletter widget",
    ];

    parent::__construct("inoby-newsletter-widget", "Inoby newsletter", $widget_options);
  }

  function form($instance) {
    $configs = ["MAILCHIMP_API_KEY", "MAILCHIMP_LIST_ID", "MAILCHIMP_REGION"];
    foreach ($configs as $conf) {
      if (!defined($conf)) {
        echo "<p>!!! define {$conf} constant in wp-config.php !!!</p>";
      }
    }
  }

  function widget($args, $instance) {
    get_template_part("template-parts/newsletter");
  }
}
