sanitize_category

The timeline below displays how wordpress function sanitize_category has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.5

/**
 * Sanitizes category data based on context.
 *
 * @since 2.3.0
 *
 * @param object|array $category Category data.
 * @param string       $context  Optional. Default 'display'.
 * @return object|array Same type as $category with sanitized data for safe use.
 */
function sanitize_category($category, $context = 'display')
{
    return sanitize_term($category, 'category', $context);
}

WordPress Version: 4.1

/**
 * Sanitizes category data based on context.
 *
 * @since 2.3.0
 *
 * @param object|array $category Category data
 * @param string $context Optional. Default is 'display'.
 * @return object|array Same type as $category with sanitized data for safe use.
 */
function sanitize_category($category, $context = 'display')
{
    return sanitize_term($category, 'category', $context);
}

WordPress Version: 3.7

/**
 * Sanitizes category data based on context.
 *
 * @since 2.3.0
 * @uses sanitize_term() See this function for what context are supported.
 *
 * @param object|array $category Category data
 * @param string $context Optional. Default is 'display'.
 * @return object|array Same type as $category with sanitized data for safe use.
 */
function sanitize_category($category, $context = 'display')
{
    return sanitize_term($category, 'category', $context);
}