WordPress.org

Codex

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

Function Reference/tag escape

Description

Removes all characters other than a-zA-Z0-9_:, the set of valid HTML tag characters. Transforms letters to lowercase.

Usage

<?php tag_escape$tag ); ?>

Parameters

$tag
(string) (required) String cleaned and escaped for output as an HTML tag.
Default: None

Return Values

(string) 

Examples

$unsafeTag = "#1 Best! Movies! EVER!!!$@#%#$";

$safeTag = tag_escape($unsafeTag);

echo '$safeTag = ' . $safeTag;

// returns: 
// $safeTag = 1bestmoviesever

Notes

Change Log

Source File

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

Related

See also index of Function Reference and index of Template Tags.