Home › Forums › Feature Requests › Customise Color Picker Swatches › Reply To: Customise Color Picker Swatches
Maybe this alternate solution is a little bit faster. It simply change the default option of the colorpicker when there are acf fields on the page.
function change_acf_color_picker() {
// Adds client custom colors to WYSIWYG editor and ACF color picker.
$client_colors = array(
"#222222",
"#8dc4d5",
"#e1523d",
"#eeeeee",
"#323232",
"#ffffff",
"#000000"
);
echo "<script>
(function($){
try {
$.wp.wpColorPicker.prototype.options = {
palettes: " . json_encode($client_colors) . "
};
}
catch (e) {}
})(jQuery)
</script>";
}
add_action( 'acf/input/admin_head', 'change_acf_color_picker' );
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.