Summery Summery
Builds an attribute list from string containing attributes.
Syntax Syntax
Description Description
Does not modify input. May return "evil" output. In case of unexpected input, returns false instead of stripping things.
Based on wp_kses_hair()
but does not return a multi-dimensional array.
Parameters Parameters
- $attr
-
(Required) Attribute list from HTML element to closing HTML element tag.
Return Return
(array|bool) List of attributes found in $attr. Returns false on failure.
Source Source
File: wp-includes/kses.php
if ( 1 === preg_match( '%\s*/\s*$%', $attr, $matches ) ) { $xhtml_slash = $matches[0]; $attr = substr( $attr, 0, -strlen( $xhtml_slash ) ); } else { $xhtml_slash = ''; } // Split it. $attrarr = wp_kses_hair_parse( $attr ); if ( false === $attrarr ) { return false; } // Make sure all input is returned by adding front and back matter. array_unshift( $attrarr, $begin . $slash . $elname ); array_push( $attrarr, $xhtml_slash . $end ); return $attrarr; } /** * Builds an attribute list from string containing attributes. * * Does not modify input. May return "evil" output. * In case of unexpected input, returns false instead of stripping things. * * Based on `wp_kses_hair()` but does not return a multi-dimensional array. * * @since 4.2.3 * * @param string $attr Attribute list from HTML element to closing HTML element tag. * @return array|bool List of attributes found in $attr. Returns false on failure. */ function wp_kses_hair_parse( $attr ) { if ( '' === $attr ) { return array(); } // phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- don't remove regex indentation $regex = '(?:'
Advertisement
Changelog Changelog
Version | Description |
---|---|
4.2.3 | Introduced. |