maybe_hash_hex_color

函式
maybe_hash_hex_color ( $color )
引數
  • (string) $color
    Required:
返回值
  • (string)
定義位置
相關方法
_maybe_update_coremaybe_add_columnrest_parse_hex_colorsanitize_hex_colormaybe_add_existing_user_to_blog
引入
3.4.0
棄用
-

maybe_hash_hex_color: 這是WordPress中的一個函式,允許你對一個十六進位制的顏色程式碼進行雜湊: 這個函式檢查顏色程式碼是否是有效的十六進位制顏色程式碼,如果是,它就對顏色程式碼進行雜湊。

確保任何十六進位制的顏色都是正確的雜湊值。

否則,返回未處理的值。

只有在使用sanitize_hex_color_no_hash()時才需要這個方法。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function maybe_hash_hex_color( $color ) {
$unhashed = sanitize_hex_color_no_hash( $color );
if ( $unhashed ) {
return '#' . $unhashed;
}
return $color;
}
function maybe_hash_hex_color( $color ) { $unhashed = sanitize_hex_color_no_hash( $color ); if ( $unhashed ) { return '#' . $unhashed; } return $color; }
function maybe_hash_hex_color( $color ) {
	$unhashed = sanitize_hex_color_no_hash( $color );
	if ( $unhashed ) {
		return '#' . $unhashed;
	}

	return $color;
}

常見問題

FAQs
檢視更多 >