Skip to content

Instantly share code, notes, and snippets.

@jasperf
Forked from simplethemes/scripts.php
Last active January 7, 2023 03:09
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 jasperf/4ae47bdf1b8f7b70f266cd28727464f8 to your computer and use it in GitHub Desktop.
Save jasperf/4ae47bdf1b8f7b70f266cd28727464f8 to your computer and use it in GitHub Desktop.
Customize the ACF color picker in your theme and have it load colors of your liking as swatches
<?php
/**
* Add brand color palette to acf color picker
* https://www.advancedcustomfields.com/resources/javascript-api/#filters-color_picker_args
*
*/
function kronos_acf_input_admin_footer() {
?>
<script type="text/javascript">
(function($) {
acf.add_filter('color_picker_args', function( args, $field ){
args.palettes = ["#000000","#CCCCCC","#EEEEEE","#FFFFFF","#b9ad33","#4c92af","#79c0a6"]
return args;
});
})(jQuery);
</script>
<?php }
add_action('acf/input/admin_footer', 'kronos_acf_input_admin_footer');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment