sanitize_category() WordPress Function
The sanitize_category() function is used to sanitize a category name. This function strips away any invalid characters from the category name, so that it can be safely used in the database.
sanitize_category( object|array $category, string $context = 'display' ) #
Sanitizes category data based on context.
Parameters
- $category
(object|array)(Required)Category data.
- $context
(string)(Optional)
Default value: 'display'
Return
(object|array) Same type as $category with sanitized data for safe use.
Source
File: wp-includes/category.php
function sanitize_category( $category, $context = 'display' ) { return sanitize_term( $category, 'category', $context ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
2.3.0 | Introduced. |