Sprache wechseln
wpseek auf Twitter


Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren




sanitize_hex_color [ ]

sanitize_hex_color ( $color )
Parameter:
  • (string) $color
Gibt zurück:
  • (string|null)
Definiert in:
Codex



Validates a hex color.

Returns either '', a 3 or 6 digit hex color (with #), or null. For validating values without a #, see sanitize_hex_color_no_hash().

Quellcode

function sanitize_hex_color( $color ) {
	if ( '' === $color )
		return '';

	// 3 or 6 hex digits, or the empty string.
	if ( preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) )
		return $color;

	return null;
}

Beispiele [ wp-snippets.com ]

Top Google Suchergebnisse

Mehr ...

Nutzerduskussionen [ wordpress.org ]

0 Nutzerkommentare

Noch keine. Sei der Erste!

Neu hinzufügen ...