Make WordPress Core

Changeset 52234


Ignore:
Timestamp:
11/23/2021 06:37:03 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Docs: Add a @since note and description to wp_kses_attr() for new attribute-related KSES options:

  • Support for an array of allowed values for attributes.
  • Support for required attributes.

Follow-up to [51963].

See #54261.

File:
1 edited

Legend:

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

    r52229 r52234  
    11431143 * in the returned code as well.
    11441144 *
     1145 * An array of allowed values can be defined for attributes. If the attribute value
     1146 * doesn't fall into the list, the attribute will be removed from the tag.
     1147 *
     1148 * Attributes can be marked as required. If a required attribute is not present,
     1149 * KSES will remove all attributes from the tag. As KSES doesn't match opening and
     1150 * closing tags, it's not possible to safely remove the tag itself, the safest
     1151 * fallback is to strip all attributes from the tag, instead.
     1152 *
    11451153 * @since 1.0.0
     1154 * @since 5.9.0 Added support for an array of allowed values for attributes.
     1155 *              Added support for required attributes.
    11461156 *
    11471157 * @param string         $element           HTML element/tag.
     
    11811191    );
    11821192
    1183     // If a required attribute check fails, we can return nothing for a self-closing tag,
    1184     // but for a non-self-closing tag the best option is to return the element with attributes,
    1185     // as KSES doesn't handle matching the relevant closing tag.
     1193    /*
     1194     * If a required attribute check fails, we can return nothing for a self-closing tag,
     1195     * but for a non-self-closing tag the best option is to return the element with attributes,
     1196     * as KSES doesn't handle matching the relevant closing tag.
     1197     */
    11861198    $stripped_tag = '';
    11871199    if ( empty( $xhtml_slash ) ) {
     
    11891201    }
    11901202
    1191     // Go through $attrarr, and save the allowed attributes for this element
    1192     // in $attr2.
     1203    // Go through $attrarr, and save the allowed attributes for this element in $attr2.
    11931204    $attr2 = '';
    11941205    foreach ( $attrarr as $arreach ) {
Note: See TracChangeset for help on using the changeset viewer.