WordPress.org

Ready to get started?Download WordPress

Codex

Function Reference/wp strip all tags

Contents

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 be strong</strong>';
var_dump($html);
//ouput '<strong>I am not be strong</strong>'

var_dump(wp_strip_all_tags($html);
//ouput 'I am not be 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.