[wp-trac] [WordPress Trac] #19691: Cannot modify admin messages for /wp-admin/edit.php
WordPress Trac
wp-trac at lists.automattic.com
Fri Dec 30 02:10:02 UTC 2011
#19691: Cannot modify admin messages for /wp-admin/edit.php
--------------------------+------------------------------------------------
Reporter: mikeschinkel | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: | Version: 3.3
Administration | Keywords: dev-feedback has-patch 2nd-opinion
Severity: normal |
--------------------------+------------------------------------------------
The admin console messages output on line `264` of WordPress 3.3's file
`/wp-admin/edit.php` are not filterable. This causes problems when added
row actions need to HTTP GET from to WordPress to modify a post and then
display an appropriate message complete with a revert link ''(like the
"Trash" link does.)''
An example use-case could be for a custom post type used for both quotes
and invoices where a row action might be ''"Convert Quote to Invoice"''
where you'd want a message and link displayed at the top of the admin
after similar to this:
- ''Quote #{$post_id} converted to Invoice. __Revert__''
Currently the only way to accomplish this is to pick hooks before and
after the messages are output and use PHP's output buffering; clearly not
a ''"best practice"'' approach.
In order to address this I'm proposing an '''`'admin_messages'`''' filter
hook to run just before the messages are output:
{{{
$messages = apply_filters( 'admin_messages', $messages );
}}}
However, since messages are output in numerous locations in the WordPress
admin it seemed best to add the hook in every location where messages are
output, which is what my patch does. Thus a hook can look at `$pagenow`
or `get_current_screen()` to decide it is needs to do anything.
Also while searching for places in the admin code that echo messages I
found `$messages` are sometimes an array of HTML where the entire array is
echoed and other times the $messages are an array with an index passed via
`$_GET` and only one message will be displayed. For those cases I created
another hook '''`'admin_message'`''' ''(note that this hook name is
singular)'':
{{{
$message = apply_filters( 'admin_message', $message, $messages,
$_GET['message'] );
}}}
I really only found a specific need for `/wp-admin/edit.php` today, but it
seemed that it would be better for consistency if all messages were made
hook filterable. That's why I created a larger patch when all my use-case
needs is one new line.
Looking forward to your feedback.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/19691>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list