Skip to content

Commit

Permalink
Taxonomy: Correct the check for error messages in `wp-admin/edit-tag-…
Browse files Browse the repository at this point in the history
…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.

git-svn-id: https://develop.svn.wordpress.org/trunk@58918 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
SergeyBiryukov committed Aug 20, 2024
1 parent 605c056 commit 6189d05
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/wp-admin/edit-tag-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<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>';
Expand All @@ -83,6 +83,7 @@
esc_html( $tax->labels->back_to_items )
);
}

wp_admin_notice(
$message,
array(
Expand Down
9 changes: 5 additions & 4 deletions src/wp-admin/edit-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -349,7 +347,9 @@
<hr class="wp-header-end">

<?php
if ( $message ) :
$class = ( isset( $_REQUEST['error'] ) ) ? 'error' : 'updated';

if ( $message ) {
wp_admin_notice(
$message,
array(
Expand All @@ -358,8 +358,9 @@
'dismissible' => true,
)
);

$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'message', 'error' ), $_SERVER['REQUEST_URI'] );
endif;
}
?>
<div id="ajax-response"></div>

Expand Down

0 comments on commit 6189d05

Please sign in to comment.