wp_kses_uri_attributes

函式
wp_kses_uri_attributes ( No parameters )
返回值
  • (string[]) HTML attribute names whose value contains a URL.
定義位置
相關方法
wp_pre_kses_block_attributeswp_sanitize_script_attributeswp_kses_attrwp_kses_js_entitieswp_kses_one_attr
引入
5.0.1
棄用
-

wp_kses_uri_attributes: 該函式用於對包含URL的HTML屬性列表進行淨化。

返回一個HTML屬性名稱的陣列,其值包含一個URL。

根據HTML規範,該函式返回一個所有必須包含URL的HTML屬性的列表。

這個列表包括KSES允許和不允許的URI屬性。

function wp_kses_uri_attributes() {
	$uri_attributes = array(
		'action',
		'archive',
		'background',
		'cite',
		'classid',
		'codebase',
		'data',
		'formaction',
		'href',
		'icon',
		'longdesc',
		'manifest',
		'poster',
		'profile',
		'src',
		'usemap',
		'xmlns',
	);

	/**
	 * Filters the list of attributes that are required to contain a URL.
	 *
	 * Use this filter to add any `data-` attributes that are required to be
	 * validated as a URL.
	 *
	 * @since 5.0.1
	 *
	 * @param string[] $uri_attributes HTML attribute names whose value contains a URL.
	 */
	$uri_attributes = apply_filters( 'wp_kses_uri_attributes', $uri_attributes );

	return $uri_attributes;
}

常見問題

FAQs
檢視更多 >