Make WordPress Core

Changeset 56603

Timestamp:
09/18/2023 12:28:24 AM (10 months ago)
Author:
joedolson
Message:

Administration: Add support for attributes in wp_admin_notice().

Allow admin notices to be created with additional attributes. Test attributes include hidden, data-*, and role="*" values, which are all in use in various admin notices across core.

This commit adds aria-live and hidden to the KSES global attributes array to support core usages.

Follow up to [56408], [56409], [56410], [56518], [56570], [56571], [56572], [56573], [56576], [56589], [56590], [56597], [56599], [56600], [56601], [56602].

Props costdev, joedolson.
See #57791.

Location:
trunk
Files:
4 edited

Legend:

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

    r56549 r56603  
    16591659 *     @type string   $id                 Optional. The value of the admin notice's ID attribute. Default empty string.
    16601660 *     @type string[] $additional_classes Optional. A string array of class names. Default empty array.
     1661
    16611662 *     @type bool     $paragraph_wrap     Optional. Whether to wrap the message in paragraph tags. Default true.
    16621663 * }
     
    16691670        'id'                 => '',
    16701671        'additional_classes' => array(),
     1672
    16711673        'paragraph_wrap'     => true,
    16721674    );
     
    16821684     * @param string $message The message for the admin notice.
    16831685     */
    1684     $args    = apply_filters( 'wp_admin_notice_args', $args, $message );
    1685     $id      = '';
    1686     $classes = 'notice';
     1686    $args       = apply_filters( 'wp_admin_notice_args', $args, $message );
     1687    $id         = '';
     1688    $classes    = 'notice';
     1689    $attributes = '';
    16871690
    16881691    if ( is_string( $args['id'] ) ) {
     
    17221725    }
    17231726
     1727
     1728
     1729
     1730
     1731
     1732
     1733
     1734
     1735
     1736
     1737
     1738
     1739
    17241740    if ( false !== $args['paragraph_wrap'] ) {
    17251741        $message = "<p>$message</p>";
    17261742    }
    17271743
    1728     $markup = sprintf( '<div %1$sclass="%2$s">%3$s</div>', $id, $classes, $message );
     1744    $markup = sprintf( '<div %1$sclass="%2$s"es, $message );
    17291745
    17301746    /**
  • trunk/src/wp-includes/kses.php

    r56559 r56603  
    26462646        'aria-details'     => true,
    26472647        'aria-expanded'    => true,
     2648
    26482649        'aria-label'       => true,
    26492650        'aria-labelledby'  => true,
    2650         'aria-hidden'      => true,
     2651        'aria-      => true,
    26512652        'class'            => true,
    26522653        'data-*'           => true,
    26532654        'dir'              => true,
     2655
    26542656        'id'               => true,
    26552657        'lang'             => true,
  • trunk/tests/phpunit/tests/admin/wpAdminNotice.php

    r56408 r56603  
    212212                ),
    213213                'expected' => '<div class="notice"><p>A notice with additional classes that are not an array.</p></div>',
     214
     215
     216
     217
     218
     219
     220
     221
     222
     223
     224
     225
     226
     227
     228
     229
     230
     231
     232
     233
     234
     235
     236
     237
     238
     239
     240
     241
     242
     243
     244
     245
     246
     247
     248
     249
     250
     251
     252
     253
     254
     255
     256
     257
     258
     259
     260
     261
     262
     263
     264
     265
     266
     267
     268
     269
     270
     271
     272
     273
     274
     275
     276
     277
     278
    214279            ),
    215280            'paragraph wrapping as a falsy value rather than (bool) false' => array(
  • trunk/tests/phpunit/tests/admin/wpGetAdminNotice.php

    r56408 r56603  
    209209                'expected' => '<div class="notice"><p>A notice with additional classes that are not an array.</p></div>',
    210210            ),
     211
     212
     213
     214
     215
     216
     217
     218
     219
     220
     221
     222
     223
     224
     225
     226
     227
     228
     229
     230
     231
     232
     233
     234
     235
     236
     237
     238
     239
     240
     241
     242
     243
     244
     245
     246
     247
     248
     249
     250
     251
     252
     253
     254
     255
     256
     257
     258
     259
     260
     261
     262
     263
     264
     265
     266
     267
     268
    211269            'paragraph wrapping as a falsy value rather than (bool) false' => array(
    212270                'message'  => 'A notice with paragraph wrapping as a falsy value rather than (bool) false.',
Note: See TracChangeset for help on using the changeset viewer.