on sanitize_color_array( $color, $color_type = 'rgb' ) {
$keys = [ 'r', 'g', 'b' ];
$mins = [ 0, 0, 0 ];
$maxs = [ 255, 255, 255 ];
if ( 'hsl' === $color_type || 'hsv' === $color_type ) {
$keys = [ 'h', 's', '' ];
$keys[2] = isset( $color['v'] ) ? 'v' : 'l';
$mins = [ 0, 0, 0 ];
$maxs = [ 360, 100, 100 ];
}
$sanitized_color = [];
$sanitized_color = [
$keys[0] => isset( $color[ $keys[0] ] ) ? absint( $color[ $keys[0] ] ) : $mins[0],
$keys[1] => isset( $color[ $keys[1] ] ) ? absint( $color[ $keys[1] ] ) : $mins[1],
$keys[2] => isset( $color[ $keys[2] ] ) ? absint( $color[ $keys[2] ] ) : $mins[2],
];
$sanitized_color[ $keys[0] ] = $sanitized_color[ $keys[0] ] < $mins[0] ? $mins[0] : $sanitized_color[ $keys[0] ];
$sanitized_color[ $keys[0] ] = $sanitized_color[ $keys[0] ] > $maxs[0] ? $maxs[0] : $sanitized_color[ $keys[0] ];
$sanitized_color[ $keys[1] ] = $sanitized_color[ $keys[1] ] < $mins[1] ? $mins[1] : $sanitized_color[ $keys[1] ];
$sanitized_color[ $keys[1] ] = $sanitized_color[ $keys[1] ] > $maxs[1] ? $maxs[1] : $sanitized_color[ $keys[1] ];
$sanitized_color[ $keys[2] ] = $sanitized_color[ $keys[2] ] < $mins[2] ? $mins[2] : $sanitized_color[ $keys[2] ];
$sanitized_color[ $keys[2] ] = $sanitized_color[ $keys[2] ] > $maxs[2] ? $maxs[2] : $sanitized_color[ $keys[2] ];
if ( isset( $color['a'] ) ) {
$sanitized_color['a'] = isset( $color['a'] ) ? filter_var( $color['a'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : 1;
$sanitized_color['a'] = $sanitized_color['a'] < 0 ? 0 : $sanitized_color['a'];
$sanitized_color['a'] = $sanitized_color['a'] > 1 ? 1 : $sanitized_color['a'];
}
return $sanitized_color;
}
/**
* Sanitize color string.
*
* @static
* @access public
* @since 1.0
*
* @param string $value The color.
* @return string
*/
public static function sanitize_color_string( $value ) {
$value = strtolower( $value );
/**
* This pattern will check and match 3/6/8-character hex, rgb, rgba, hsl, hsla, hsv, and hsva colors.
*
* RGB regex:
*
* @link https://stackoverflow.com/questions/9585973/javascript-regular-expression-for-rgb-values#answer-9586045
*
* For testing it, you can use these links:
*
* @link https://regex101.com/
* @link https://regexr.com/
* @link https://www.regextester.com/
*
* How to test it?
*
* Paste the following code to the test field (of course without the asterisks and spaces in front of them):
* rgba(255, 255, 0, 0.9)
* rgb(255, 255, 0)
* #ff0
* #ffff00
* hsl(150, 25%, 25%)
* hsla(250, 25%, 25%, 0.7)
* hsv(125, 15%, 30%)
* hsva(125, 15%, 30%, 0.5)
*
* And then paste the regex `$pattern` below (without the single quote's start and end) to the regular expression box.
* Set the flag to use "global" and "multiline".
*/
$pattern = '/^(\#[\da-f]{3}|\#[\da-f]{6}|\#[\da-f]{8}|rgba\(((\d{1,2}|1\d\d|2([0-4]\d|5[0-5]))\s*,\s*){2}((\d{1,2}|1\d\d|2([0-4]\d|5[0-5]))\s*)(,\s*(0\.\d+|1))\)|rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)|hsla\(\s*((\d{1,2}|[1-2]\d{2}|3([0-5]\d|60)))\s*,\s*((\d{1,2}|100)\s*%)\s*,\s*((\d{1,2}|100)\s*%)(,\s*(0\.\d+|1))\)|hsl\(\s*((\d{1,2}|[1-2]\d{2}|3([0-5]\d|60)))\s*,\s*((\d{1,2}|100)\s*%)\s*,\s*((\d{1,2}|100)\s*%)\)|hsva\(\s*((\d{1,2}|[1-2]\d{2}|3([0-5]\d|60)))\s*,\s*((\d{1,2}|100)\s*%)\s*,\s*((\d{1,2}|100)\s*%)(,\s*(0\.\d+|1))\)|hsv\(\s*((\d{1,2}|[1-2]\d{2}|3([0-5]\d|60)))\s*,\s*((\d{1,2}|100)\s*%)\s*,\s*((\d{1,2}|100)\s*%)\))$/';
preg_match( $pattern, $value, $matches );
// Return the 1st match found.
if ( isset( $matches[0] ) ) {
if ( is_string( $matches[0] ) ) {
return $matches[0];
}
if ( is_array( $matches[0] ) && isset( $matches[0][0] ) ) {
return $matches[0][0];
}
}
// If no match was found, return an empty string.
return '';
}
/**
* Enqueue styles & scripts on 'customize_preview_init' action.
*
* @since 4.0.0
* @access public
*/
public function enqueue_customize_preview_scripts() {
wp_enqueue_script( 'kirki-react-colorful', URL::get_from_path( dirname( dirname( __DIR__ ) ) ) . '/dist/preview.js', [ 'wp-hooks', 'customize-preview' ], $this->control_class::$control_ver, true );
}
/**
* Add output control class for react colorful control.
*
* @since 4.0.0
* @access public
*
* @param array $control_classes The existing control classes.
* @return array
*/
public function output_control_classnames( $control_classes ) {
$control_classes['kirki-react-colorful'] = '\Kirki\Field\CSS\ReactColorful';
return $control_classes;
}
}
Fatal error: Uncaught Error: Class "Kirki\Field\ReactColorful" not found in /htdocs/wp-content/plugins/kirki/kirki-packages/control-color/src/Field/Color.php:23
Stack trace:
#0 /htdocs/wp-content/plugins/all-in-one-seo-pack/vendor/composer/ClassLoader.php(576): include()
#1 /htdocs/wp-content/plugins/all-in-one-seo-pack/vendor/composer/ClassLoader.php(427): Composer\Autoload\{closure}('/htdocs/wp-cont...')
#2 [internal function]: Composer\Autoload\ClassLoader->loadClass('Kirki\\Field\\Col...')
#3 /htdocs/wp-content/plugins/kirki/kirki-packages/compatibility/src/Aliases.php(164): class_exists('Kirki\\Field\\Col...')
#4 /htdocs/wp-content/plugins/kirki/kirki-packages/compatibility/src/Aliases.php(151): Kirki\Compatibility\Aliases->add_aliases()
#5 /htdocs/wp-content/plugins/kirki/inc/bootstrap.php(15): Kirki\Compatibility\Aliases->__construct()
#6 /htdocs/wp-content/plugins/kirki/kirki.php(44): require_once('/htdocs/wp-cont...')
#7 /htdocs/wp-settings.php(526): include_once('/htdocs/wp-cont...')
#8 /htdocs/wp-config.php(85): require_once('/htdocs/wp-sett...')
#9 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...')
#10 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...')
#11 /htdocs/index.php(17): require('/htdocs/wp-blog...')
#12 {main}
thrown in /htdocs/wp-content/plugins/kirki/kirki-packages/control-color/src/Field/Color.php on line 23