sanitize_category_field

Sanitizes data in single category key field.

Description

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

Parameters (4)

0. $field (string)
Category key to sanitize
1. $value (mixed)
Category value to sanitize
2. $cat_id (int)
The cat id.
3. $context (string)
What filter to use, raw,, display, etc.

Usage

  1. if ( !function_exists( 'sanitize_category_field' ) ) { 
  2. require_once ABSPATH . WPINC . '/category.php'; 
  3.  
  4. // Category key to sanitize 
  5. $field = ''; 
  6.  
  7. // Category value to sanitize 
  8. $value = null; 
  9.  
  10. // The cat id. 
  11. $cat_id = -1; 
  12.  
  13. // What filter to use, 'raw', 'display', etc. 
  14. $context = ''; 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = sanitize_category_field($field, $value, $cat_id, $context); 
  18.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/category.php  
  1. function sanitize_category_field( $field, $value, $cat_id, $context ) { 
  2. return sanitize_term_field( $field, $value, $cat_id, 'category', $context );