sanitize_category

Sanitizes category data based on context.

Description

(object|array) sanitize_category( (object|array) $category, (string) $context = 'display' ); 

Returns (object|array)

Same type as $category with sanitized data for safe use.

Parameters (2)

0. $category (object|array)
The category.
1. $context — Optional. (string) => 'display'
Default is display..

Usage

  1. if ( !function_exists( 'sanitize_category' ) ) { 
  2. require_once ABSPATH . WPINC . '/category.php'; 
  3.  
  4. // The category. 
  5. $category = null; 
  6.  
  7. // Optional. Default is 'display'. 
  8. $context = 'display'; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = sanitize_category($category, $context); 
  12.  

Defined (1)

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

/wp-includes/category.php  
  1. function sanitize_category( $category, $context = 'display' ) { 
  2. return sanitize_term( $category, 'category', $context );