Uma área de pesquisa sobre o WordPress para devs e autores do tema



wp_strip_all_tags ›

Desde2.9.0
Obsoleton/a
wp_strip_all_tags ( $string, $remove_breaks = false )
Parâmetros: (2)
  • (string) $string String containing HTML tags
    Required: Yes
  • (bool) $remove_breaks Optional. Whether to remove left over line breaks and white space chars
    Required: No
    Padrão: false
Retorna:
  • (string) The processed string.
Definido em:
Codex:

Properly strip all HTML tags including script and style

This differs from strip_tags() because it removes the contents of the <script> and <style> tags. E.g. strip_tags( '<script>something</script>' ) will return 'something'. wp_strip_all_tags will return ''



Fonte

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