自定义Wordpress颜色选择器 [英] Customising Wordpress Color Picker

查看:314
本文介绍了自定义Wordpress颜色选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法自定义Wordpress 3.8颜色选择器(在自定义字段类型),以使用只有我会定义的颜色?

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

我需要只有6颜色为客户,但他们不想有所有的那些颜色,除了6渐变颜色。

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:(

谢谢

推荐答案

是的,

Wordpress使用 Iris colorpicker

Wordpress uses the Iris colorpicker , and if you will go to it´s page you will see all the methods and options ..

基本上,你添加了:

 palettes: ['#e5003d','#A6FF4C','#757584','#99CCFF','#00c1e8','#111111','#ECECFB']

到您的选项。

    jQuery('#my-ID .my-color-picker-class').each(function(){
        jQuery(this).wpColorPicker({
            // you can declare a default color here,
            // or in the data-default-color attribute on the input
            //defaultColor: false,

            // a callback to fire whenever the color changes to a valid color
            change: function(event, ui){},
            // a callback to fire when the input is emptied or an invalid color
            clear: function() {},
            // hide the color picker controls on load
            hide: true,
            // set  total width
            width : 200,
            // show a group of common colors beneath the square
            // or, supply an array of colors to customize further
            palettes: ['#444444','#ff2255','#559999','#99CCFF','#00c1e8','#F9DE0E','#111111','#EEEEDD']
        });

这当然是你自己编写的自定义字段..

All this of course if you code your own custom field..

如果你使用一些插件或类似 - 这将取决于插件机制..

If you use some plugin or such - It will depend on that plugin mechanism ..

这篇关于自定义Wordpress颜色选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆