WP_Customize_Widgets::filter_wp_kses_allowed_data_attributes( array $allowed_html ): array

In this article

Ensures the HTML data-* attributes for selective refresh are allowed by kses.

Description

This is needed in case the $before_widget is run through wp_kses() when printed.

Parameters

$allowed_htmlarrayrequired
Allowed HTML.

Return

array (Maybe) modified allowed HTML.

Source

public function filter_wp_kses_allowed_data_attributes( $allowed_html ) {
	foreach ( array_keys( $this->before_widget_tags_seen ) as $tag_name ) {
		if ( ! isset( $allowed_html[ $tag_name ] ) ) {
			$allowed_html[ $tag_name ] = array();
		}
		$allowed_html[ $tag_name ] = array_merge(
			$allowed_html[ $tag_name ],
			array_fill_keys(
				array(
					'data-customize-partial-id',
					'data-customize-partial-type',
					'data-customize-partial-placement-context',
					'data-customize-partial-widget-id',
					'data-customize-partial-options',
				),
				true
			)
		);
	}
	return $allowed_html;
}

Changelog

VersionDescription
4.5.0Introduced.

User Contributed Notes

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