Make WordPress Core

Opened 6 months ago

Closed 6 months ago

Last modified 6 months ago

#61896 closed defect (bug) (fixed)

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

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

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 6 months ago.
Base class logic on $_REQUEST['error']

Download all attachments as: .zip

Change History (6)

@xipasduarte
6 months ago

Base class logic on $_REQUEST['error']

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


6 months 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
6 months ago

  • Component changed from General to Taxonomy

#3 @SergeyBiryukov
6 months ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to 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
6 months ago

  • Milestone changed from Awaiting Review to 6.7

@SergeyBiryukov commented on PR #7212:


6 months ago
#5

Thanks for the PR! Merged in r58918.

Note: See TracTickets for help on using tickets.