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

View File

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

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @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. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.