filter_block_core_template_part_attributes( string $attribute_value, string $attribute_name, array[]|string $allowed_html ): string

In this article

Sanitizes the value of the Template Part block’s tagName attribute.

Parameters

$attribute_valuestringrequired
The attribute value to filter.
$attribute_namestringrequired
The attribute name.
$allowed_htmlarray[]|stringrequired
An array of allowed HTML elements and attributes, or a context name such as 'post'. See wp_kses_allowed_html() for the list of accepted context names.

Return

string The sanitized attribute value.

Source

function filter_block_core_template_part_attributes( $attribute_value, $attribute_name, $allowed_html ) {
	if ( empty( $attribute_value ) || 'tagName' !== $attribute_name ) {
		return $attribute_value;
	}
	if ( ! is_array( $allowed_html ) ) {
		$allowed_html = wp_kses_allowed_html( $allowed_html );
	}
	return isset( $allowed_html[ $attribute_value ] ) ? $attribute_value : '';
}

Changelog

VersionDescription
6.5.5Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.