dozent_sanitize_html( null $text = null )

Sanitize HTML string from user input


Parameters

$text

(null) (Optional)

Default value: null


Return

(mixed|string|void)


Source

File: includes/core-functions.php

	function dozent_sanitize_html( $text = null ) {
		if ( ! $text ) {
			return '';
		}

		$allowed_tags = [
			'html',
			'body',
			'em',
			'h1',
			'h2',
			'h3',
			'h4',
			'h5',
			'h6',
			'p',
			's',
			'br',
			'ul',
			'li',
			'hr',
			'a',
			'abbr',
			'address',
			'b',
			'blockquote',
			'center',
			'cite',
			'code',
			'del',
			'i',
			'ins',
			'strong',
			'sub',
			'sup',
			'time',
			'u',
			'img',
			'iframe',
			'link',
			'nav',
			'ol',
			'table',
			'caption',
			'th',
			'tr',
			'td',
			'thead',
			'tbody',
			'tfoot',
			'col',
			'colgroup',
			'div',
			'span'
		];

		/**
		 * Filter default allowed tags for the function dozent_sanitize_html_allowed_tags();
		 *
		 * @since DozentLMS 1.0.0
		 *
		 * @see dozent_sanitize_html_allowed_tags
		 *
		 * @param  array  $allowed_tags  Default Allowed Tags
		 */

		$allowed_tags        = apply_filters( 'dozent_sanitize_html_allowed_tags', $allowed_tags );
		$allowed_tags_string = "<" . implode( "><", $allowed_tags ) . ">";

		$text = strip_tags( $text, $allowed_tags_string );
		$text = str_replace( 'javascript:', '', $text );

		return apply_filters( 'dozent_sanitize_html', $text );
	}


Changelog

Changelog
Version Description
DozentLMS 1.0.0 Introduced.