allowed_tags() WordPress Function

The allowed_tags() function is used to specify which HTML tags are allowed in a string. This function can be used to filter user-generated content, such as comments or forum posts. It is also possible to use this function to allow only certain HTML tags in a string, while disallowing others.

allowed_tags() #

Display all of the allowed tags in HTML format with attributes.


Description

This is useful for displaying in the comment area, which elements and attributes are supported. As well as any plugins which want to display it.


Top ↑

Return

(string) HTML allowed tags entity encoded.


Top ↑

Source

File: wp-includes/general-template.php

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

Top ↑

Changelog

Changelog
VersionDescription
1.0.1Introduced.

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
Show More