WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/wp strip all tags

Description

Properly strip all HTML tags including script and style.

Usage

<?php wp_strip_all_tags$string$remove_breaks ); ?>

Parameters

$string
(string) (required) String containing HTML tags
Default: None
$remove_breaks
(boolean) (optional) Whether to remove left over line breaks and white space characters
Default: false

Returns Values

(string) 
The processed string.

Examples

<?php
$html 
'<strong>I am not strong</strong>';
var_dump$html );
//output '<strong>I am not strong</strong>'

var_dumpwp_strip_all_tags$html ) );
//output 'I am not strong'
?>

Notes

wp_strip_all_tags() is added to the following filters by default (see wp-includes/default-filters.php):

  • pre_comment_author_url
  • pre_user_url
  • pre_link_url
  • pre_link_image
  • pre_link_rss
  • pre_post_guid

It is also applied to these filters by default when on the administration side of the site:

  • user_url
  • link_url
  • link_image
  • link_rss
  • comment_url
  • post_guid

Change Log

Since: 2.9.0

Source File

wp_strip_all_tags() is located in wp-includes/formatting.php

Related

This page is marked as incomplete. You can help Codex by expanding it.