wpseek.com
Un motore di ricerca WordPress per sviluppatori e autori di temi



sanitize_hex_color_no_hash › WordPress Function

Da3.4.0
Deprecaton/a
sanitize_hex_color_no_hash ( $color )
Parametri:
  • (string) $color
    Richiesto:
Ritorna:
  • (string|null)
Definito a:
Codex:

Sanitizes a hex color without a hash. Use sanitize_hex_color() when possible.

Saving hex colors without a hash puts the burden of adding the hash on the UI, which makes it difficult to use or upgrade to other color types such as rgba, hsl, rgb, and HTML color names. Returns either '', a 3 or 6 digit hex color (without a #), or null.


Sorgenti

function sanitize_hex_color_no_hash( $color ) {
	$color = ltrim( $color, '#' );

	if ( '' === $color ) {
		return '';
	}

	return sanitize_hex_color( '#' . $color ) ? $color : null;
}