Support Forum
Hey guys!
Just updated to WordPress 5.5 and I got a error on JavaScript console on the ALPHA CHANNEL feature for COLOR PICKER. At first moment I did think it was related to the META BOX suite, however it is a general problem happening on many themes and plugins out there.
So, I would suggest you to address a fix within Meta Box internals, because other people could think same way as me and come here asking for help.
I understand it is a problem inside the COLOR PICKER code, but, anyway, I did fix it using this on my theme functions.php file:
if( is_admin() ){
add_action( 'wp_default_scripts', 'wp_default_custom_scripts' );
function wp_default_custom_scripts( $scripts ){
$scripts->add( 'wp-color-picker', "/wp-admin/js/color-picker.js", array( 'iris' ), false, 1 );
did_action( 'init' ) && $scripts->localize(
'wp-color-picker',
'wpColorPickerL10n',
array(
'clear' => __( 'Clear' ),
'clearAriaLabel' => __( 'Clear color' ),
'defaultString' => __( 'Default' ),
'defaultAriaLabel' => __( 'Select default color' ),
'pick' => __( 'Select Color' ),
'defaultLabel' => __( 'Color value' ),
)
);
}
}
Hi,
Meta Box uses WP Color Picker Alpha as a library as many themes/plugins. This issue has been noticed and the developer has created a pull request to fix it https://github.com/kallookoo/wp-color-picker-alpha/pull/38. We are waiting for this PR will be merged and update the new version of Meta Box.
Thanks for your code, it will help other users for temporary fixing.
Solved in the new version 5.3.4 of Meta Box, please update the plugin to fix this issue.
I still see a broken alpha color picker in the Customizer when using Meta Box 5.3.4. The color picker works fine in the regular WordPress admin, but not in the Customizer.
I added this to my functions.php
file to work around the issue:
if( is_customize_preview() ) {
add_action( 'wp_default_scripts', 'wp_default_custom_scripts' );
function wp_default_custom_scripts( $scripts ) {
$scripts->add( 'wp-color-picker', '/wp-admin/js/color-picker.js', array( 'iris' ), false, 1 );
did_action( 'init' ) && $scripts->localize(
'wp-color-picker',
'wpColorPickerL10n',
array(
'clear' => __( 'Clear' ),
'clearAriaLabel' => __( 'Clear color' ),
'defaultString' => __( 'Default' ),
'defaultAriaLabel' => __( 'Select default color' ),
'pick' => __( 'Select Color' ),
'defaultLabel' => __( 'Color value' ),
)
);
}
}