Applies filters that can be hooked to perform specific sanitization procedures for the particular metadata type and key. Does not sanitize anything on its own. Custom filters must be hooked in to do the work. The filter hook tag has the form "sanitize_{$meta_type}_meta_{$meta_key}".
<?php $clean_value = sanitize_meta( $meta_key, $meta_value, $meta_type ); ?>
(mixed) Sanitized value as processed by any hooked filter functions.
$clean_value = sanitize_meta( 'birth-year', $user_input, 'user' ); function sanitize_birth_year_meta( $year ) { $now = date( 'Y' ); $then = $now - 115; // No users older than 115. if ( $then > $year || $year > $now ) { wp_die( 'Invalid entry, go back and try again.' ); } return $year; } add_filter( 'sanitize_user_meta_birth-year', 'sanitize_birth_year_meta' );
This function is called by add_meta_data() and update_metadata() WordPress functions.
Since: 3.1.3
sanitize_meta() is located in wp-includes/meta.php
.
sanitize_meta()
is in a class of functions that help you sanitize potentially unsafe data which allow you to pass an arbitrary variable and receive the clean version based on data type. Others include: