From 6189d05ded9a2f39b05df2a9e653747704bd8c3c Mon Sep 17 00:00:00 2001
From: Sergey Biryukov
Date: Tue, 20 Aug 2024 17:48:07 +0000
Subject: [PATCH] Taxonomy: Correct the check for error messages in
`wp-admin/edit-tag-form.php`.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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.
git-svn-id: https://develop.svn.wordpress.org/trunk@58918 602fd350-edb4-49c9-b593-d223f7449a82
---
src/wp-admin/edit-tag-form.php | 3 ++-
src/wp-admin/edit-tags.php | 9 +++++----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/wp-admin/edit-tag-form.php b/src/wp-admin/edit-tag-form.php
index 0b59e36c84ccc..b6da6c6687bc8 100644
--- a/src/wp-admin/edit-tag-form.php
+++ b/src/wp-admin/edit-tag-form.php
@@ -72,7 +72,7 @@
labels->edit_item; ?>
' . $message . '
';
@@ -83,6 +83,7 @@
esc_html( $tax->labels->back_to_items )
);
}
+
wp_admin_notice(
$message,
array(
diff --git a/src/wp-admin/edit-tags.php b/src/wp-admin/edit-tags.php
index db2a13fe82f6f..a0a38d917d594 100644
--- a/src/wp-admin/edit-tags.php
+++ b/src/wp-admin/edit-tags.php
@@ -321,8 +321,6 @@
// 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 @@
true,
)
);
+
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'message', 'error' ), $_SERVER['REQUEST_URI'] );
-endif;
+}
?>