WP_Customize_Widgets::filter_wp_kses_allowed_data_attributes() WordPress Method

The WP_Customize_Widgets::filter_wp_kses_allowed_data_attributes() method is used to filter the allowed data attributes for widgets. This is useful for making sure that only the allowed data attributes are saved for widgets.

WP_Customize_Widgets::filter_wp_kses_allowed_data_attributes( array $allowed_html ) #

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.


Top ↑

Parameters

$allowed_html

(array)(Required)Allowed HTML.


Top ↑

Return

(array) (Maybe) modified allowed HTML.


Top ↑

Source

File: wp-includes/class-wp-customize-widgets.php

	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;
	}

Top ↑

Changelog

Changelog
VersionDescription
4.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More