sanitize_meta

Sanitize meta value.

Description

sanitize_meta( (string) $meta_key, (mixed) $meta_value, (string) $object_type ); 

Parameters (3)

0. $meta_key (string)
The meta key.
1. $meta_value (mixed)
Meta value to sanitize.
2. $object_type (string)
Type of object the meta is registered to.

Usage

  1. if ( !function_exists( 'sanitize_meta' ) ) { 
  2. require_once ABSPATH . WPINC . '/meta.php'; 
  3.  
  4. // The meta key. 
  5. $meta_key = ''; 
  6.  
  7. // Meta value to sanitize. 
  8. $meta_value = null; 
  9.  
  10. // Type of object the meta is registered to. 
  11. $object_type = ''; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = sanitize_meta($meta_key, $meta_value, $object_type); 
  15.  

Defined (1)

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

/wp-includes/meta.php  
  1. function sanitize_meta( $meta_key, $meta_value, $object_type ) { 
  2. /** 
  3. * Filters the sanitization of a specific meta key of a specific meta type. 
  4. * The dynamic portions of the hook name, `$meta_type`, and `$meta_key`,  
  5. * refer to the metadata object type (comment, post, or user) and the meta 
  6. * key value, respectively. 
  7. * @since 3.3.0 
  8. * @param mixed $meta_value Meta value to sanitize. 
  9. * @param string $meta_key Meta key. 
  10. * @param string $object_type Object type. 
  11. */ 
  12. return apply_filters( "sanitize_{$object_type}_meta_{$meta_key}", $meta_value, $meta_key, $object_type );