Only run in input and is defined data alpha in true
Download and copy script inside folder dist in you theme options or plugin. This would be an example to use it:
wp_enqueue_style( 'wp-color-picker' );
wp_register_script( 'wp-color-picker-alpha', $url_to_script, array( 'wp-color-picker' ), $current_version, $in_footer );
wp_add_inline_script(
'wp-color-picker-alpha',
'jQuery( function() { jQuery( ".color-picker" ).wpColorPicker(); } );'
);
wp_enqueue_script( 'wp-color-picker-alpha' );
Add class .color-picker
and data-alpha-enabled="true"
in input.
On previous versions of the 3.0.0 this script it starts automatically, but I have decided not to do it anymore.
data-alpha-reset:
For set Alpha Channel for disabled transparency after press color palette.
data-alpha-custom-width:
By default the input width is increased so that everything can be seen, with a value of 130 plus the original size.
For change default input width ( change the number you want, "in pixels" )
To disable this feature can also specify the value like "false" or "0".
data-alpha-color-type:
To set the type of color format; hex, rgb, hsl. Use the current or default color.
By default is rgb and if is hex change to rgba when the alpha channel is set. It also supports rgba, hsla and octo hexadecimal.
For limitations you must specify octohex as type when you want to use the hexadecimal format and the alpha channel.
data-alpha-skip-debounce:
Skip the debounce, when set the color inside of the input.
Set to true, to skip the debounce.
data-alpha-debounce-timeout:
Change the default timeout on debounce callback, by default is 100.
Licensed under the GPLv2 license or later.
If you would like to contribute please fork the project and report bugs or submit pull requests.
It was tested with Firefox and the WordPress 6.5.3 version.
For testing download or clone wp-color-picker-alpha-plugin inside WordPress plugins folder and activate.
The variable wpColorPickerL10n is used to check if it is earlier than version 4.9 and adjusts the content, only tested in 4.8.3 and 4.9-RC2-42156.
Initial Release