Add global custom palettes to your ACF Iris Wordpress Color Picker.
jQuery(document).ready(function($) {
if( acf.fields.color_picker ) {
// custom colors
var palette = ['#000000', '#333333', '#1D3278', '#E41E41', '#F1F1F1', '#FFFFFF'];
// when initially loaded find existing colorpickers and set the palette
acf.add_action('load', function() {
$('input.wp-color-picker').each(function() {
$(this).iris('option', 'palettes', palette);
});
});
// if appended element only modify the new element's palette
acf.add_action('append', function(el) {
$(el).find('input.wp-color-picker').iris('option', 'palettes', palette);
});
}
});
<?php
// CUSTOM ADMIN COLOR PALETTE
// Place BELOW the initial script and styles enqueue function
add_action( 'acf/input/admin_enqueue_scripts', function() {
wp_enqueue_script( 'acf-custom-colors', get_template_directory_uri() . '/library/js/color-picker.js', 'acf-input', '1.0', true );
});
?>