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'


Top ↑

Return

(object|array) Same type as $category with sanitized data for safe use.


Top ↑

Source

File: wp-includes/category.php

function sanitize_category( $category, $context = 'display' ) {
	return sanitize_term( $category, 'category', $context );
}


Top ↑

Changelog

Changelog
VersionDescription
2.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.