wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



sanitize_key › WordPress Function

Od3.0.0
Przestarzałyn/a
sanitize_key ( $key )
Parametry:
  • (string) $key String key.
    Wymagane: Tak
Powrót:
  • (string) Sanitized key.
Zdefiniowane na:
Codex:

Sanitizes a string key.

Keys are used as internal identifiers. Lowercase alphanumeric characters, dashes, and underscores are allowed.


Źródło

function sanitize_key( $key ) {
	$sanitized_key = '';

	if ( is_scalar( $key ) ) {
		$sanitized_key = strtolower( $key );
		$sanitized_key = preg_replace( '/[^a-z0-9_\-]/', '', $sanitized_key );
	}

	/**
	 * Filters a sanitized key string.
	 *
	 * @since 3.0.0
	 *
	 * @param string $sanitized_key Sanitized key.
	 * @param string $key           The key prior to sanitization.
	 */
	return apply_filters( 'sanitize_key', $sanitized_key, $key );
}