wp_kses_allowed_html( string|array $context = '' )
Return a list of allowed tags and attributes for a given context.
Parameters
- $context
-
(Optional) The context for which to retrieve tags. Allowed values are post, strip, data, entities, or the name of a field filter such as pre_user_description.
Default value: ''
Return
(array) List of allowed tags and their allowed attributes.
Source
File: wp-includes/kses.php
function wp_kses_allowed_html( $context = '' ) {
global $allowedposttags, $allowedtags, $allowedentitynames;
if ( is_array( $context ) ) {
/**
* Filters HTML elements allowed for a given context.
*
* @since WP-3.5.0
*
* @param array $context Context to judge allowed tags by.
* @param string $context_type Context type (explicit).
*/
return apply_filters( 'wp_kses_allowed_html', $context, 'explicit' );
}
switch ( $context ) {
case 'post':
/** This filter is documented in wp-includes/kses.php */
$tags = apply_filters( 'wp_kses_allowed_html', $allowedposttags, $context );
// WP-4.9.9 removed the `<form>` tag, allow it if a filter is
// allowing its sub-elements `<input>` or `<select>`.
if ( ! CUSTOM_TAGS && ! isset( $tags['form'] ) && ( isset( $tags['input'] ) || isset( $tags['select'] ) ) ) {
$tags = $allowedposttags;
$tags['form'] = array(
'action' => true,
'accept' => true,
'accept-charset' => true,
'enctype' => true,
'method' => true,
'name' => true,
'target' => true,
);
/** This filter is documented in wp-includes/kses.php */
$tags = apply_filters( 'wp_kses_allowed_html', $tags, $context );
}
return $tags;
case 'user_description':
case 'pre_user_description':
$tags = $allowedtags;
$tags['a']['rel'] = true;
/** This filter is documented in wp-includes/kses.php */
return apply_filters( 'wp_kses_allowed_html', $tags, $context );
case 'strip':
/** This filter is documented in wp-includes/kses.php */
return apply_filters( 'wp_kses_allowed_html', array(), $context );
case 'entities':
/** This filter is documented in wp-includes/kses.php */
return apply_filters( 'wp_kses_allowed_html', $allowedentitynames, $context);
case 'data':
default:
/** This filter is documented in wp-includes/kses.php */
return apply_filters( 'wp_kses_allowed_html', $allowedtags, $context );
}
}
Changelog
Version | Description |
---|---|
WP-4.9.9 | form removed as allowable HTML tag. |
WP-3.5.0 | Introduced. |