mirrored from git://develop.git.wordpress.org/
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Administration: Introduce wp_get_admin_notice()
and wp_admin_notice()
.
#4119
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
costdev
force-pushed
the
wp_admin_notice
branch
from
February 23, 2023 01:26
2fa79ba
to
e6956f2
Compare
costdev
force-pushed
the
wp_admin_notice
branch
4 times, most recently
from
February 23, 2023 19:40
8840eca
to
0e93847
Compare
costdev
force-pushed
the
wp_admin_notice
branch
4 times, most recently
from
June 19, 2023 01:51
d15fbea
to
1148c4e
Compare
costdev
changed the title
Administration: Introduce
Administration: Introduce Jun 19, 2023
wp_admin_notice()
.wp_get_admin_notice()
and wp_admin_notice()
.
costdev
commented
Jul 24, 2023
costdev
commented
Jul 25, 2023
costdev
commented
Jul 25, 2023
costdev
force-pushed
the
wp_admin_notice
branch
2 times, most recently
from
July 25, 2023 02:54
f51e27b
to
bacaca5
Compare
costdev
force-pushed
the
wp_admin_notice
branch
from
August 9, 2023 00:02
bacaca5
to
da82115
Compare
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This introduces two new functions to standardize admin notice output and reduce maintenance.
wp_get_admin_notice()
- Returns the markup for an admin notice.wp_admin_notice()
- Outputs an admin notice.Parameters
The functions accept the following parameters:
string $message
- The message for the admin notice.array $args
- Optional. Arguments for the admin notice. Default empty array.string $type
- Optional. The type of the admin notice. e.g. 'success', 'warning', 'info'. Default empty string.bool $dismissible
- Optional. Whether the admin notice is dismissible. Default false.string $id
- Optional. The ID for the admin notice. Default empty string.string[] $additional_classes
- Optional. A string array of class names. Default empty array.bool $paragraph_wrap
- Optional. Whether to wrap the message in paragraph tags. Default true.Filters
wp_get_admin_notice
has the following filters:wp_admin_notice_args
- Filters the arguments for the admin notice.(array) $args
,(string) $message
.wp_admin_notice_markup
- Filters the markup for the admin notice.(string) $markup
,(string) $message
,(array) $args
.Actions
wp_admin_notice
has the following action:wp_admin_notice
- Fires before an admin notice is output.(string) $message
,(array) $args
.Tests
PHPUnit tests are included and achieve 100% line and branch coverage.
Examples
Get the markup for a dismissible success notice
Result:
Output a dismissible success notice
Output:
Make all admin notices dismissible
Output:
Add a custom class to all admin notices
Output:
Log warning notices
https://core.trac.wordpress.org/ticket/57791