\DevOwl\CustomizeContrastRatioValidator

Validate contrast ratio. To validate at "Publish" time add it as `setting.validate_callback` to your customize setting.

Summary

Methods
Properties
Constants
__construct()
validate_callback()
getLuminosity()
getLuminosityRatio()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$message
$minimum
$setting1
$setting2
$panel
$modifier
$currentlyDisabled
N/A

Properties

$message

$message :

Type

$minimum

$minimum :

Type

$setting1

$setting1 :

Type

$setting2

$setting2 :

Type

$modifier

$modifier :

Type

$currentlyDisabled

$currentlyDisabled :

Type

Methods

__construct()

__construct(string  $message,integer  $minimum,string  $setting1,string  $setting2,\DevOwl\Customize\AbstractCustomizePanel  $panel,callable  $modifier = null)

C'tor.

Parameters

string $message

Localized message thrown to the customizer (two %s (ratio, minimum) are given)

integer $minimum
string $setting1

The setting ID to check against

string $setting2

The setting ID to check against

\DevOwl\Customize\AbstractCustomizePanel $panel
callable $modifier

Allows you to modify the value for the settings at runtime

validate_callback()

validate_callback(\WP_Error  $validity): mixed

Validate minimum contrast ratio.

Parameters

\WP_Error $validity

Returns

mixed

getLuminosity()

getLuminosity(string  $color)

Calculate luminosity of a given `#RRGGBB` string.

Also ported to utils/getLuminosity.tsx.

Parameters

string $color

getLuminosityRatio()

getLuminosityRatio(string  $color1,string  $color2)

Calculate contrast ratio of two given `#RRGGBB` strings.

Also ported to utils/getLuminosityRatio.tsx.

Parameters

string $color1
string $color2