function sanitize_key( $key ) {}

Sanitize a string key.
Keys are used as internal identifiers. Lowercase alphanumeric characters, dashes and underscores are allowed.


  • string $key: String key

Return values

returns:Sanitized key

Defined filters

  • sanitize_key
    apply_filters( 'sanitize_key', $key, $raw_key )

Source code

function sanitize_key( $key ) {

	$raw_key = $key;

	$key = strtolower( $key );

	$key = preg_replace( '/[^a-z0-9_\-]/', '', $key );

	return apply_filters( 'sanitize_key', $key, $raw_key );



No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: