Skip to content

Instantly share code, notes, and snippets.

@rfmeier
Last active October 24, 2021 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rfmeier/c048ee02a833593fd2dd to your computer and use it in GitHub Desktop.
Save rfmeier/c048ee02a833593fd2dd to your computer and use it in GitHub Desktop.
Sanitize callback for WordPress register_meta() function.
<?php //* do not include php tag
/**
* Callback for WordPress register_meta() sanitize parameter.
*
* Sanitize the 'sample_count' meta value before saved to the database.
*
* @see https://codex.wordpress.org/Function_Reference/register_meta
*
* @uses absint()
* @see https://codex.wordpress.org/Function_Reference/absint
*
* @param mixed $meta_value The meta value.
* @param string $meta_key The meta key.
* @param string $meta_type The meta type.
* @return mixed The meta value.
*/
function sanitize_sample_count_meta( $meta_value, $meta_key, $meta_type ) {
return absint( $meta_value );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment