Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wp-notice
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wpdesk
wp-notice
Commits
3cdcc1e0
Commit
3cdcc1e0
authored
3 years ago
by
Grzegorz Rola
Browse files
Options
Downloads
Patches
Plain Diff
feature(js): support for gutenberg
parent
64c38af5
No related branches found
No related tags found
1 merge request
!20
Feature/gutenberg
Pipeline
#10873
passed with stages
in 2 minutes and 10 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
assets/js/gutenberg.js
+1
-1
1 addition, 1 deletion
assets/js/gutenberg.js
src/WPDesk/Notice/Notice.php
+20
-8
20 additions, 8 deletions
src/WPDesk/Notice/Notice.php
src/WPDesk/Notice/PermanentDismissibleNotice.php
+5
-3
5 additions, 3 deletions
src/WPDesk/Notice/PermanentDismissibleNotice.php
with
26 additions
and
12 deletions
assets/js/gutenberg.js
+
1
−
1
View file @
3cdcc1e0
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
)
{
...
...
This diff is collapsed.
Click to expand it.
src/WPDesk/Notice/Notice.php
+
20
−
8
View file @
3cdcc1e0
...
...
@@ -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
;
}
...
...
This diff is collapsed.
Click to expand it.
src/WPDesk/Notice/PermanentDismissibleNotice.php
+
5
−
3
View file @
3cdcc1e0
...
...
@@ -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
,
''
))
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment