sanitize_hex_color_no_hash() - WordPress 函数参考中文文档

返回介绍

sanitize_hex_color_no_hash()

发布于 2017-09-11 字数1584 浏览 934 评论 0

sanitize_hex_color_no_hash( string $color )

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


参数

$color

(string)
(Required)


返回值

(string|null)


源代码

File: wp-includes/formatting.php

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

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

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

更新日志

Version 描述
3.4.0 Introduced.

相关函数

Uses

  • wp-includes/formatting.php:
    sanitize_hex_color()

Used By

  • wp-includes/class-wp-customize-manager.php:
    WP_Customize_Manager::_sanitize_header_textcolor()
  • wp-includes/formatting.php:
    maybe_hash_hex_color()

User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!