Taxonomy: Correct the check for error messages in `wp-admin/edit-tag-form.php`.

Instead of checking for a specific message, e.g. “Item not updated”, the `$_REQUEST['error']` variable is now checked. This allows for custom messages added via the `term_updated_messages` filter to be considered an error when appropriate, and displayed with the correct CSS class.

This also brings consistency with a similar check in `wp-admin/edit-tags.php`.

Follow-up to [31823], [44663].

Props xipasduarte.
Fixes #61896.
Built from https://develop.svn.wordpress.org/trunk@58918


git-svn-id: http://core.svn.wordpress.org/trunk@58314 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2024-08-20 17:50:16 +00:00
parent fbf02475bc
commit 1aa22ca3c6
3 changed files with 8 additions and 6 deletions

View File

@ -72,7 +72,7 @@ do_action( "{$taxonomy}_pre_edit_form", $tag, $taxonomy ); ?>
<h1><?php echo $tax->labels->edit_item; ?></h1>
<?php
$class = ( isset( $msg ) && 5 === $msg ) ? 'error' : 'success';
$class = ( isset( $_REQUEST['error'] ) ) ? 'error' : 'success';
if ( $message ) {
$message = '<p><strong>' . $message . '</strong></p>';
@ -83,6 +83,7 @@ if ( $message ) {
esc_html( $tax->labels->back_to_items )
);
}
wp_admin_notice(
$message,
array(

View File

@ -321,8 +321,6 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
// Also used by the Edit Tag form.
require_once ABSPATH . 'wp-admin/includes/edit-tag-messages.php';
$class = ( isset( $_REQUEST['error'] ) ) ? 'error' : 'updated';
if ( is_plugin_active( 'wpcat2tag-importer/wpcat2tag-importer.php' ) ) {
$import_link = admin_url( 'admin.php?import=wpcat2tag' );
} else {
@ -349,7 +347,9 @@ if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) {
<hr class="wp-header-end">
<?php
if ( $message ) :
$class = ( isset( $_REQUEST['error'] ) ) ? 'error' : 'updated';
if ( $message ) {
wp_admin_notice(
$message,
array(
@ -358,8 +358,9 @@ if ( $message ) :
'dismissible' => true,
)
);
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'message', 'error' ), $_SERVER['REQUEST_URI'] );
endif;
}
?>
<div id="ajax-response"></div>

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.7-alpha-58917';
$wp_version = '6.7-alpha-58918';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.