Skip to content
Snippets Groups Projects
Commit 3cdcc1e0 authored by Grzegorz Rola's avatar Grzegorz Rola
Browse files

feature(js): support for gutenberg

parent 64c38af5
No related branches found
No related tags found
1 merge request!20Feature/gutenberg
Pipeline #10873 passed with stages
in 2 minutes and 10 seconds
jQuery( document ).ready(function() {
jQuery('.wpdesk').each(function( index ) {
jQuery('.wpdesk-notice-gutenberg').each(function( index ) {
var classList = jQuery(this).attr('class').split(/\s+/);
var type = '';
jQuery.each(classList, function(index, item) {
......
......@@ -58,6 +58,12 @@ class Notice
*/
protected $attributes = array();
/**
* Show notice in gutenberg editor.
*
* @var bool
*/
protected $showInGutenberg = false;
/**
* WPDesk_Flexible_Shipping_Notice constructor.
......@@ -67,19 +73,22 @@ class Notice
* @param bool $dismissible Is dismissible.
* @param int $priority Notice priority.
* @param array $attributes Attributes.
* @param bool $showInGutenberg Show notice in gutenberg editor.
*/
public function __construct(
$noticeContent,
$noticeType = 'info',
$dismissible = false,
$priority = 10,
$attributes = array()
$attributes = array(),
$showInGutenberg = false
) {
$this->noticeContent = $noticeContent;
$this->noticeType = $noticeType;
$this->dismissible = $dismissible;
$this->priority = $priority;
$this->attributes = $attributes;
$this->noticeContent = $noticeContent;
$this->noticeType = $noticeType;
$this->dismissible = $dismissible;
$this->priority = $priority;
$this->attributes = $attributes;
$this->showInGutenberg = $showInGutenberg;
$this->addAction();
}
......@@ -225,9 +234,9 @@ class Notice
protected function getNoticeClass()
{
if ('updated' === $this->noticeType) {
$notice_class = 'wpdesk notice ' . $this->noticeType;
$notice_class = 'notice ' . $this->noticeType;
} else {
$notice_class = 'wpdesk notice notice-' . $this->noticeType;
$notice_class = 'notice notice-' . $this->noticeType;
}
if ($this->dismissible) {
$notice_class .= ' is-dismissible';
......@@ -235,6 +244,9 @@ class Notice
if (isset($this->attributes['class'])) {
$notice_class .= ' ' . $this->attributes['class'];
}
if ($this->showInGutenberg) {
$notice_class .= 'wpdesk-notice-gutenberg';
}
return $notice_class;
}
......
......@@ -30,17 +30,19 @@ class PermanentDismissibleNotice extends Notice
* @param string $noticeContent Notice content.
* @param string $noticeName Notice dismiss option name.
* @param string $noticeType Notice type.
* @param int $priority Priority
* @param int $priority Priority
* @param array $attributes Attributes.
* @param bool $showInGutenberg Show notice in gutenberg editor.
*/
public function __construct(
$noticeContent,
$noticeName,
$noticeType = 'info',
$priority = 10,
$attributes = array()
$attributes = array(),
$showInGutenberg = false
) {
parent::__construct($noticeContent, $noticeType, true, $priority, $attributes);
parent::__construct($noticeContent, $noticeType, true, $priority, $attributes, $showInGutenberg);
$this->noticeName = $noticeName;
$this->noticeDismissOptionName = static::OPTION_NAME_PREFIX . $noticeName;
if (self::OPTION_VALUE_DISMISSED === get_option($this->noticeDismissOptionName, '')) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment