Skip to content
Snippets Groups Projects
Select Git revision
  • d7c257e6e8a85f6c83946a703ae0dccb5fe60516
  • master default protected
  • bugfix/wordpress-review
  • fix/duplicate
  • bugfix/get_current_screen_fail
  • feature/dismiss-nonce
  • replace-dodgy-path
  • bugfix/notice-not-show
  • devel
  • 3.3.0
  • 3.2.5
  • 3.2.4
  • 3.2.3
  • 3.2.2
  • 3.2.1
  • 3.2.0
  • 3.2.0-beta7
  • 3.2.0-beta6
  • 3.2.0-beta5
  • 3.2.0-beta4
  • 3.2.0-beta3
  • 3.2.0-beta2
  • 3.2.0-beta1
  • 3.1.4
  • 3.1.4-beta1
  • 3.1.3
  • 3.1.1
  • 3.1
  • 3.0
29 results

admin-head-js.php

Blame
  • Notice.php 2.02 KiB
    <?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 {