ContrastRatioValidator
in package
Validate contrast ratio. To validate at "Publish" time add it as `setting.validate_callback` to your customize setting.
Table of Contents
Properties
- $currentlyDisabled : mixed
- $message : mixed
- $minimum : mixed
- $modifier : mixed
- $panel : AbstractCustomizePanel
- See `AbstractCustomizePanel`.
- $setting1 : mixed
- $setting2 : mixed
Methods
- __construct() : mixed
- C'tor.
- getLuminosity() : mixed
- Calculate luminosity of a given `#RRGGBB` string.
- getLuminosityRatio() : mixed
- Calculate contrast ratio of two given `#RRGGBB` strings.
- validate_callback() : mixed
- Validate minimum contrast ratio.
Properties
$currentlyDisabled
private
mixed
$currentlyDisabled
= false
$message
private
mixed
$message
$minimum
private
mixed
$minimum
$modifier
private
mixed
$modifier
$panel
See `AbstractCustomizePanel`.
private
AbstractCustomizePanel
$panel
$setting1
private
mixed
$setting1
$setting2
private
mixed
$setting2
Methods
__construct()
C'tor.
public
__construct(string $message, int $minimum, string $setting1, string $setting2, AbstractCustomizePanel $panel[, callable $modifier = null ]) : mixed
Parameters
- $message : string
-
Localized message thrown to the customizer (two
%s
(ratio, minimum) are given) - $minimum : int
- $setting1 : string
-
The setting ID to check against
- $setting2 : string
-
The setting ID to check against
- $panel : AbstractCustomizePanel
- $modifier : callable = null
-
Allows you to modify the value for the settings at runtime
Tags
getLuminosity()
Calculate luminosity of a given `#RRGGBB` string.
public
static getLuminosity(string $color) : mixed
Also ported to utils/getLuminosity.tsx
.
Parameters
- $color : string
Tags
getLuminosityRatio()
Calculate contrast ratio of two given `#RRGGBB` strings.
public
static getLuminosityRatio(string $color1, string $color2) : mixed
Also ported to utils/getLuminosityRatio.tsx
.
Parameters
- $color1 : string
- $color2 : string
Tags
validate_callback()
Validate minimum contrast ratio.
public
validate_callback(WP_Error $validity) : mixed
Parameters
- $validity : WP_Error