sanitize_key
Filters a sanitized key string.
Description
Parameters (2)
- 0. $key (string)
- Sanitized key.
- 1. $raw_key (string)
- The key prior to sanitization.
Usage
- To run the hook, copy the example below.
- $key = apply_filters( 'sanitize_key', $key, $raw_key );
- if ( !empty( $key ) ) {
- // everything has led up to this point...
- }
- The following example is for adding a hook callback.
- // define the sanitize_key callback
- function filter_sanitize_key( $key, $raw_key ) {
- // make filter magic happen here...
- return $key;
- };
- // add the filter
- add_filter( 'sanitize_key', 'filter_sanitize_key', 10, 2 );
- To remove a hook callback, use the example below.
- // remove the filter
- remove_filter( 'sanitize_key', 'filter_sanitize_key', 10, 2 );
Defined (1)
The filter is defined in the following location(s).
- /wp-includes/formatting.php
- return apply_filters( 'sanitize_key', $key, $raw_key );