kallookoo / wp-color-picker-alpha

Overwrite Automattic Iris for enabled Alpha Channel in wpColorPicker
GNU General Public License v2.0
132 stars 88 forks source link

Version 3 not showing Color Picker #44

Closed neilgee closed 3 years ago

neilgee commented 3 years ago

I have been using wp-color-picker-alpha for various WordPress plugins settings, enqueuing the script and using like so...

function my_overlay_callback() {
$options = get_option( 'plugin_settings' );

if( !isset( $options['my_overlay'] ) ) $options['my_overlay'] = 'rgba(0,0,0,0.85)';

echo '<input type="text" class="color-picker" data-alpha="true" data-default-color="rgba(0,0,0,0.85)" name="plugin_settings[my_overlay]" value="' . sanitize_text_field($options['my_overlay']) . '"/>';
}

This gives me the color picker when selected.

wordpress-default-rgba-color

Since version 3 of the script the picker no longer shows - it just falls back to a text field for manual entry.

Screen Shot 2020-11-20 at 8 49 45 am

kallookoo commented 3 years ago

Hi @neilgee Read the Usage Now it is necessary to call it explicitly and I recommend using your own class to prevent other plugins or themes from modifying yours.

neilgee commented 3 years ago

Ok thanks, I have added data-alpha-enabled="true" to the input but picker still not displaying - I think its the inline script tripping me up, will look a bit more closely later.

neilgee commented 3 years ago

Have it sorted now - I already had a js file for the backend settings added $( ".color-picker" ).wpColorPicker(); to it, now works perfect - thanks