function wp_strip_all_tags($string, $remove_breaks = false) {}

Properly strip all HTML tags including script and style


  • string $string: String containing HTML tags
  • bool $remove_breaks: optional Whether to remove left over line breaks and white space chars

Return values

returns:The processed string.

Source code

function wp_strip_all_tags($string, $remove_breaks = false) {

	$string = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $string );

	$string = strip_tags($string);

	if ( $remove_breaks )

		$string = preg_replace('/[\r\n\t ]+/', ' ', $string);

	return trim($string);



No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: