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
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wpdesk
wp-notice
Commits
0530c90b
Commit
0530c90b
authored
6 years ago
by
Grzegorz Rola
Browse files
Options
Downloads
Patches
Plain Diff
Attributes
parent
55ce2af9
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!6
Feature/attributes
Pipeline
#7791
passed
6 years ago
Stage: tools
Stage: tests
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/WPDesk/Notice/Notice.php
+16
-3
16 additions, 3 deletions
src/WPDesk/Notice/Notice.php
src/WPDesk/Notice/PermanentDismissibleNotice.php
+3
-3
3 additions, 3 deletions
src/WPDesk/Notice/PermanentDismissibleNotice.php
with
19 additions
and
6 deletions
src/WPDesk/Notice/Notice.php
+
16
−
3
View file @
0530c90b
...
...
@@ -64,13 +64,20 @@ class Notice
* @param string $noticeType Notice type.
* @param bool $dismissible Is dismissible.
* @param int $priority Notice priority.
*/
public
function
__construct
(
$noticeContent
,
$noticeType
=
'info'
,
$dismissible
=
false
,
$priority
=
10
)
{
* @param array $attributes Attributes.
*/
public
function
__construct
(
$noticeContent
,
$noticeType
=
'info'
,
$dismissible
=
false
,
$priority
=
10
,
$attributes
=
array
()
)
{
$this
->
noticeContent
=
$noticeContent
;
$this
->
noticeType
=
$noticeType
;
$this
->
dismissible
=
$dismissible
;
$this
->
priority
=
$priority
;
$this
->
attributes
=
$attributes
;
$this
->
addAction
();
}
...
...
@@ -176,6 +183,9 @@ class Notice
if
(
$this
->
dismissible
)
{
$notice_class
.
=
' is-dismissible'
;
}
if
(
isset
(
$this
->
attributes
[
'class'
]))
{
$notice_class
.
=
$this
->
attributes
[
'class'
];
}
return
$notice_class
;
}
...
...
@@ -187,6 +197,9 @@ class Notice
protected
function
getAttributesAsString
()
{
$attribute_string
=
sprintf
(
'class="%1$s"'
,
esc_attr
(
$this
->
getNoticeClass
()));
foreach
(
$this
->
attributes
as
$attribute_name
=>
$attribute_value
)
{
$attribute_string
.
=
sprintf
(
' %1$s="%2$s"'
,
esc_html
(
$attribute_name
),
esc_attr
(
$attribute_value
));
}
return
$attribute_string
;
}
...
...
This diff is collapsed.
Click to expand it.
src/WPDesk/Notice/PermanentDismissibleNotice.php
+
3
−
3
View file @
0530c90b
...
...
@@ -31,11 +31,11 @@ class PermanentDismissibleNotice extends Notice
* @param string $noticeType Notice type.
* @param string $noticeName Notice dismiss option name.
* @param int $priority Priority
* @param array $attributes Attributes.
*/
public
function
__construct
(
$noticeContent
,
$noticeType
,
$noticeName
,
$priority
=
10
)
public
function
__construct
(
$noticeContent
,
$noticeType
,
$noticeName
,
$priority
=
10
,
$attributes
=
array
())
{
parent
::
__construct
(
$noticeContent
,
$noticeType
,
true
,
$priority
);
parent
::
__construct
(
$noticeContent
,
$noticeType
,
true
,
$priority
,
$attributes
);
$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