if ( preg_match( '%\s*/\s*$%',
$attr ) ) { $xhtml_slash = ' /';
} // Are any attributes allowed at all for this element?
$element_low =
strtolower( $element );
if ( empty( $allowed_html[ $element_low ] ) || true ===
$allowed_html[ $element_low ] ) { return "<
$element$xhtml_slash>";
} // Split it.
$attrarr =
wp_kses_hair( $attr,
$allowed_protocols );
// Check if there are attributes that are required.
$required_attrs =
array_filter( $allowed_html[ $element_low ],
static function( $required_attr_limits ) { return isset( $required_attr_limits['required'
] ) && true ===
$required_attr_limits['required'
];
} );
/*
* If a required attribute check fails, we can return nothing for a self-closing tag,
* but for a non-self-closing tag the best option is to return the element with attributes,
* as KSES doesn't handle matching the relevant closing tag.
*/