Created
January 15, 2019 06:36
-
-
Save jonschr/6d89238d84664e396c2d9b29d7959bfd to your computer and use it in GitHub Desktop.
Hooking into the ACF color picker and adding the colors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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