sanitize_category_field() WordPress Function

The sanitize_category_field() function is used to sanitize a category field. It takes three parameters: the field to sanitize, the sanitization type (e.g. 'text' or 'url'), and an optional array of options. The function returns a sanitized string.

sanitize_category_field( string $field, mixed $value, int $cat_id, string $context ) #

Sanitizes data in single category key field.


Parameters

$field

(string)(Required)Category key to sanitize.

$value

(mixed)(Required)Category value to sanitize.

$cat_id

(int)(Required)Category ID.

$context

(string)(Required)What filter to use, 'raw', 'display', etc.


Top ↑

Return

(mixed) Same type as $value after $value has been sanitized.


Top ↑

Source

File: wp-includes/category.php

function sanitize_category_field( $field, $value, $cat_id, $context ) {
	return sanitize_term_field( $field, $value, $cat_id, '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.