rest_parse_hex_color

函数
rest_parse_hex_color ( $color )
参数
  • (string) $color 3 or 6 digit hex color (with #).
    Required:
返回值
  • (string|false)
定义位置
相关方法
rest_parse_datesanitize_hex_colorrest_parse_embed_paramwp_parse_auth_cookiemaybe_hash_hex_color
引入
5.4.0
弃用
-

rest_parse_hex_color: 这是一个WordPress的函数,解析十六进制的颜色代码并返回一个RGB颜色值: 该函数接收一个十六进制的颜色代码并返回相应的RGB颜色值: 这个函数用来解析传递给WordPress REST API的颜色代码。

解析一个3位或6位的十六进制颜色(带#)。

function rest_parse_hex_color( $color ) {
	$regex = '|^#([A-Fa-f0-9]{3}){1,2}$|';
	if ( ! preg_match( $regex, $color, $matches ) ) {
		return false;
	}

	return $color;
}

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2025-12-14 11:36:30

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: