Skip to content

Instantly share code, notes, and snippets.

@Lovor01
Forked from rfmeier/functions.php
Last active February 15, 2022 11:30
Show Gist options
  • Save Lovor01/25cf052eb0e60fa48b5be7dc9c260b90 to your computer and use it in GitHub Desktop.
Save Lovor01/25cf052eb0e60fa48b5be7dc9c260b90 to your computer and use it in GitHub Desktop.
Sanitize callback for WordPress register_meta() function.

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