根据上下文清理类别数据。
原型
sanitize_category( object|array $category, string $context = 'display' )
参数
$category
(object|array)
(Required)
类别数据
$context
(string)
(Optional)
默认为“显示”。
返回值
(object|array)
与$ category相同的类型,具有安全使用的清理数据。
源文件
路径:wp-includes/category.php
<?php
...
function sanitize_category( $category, $context = 'display' ) {
return sanitize_term( $category, 'category', $context );
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/sanitize_category/