<?php

/**
 * Class
 */
class Inoby_Admin_Notices {
  private static $errors = [];

  public static function add_error($message, $code = null) {
    $error = new stdClass();
    $error->message = $message;
    $error->code = $code;
    self::$errors[] = $error;
  }

  public static function show_notices() {
    if (count(self::$errors)) {
      echo '<div class="notice notice-error">';
      echo "<h4 style=\"color: red;\">V konfiguraci inoby temy sú chyby</h4>";
      foreach (self::$errors as $error) {
        echo "<p>$error->message</p>";
        if ($error->code) {
          echo "<pre style=\"background: whitesmoke; padding: 1em;\">$error->code</pre>";
        }
        echo "<hr>";
      }
      echo "</div>";
    }
  }
}

if (is_admin()) {
  add_action("admin_notices", ["Inoby_Admin_Notices", "show_notices"]);
}
