allowed_tags()WP 1.0.1

Outputs the allowed HTML tags and their attributes. Outputs as an encoded HTML string.

The function may be useful when you need to show which tags and attributes can be used in the comment field. You can also output supported tags in a plugin that cleans the input data using wp_kses() and the default filter or tag groups from the global variable $allowedtags.

Works based on the global variable $allowedtags which stores the allowed tags. See the list in the file wp-includes/kses.php

1 time — 0.00004 sec (very fast) | 50000 times — 0.69 sec (very fast) | PHP 7.0.5, WP 4.5.1

No Hooks.

Returns

String. Allowed tags in HTML format.

Usage

<?php echo allowed_tags(); ?>

Examples

0

#1 Display all allowed tags

echo allowed_tags();
// output:
// <a href="" title=""> <abbr title=""> <acronym title=""> 
// <b> <blockquote cite=""> <cite> <code> <del datetime=""> 
// <em> <i> <q cite=""> <s> <strike> <strong>

Notes

  • Global. Array. $allowedtags

Changelog

Since 1.0.1 Introduced.
Since 4.4.0 No longer used in core.

allowed_tags() code WP 6.9.1

function allowed_tags() {
	global $allowedtags;
	$allowed = '';
	foreach ( (array) $allowedtags as $tag => $attributes ) {
		$allowed .= '<' . $tag;
		if ( 0 < count( $attributes ) ) {
			foreach ( $attributes as $attribute => $limits ) {
				$allowed .= ' ' . $attribute . '=""';
			}
		}
		$allowed .= '> ';
	}
	return htmlentities( $allowed );
}