Make WordPress Core


Ignore:
Timestamp:
10/10/2026 02:18:37 PM (3 days ago)
Author:
joedolson
Message:

Admin: Admin notice accessibility improvements.

Capture all admin notices with message content generated via wp_get_admin_notices(). Wrap all captured notices inside an aside so notices are identified within a navigable landmark. Add information about the number of notices produced on a page in the title element of the page.

Ensures users have awareness on page entry whether there are notices present, how many there are, and provides screen readers with a mechanism to locate them as a group. Inline notices are counted in the total, but not contained within the landmark.

Developed in ​https://github.com/WordPress/wordpress-develop/pull/13671.

Props afercia, psykro, ryokuhi, raaaahman, alexstine, sergeybiryukov, oglekler, marybaum, swissspidy, davidbaumwald, sanket.parmar, sabernhardt, peterwilsoncc, williampatton, im3dabasia1, audrasjb, khokansardar, ugyensupport, joedolson.
Fixes #50486.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r64253 r64282  
    93439343        $args = apply_filters( 'wp_admin_notice_args', $args, $message );
    93449344
     9345        // Unique ID is intended for internal use, and is not a filterable argument.
     9346        $unique_id         = wp_unique_prefixed_id( 'wp-admin-notice-' );
     9347        $args['notice_id'] = $unique_id;
     9348
    93459349        $wrap_with_p  = false !== $args['paragraph_wrap'];
    93469350        $wrap_opener  = $wrap_with_p ? '<p>' : '';
    … …  
    93529356                $trimmed_id = trim( $args['id'] );
    93539357
     9358                $html_builder->set_attribute( 'data-id', $unique_id );
    93549359                if ( '' !== $trimmed_id ) {
    93559360                        $html_builder->set_attribute( 'id', $trimmed_id );
    9356                 }
     9361                } else {
     9362                        $html_builder->set_attribute( 'id', $unique_id );
     9363                }
     9364        } else {
     9365                $html_builder->set_attribute( 'data-id', $unique_id );
     9366                $html_builder->set_attribute( 'id', $unique_id );
    93579367        }
    93589368
Note: See TracChangeset for help on using the changeset viewer.