Skip to content

Instantly share code, notes, and snippets.

@jonschr
Created January 15, 2019 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonschr/6d89238d84664e396c2d9b29d7959bfd to your computer and use it in GitHub Desktop.
Save jonschr/6d89238d84664e396c2d9b29d7959bfd to your computer and use it in GitHub Desktop.
Hooking into the ACF color picker and adding the colors
/**
* Add the colors into Iris
*/
add_action( 'acf/input/admin_footer', 'gutenberg_sections_register_acf_color_palette' );
function gutenberg_sections_register_acf_color_palette() {
$color_palette = output_the_colors();
if ( !$color_palette )
return;
?>
<script type="text/javascript">
(function( $ ) {
acf.add_filter( 'color_picker_args', function( args, $field ){
// add the hexadecimal codes here for the colors you want to appear as swatches
args.palettes = <?php echo $color_palette; ?>
// return colors
return args;
});
})(jQuery);
</script>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment