Skip to content

Instantly share code, notes, and snippets.

@annalinneajohansson
Created October 21, 2015 12:00
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save annalinneajohansson/1d6e826b798e31f931d6 to your computer and use it in GitHub Desktop.
Save annalinneajohansson/1d6e826b798e31f931d6 to your computer and use it in GitHub Desktop.
Adds client custom colors to WYSIWYG editor and ACF color picker. #wordpress
<?php
function change_acf_color_picker() {
$client_colors = array(
"#DD3333",
"#81D742",
"#1E73BE",
"#8224E3",
"#DD9933",
"#EEEE22"
);
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' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment