Customising Wordpress Color Picker

Dani picture Dani · Mar 8, 2014 · Viewed 10.3k times · Source

Is there any way to customize the Wordpress 3.8 color picker (on the custom field types) to use only colors i will define?

I need to have only 6 colors for a client, but they do not want to have all those colors, apart from 6 gradient colors.

Will be greatful for any help... I have been trying to do it for several days, but no positive solution:(

Thank you

Answer

Obmerk Kronen picture Obmerk Kronen · Mar 8, 2014

Wordpress 3.5+ uses the Iris colorpicker which has several options available for use.

When initializing the object just assign the palettes option with an array of colors.

var colorOptions = {
    // show a group of common colors beneath the square
    // or, supply an array of colors to customize further
    palettes: ['#4444,44','#ff2255','#559999','#99CCFF','#00c1e8','#F9DE0E','#111111','#EEEEDD']
};

jQuery('.my-color-picker-class').wpColorPicker(colorOptions);