From bdfb059db7d96fac0a13257981bfb656c4b6fd29 Mon Sep 17 00:00:00 2001
From: Grzegorz Rola <grola@seostudio.pl>
Date: Mon, 24 Sep 2018 21:58:58 +0200
Subject: [PATCH] init

---
 src/Notice/AjaxHandler.php       | 16 ++++++
 src/Notice/DismissibleNotice.php | 34 +++++++++++
 src/Notice/Notice.php            | 99 ++++++++++++++++++++++++++++++++
 3 files changed, 149 insertions(+)
 create mode 100644 src/Notice/AjaxHandler.php
 create mode 100644 src/Notice/DismissibleNotice.php
 create mode 100644 src/Notice/Notice.php

diff --git a/src/Notice/AjaxHandler.php b/src/Notice/AjaxHandler.php
new file mode 100644
index 0000000..19bafd9
--- /dev/null
+++ b/src/Notice/AjaxHandler.php
@@ -0,0 +1,16 @@
+<?php
+
+namespace WPDesk\Notice;
+
+/**
+ * Class Notice.
+ *
+ * @package WPDesk\Notice
+ */
+class AjaxHandler
+{
+
+
+
+}
+
diff --git a/src/Notice/DismissibleNotice.php b/src/Notice/DismissibleNotice.php
new file mode 100644
index 0000000..d05c133
--- /dev/null
+++ b/src/Notice/DismissibleNotice.php
@@ -0,0 +1,34 @@
+<?php
+
+namespace WPDesk\Notice;
+
+/**
+ * Class Notice.
+ *
+ * @package WPDesk\Notice
+ */
+class DismissibleNotice extends Notice
+{
+
+	/**
+	 * @var string
+	 */
+	private $noticeDismissOptionName;
+
+    /**
+     * WPDesk_Flexible_Shipping_Notice constructor.
+     *
+     * @param string $noticeType Notice type.
+     * @param string $noticeContent Notice content.
+     * @param string $noticeDismissOptionName Notice dismiss option name.
+     */
+    public function __construct($noticeType, $noticeContent, $noticeDismissOptionName)
+    {
+        parent::__construct($noticeType, $noticeContent, true);
+        $this->noticeDismissOptionName = $noticeContent;
+    }
+
+    protected
+
+}
+
diff --git a/src/Notice/Notice.php b/src/Notice/Notice.php
new file mode 100644
index 0000000..635b530
--- /dev/null
+++ b/src/Notice/Notice.php
@@ -0,0 +1,99 @@
+<?php
+
+namespace WPDesk\Notice;
+
+/**
+ * Class Notice.
+ *
+ * @package WPDesk\Notice
+ */
+class Notice
+{
+
+    const NOTICE_TYPE_ERROR = 'error';
+    const NOTICE_TYPE_WARNING = 'warning';
+    const NOTICE_TYPE_SUCCESS = 'success';
+    const NOTICE_TYPE_INFO = 'info';
+
+    /**
+     * Notice type.
+     *
+     * @var string
+     */
+    protected $noticeType;
+
+    /**
+     * Notice content.
+     *
+     * @var string
+     */
+    protected $noticeContent;
+
+    /**
+     * Is dismissible.
+     *
+     * @var bool
+     */
+    protected $isDismissible;
+
+	/**
+	 * Attributes.
+	 *
+	 * @var string[]
+	 */
+    protected $attributes = array();
+
+    /**
+     * WPDesk_Flexible_Shipping_Notice constructor.
+     *
+     * @param string $noticeType Notice type.
+     * @param string $noticeContent Notice content.
+     * @param bool $isDismissible Is dismissible.
+     */
+    public function __construct($noticeType, $noticeContent, $isDismissible = false)
+    {
+        $this->noticeType    = $noticeType;
+        $this->noticeContent = $noticeContent;
+        $this->isDismissible = $isDismissible;
+        add_action('admin_notices', [$this, 'showNotice']);
+    }
+
+    /**
+     * Get notice class.
+     *
+     * @return string
+     */
+    protected function getNoticeClass()
+    {
+        if ('updated' === $this->noticeType) {
+            $notice_class = 'notice ' . $this->noticeType;
+        } else {
+            $notice_class = 'notice notice-' . $this->noticeType;
+        }
+        if ($this->isDismissible) {
+            $notice_class .= ' is-dismissible';
+        }
+        return $notice_class;
+    }
+
+    /**
+     * Get attributes as string.
+     *
+     * @return string
+     */
+    protected function getAttributesAsString()
+    {
+        $attribute_string = sprintf('class="%1$s"', esc_attr($this->getNoticeClass()));
+        return $attribute_string;
+    }
+
+    /**
+     * Show notice;
+     */
+    public function showNotice()
+    {
+        echo sprintf('<div %1$s><p>%2$s</p></div>', $this->getAttributesAsString(), $this->noticeContent);
+    }
+
+}
+
-- 
GitLab