Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#61896 closed defect (bug) (fixed)

Allow custom errors with correct HTML class for `edit-tag-form.php`

Reported by: xipasduarte Owned by: SergeyBiryukov
Priority: normal Milestone: 6.7
Component: Taxonomy Version:
Severity: normal Keywords: has-patch
Cc: Focuses: administration

Description

The term_updated_messages filter allows for messages to be customized (add, remove or change), but in the case of errors there is an issue if we want other messages to be considered as an error. On the edit-tag-form.php the class is related only to the value of the message code, only $msg == 5 is considered an error.

Looking at where this message is set, I could only find on reference on edit-tags.php, line 191, with the following code:

$location = add_query_arg(
        array(
                'error'   => true,
                'message' => 5,
        ),
        $referer
);

The #_REQUEST['error'] argument appears to be set, as expected, and the wrong class seems to be due to a leftover from the past. So the fix is actually pretty simple, we could just use the request argument to define the class.

Attachments (1)

61896.diff​ (529 bytes ) - added by xipasduarte 2 years ago.
Base class logic on $_REQUEST['error']

Download all attachments as: .zip

Change History (6)

@xipasduarte
2 years ago

Base class logic on $_REQUEST['error']

This ticket was mentioned in ​PR #7212 on ​WordPress/wordpress-develop by ​@xipasduarte.


2 years ago
#1

  • Keywords has-patch added

Base the edit-tag-form.php notice class on the $_REQUEST['error'] argument.

Trac ticket: core.trac.wordpress.org/ticket/61896

#2 @xipasduarte
2 years ago

  • Component General → Taxonomy

#3 @SergeyBiryukov
2 years ago

  • Owner set to SergeyBiryukov
  • Resolution → fixed
  • Status new → closed

In 58918:

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.

#4 @SergeyBiryukov
2 years ago

  • Milestone Awaiting Review → 6.7

​@SergeyBiryukov commented on ​PR #7212:


2 years ago
#5

Thanks for the PR! Merged in r58918.

Note: See TracTickets for help on using tickets.