Dan*_*ani 5 wordpress color-picker colors picker
有没有办法自定义Wordpress 3.8颜色选择器(在自定义字段类型上)只使用我将定义的颜色?
我需要为客户端只有6种颜色,但他们不希望拥有所有这些颜色,除了6种渐变颜色.
对任何帮助都会很高兴...我已经尝试了几天,但没有积极的解决方案:(
谢谢
是,
Wordpress使用Iris颜色选择器,如果您将转到它的页面,您将看到所有方法和选项..
基本上,你添加这个:
palettes: ['#e5003d','#A6FF4C','#757584','#99CCFF','#00c1e8','#111111','#ECECFB']
Run Code Online (Sandbox Code Playgroud)
初始化对象时的选项
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']
});
Run Code Online (Sandbox Code Playgroud)
当然,如果您编写自己的自定义字段,那么所有这些.
如果你使用一些插件或类似的 - 它将取决于该插件机制..
如果您使用 TinyMCE 编辑器,您可以像这样修改调色板。
function my_mce4_options( $init ) {
$custom_colours = '
"e14d43", "Color 1 Name",
"d83131", "Color 2 Name",
"ed1c24", "Color 3 Name",
"f99b1c", "Color 4 Name",
"50b848", "Color 5 Name",
"00a859", "Color 6 Name"
';
$init['textcolor_map'] = '['.$custom_colours.']';
// Set number of color rows
$init['textcolor_rows'] = 3;
// Set number of color columns
$init['textcolor_cols'] = 2
return $init;
}
add_filter('tiny_mce_before_init', 'my_mce4_options');
Run Code Online (Sandbox Code Playgroud)