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
436a297d
Commit
436a297d
authored
1 year ago
by
Grzegorz Rola
Browse files
Options
Downloads
Patches
Plain Diff
bugfix(ajax): permission check
parent
cd51ab56
No related branches found
No related tags found
1 merge request
!28
bugfix(ajax): permission check
Pipeline
#337385
failed
1 year ago
Stage: prepare-vendor
Stage: tools
Stage: tests
Stage: deploy
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+5
-0
5 additions, 0 deletions
CHANGELOG.md
src/WPDesk/Notice/AjaxHandler.php
+14
-12
14 additions, 12 deletions
src/WPDesk/Notice/AjaxHandler.php
with
19 additions
and
12 deletions
CHANGELOG.md
+
5
−
0
View file @
436a297d
## [3.2.4] - 2024-03-11
### Fixed
-
permission check on notice dismiss action
## [3.2.3] - 2023-04-06
### Fixed
-
fatal error if get_current_screen function return null
## [3.2.2] - 2023-03-03
### Added
-
security nonce in permanent dismissible notice ajax action
...
...
This diff is collapsed.
Click to expand it.
src/WPDesk/Notice/AjaxHandler.php
+
14
−
12
View file @
436a297d
...
...
@@ -78,17 +78,21 @@ class AjaxHandler implements HookablePluginDependant {
if
(
isset
(
$_POST
[
self
::
POST_FIELD_NOTICE_NAME
]
)
)
{
$noticeName
=
sanitize_text_field
(
$_POST
[
self
::
POST_FIELD_NOTICE_NAME
]
);
$option_name
=
PermanentDismissibleNotice
::
OPTION_NAME_PREFIX
.
$noticeName
;
ajax_check_referer
(
$option_name
,
self
::
POST_FIELD_SECURITY
);
if
(
!
current_user_can
(
'edit_posts'
)
)
{
wp_send_json_error
();
}
if
(
isset
(
$_POST
[
self
::
POST_FIELD_SOURCE
]
)
)
{
$source
=
sanitize_text_field
(
$_POST
[
self
::
POST_FIELD_SOURCE
]
);
}
else
{
$source
=
null
;
}
$security
=
$_POST
[
self
::
POST_FIELD_SECURITY
]
??
''
;
$option_name
=
PermanentDismissibleNotice
::
OPTION_NAME_PREFIX
.
$noticeName
;
if
(
wp_verify_nonce
(
$security
,
$option_name
)
)
{
update_option
(
$option_name
,
PermanentDismissibleNotice
::
OPTION_VALUE_DISMISSED
...
...
@@ -98,11 +102,9 @@ class AjaxHandler implements HookablePluginDependant {
wp_send_json_success
();
}
}
}
if
(
defined
(
'DOING_AJAX'
)
&&
DOING_AJAX
)
{
wp_send_json_error
();
}
}
}
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