Skip to content
Snippets Groups Projects
Select Git revision
  • c3e34039e9dce1814931de29009ca8f14f3f3c1a
  • main default protected
  • v0.10
  • 0.10.6
  • 0.10.5
  • 0.10.4
  • 0.10.3
  • 0.10.2
  • 0.10.1
  • 0.10.0
  • 0.9.1
  • 0.9.0
12 results

CHANGELOG.md

Blame
  • To find the state of this project's repository at the time of any of these versions, check out the tags.
    PermanentDismissibleNotice.php 1.15 KiB
    <?php
    
    namespace WPDesk\Notice;
    
    /**
     * Class Notice.
     *
     * @package WPDesk\Notice
     */
    class PermanentDismissibleNotice extends Notice
    {
    
        const OPTION_NAME_PREFIX = 'wpdesk_notice_dismiss_';
    
        /**
         * @var string
         */
        private $noticeName;
    
        /**
         * @var string
         */
        private $noticeDismissOptionName;
    
        /**
         * WPDesk_Flexible_Shipping_Notice constructor.
         *
         * @param string $noticeType Notice type.
         * @param string $noticeContent Notice content.
         * @param string $noticeName Notice dismiss option name.
         */
        public function __construct($noticeType, $noticeContent, $noticeName)
        {
            parent::__construct($noticeType, $noticeContent, true);
            $this->noticeName = $noticeName;
            $this->noticeDismissOptionName = static::OPTION_NAME_PREFIX . $noticeName;
        }
    
        /**
         * Get attributes as string.
         *
         * @return string
         */
        protected function getAttributesAsString()
        {
            $attributesAsString = parent::getAttributesAsString();
            $attributesAsString .= sprintf('data-notice-name="%1$s"', esc_attr($this->noticeName));
            return $attributesAsString;
        }
    
    }