Home › Forums › Feature Requests › Customise Color Picker Swatches › Reply To: Customise Color Picker Swatches
@Matthew McVickar has a great answer and it worked for me with minor modification. $parent_file has query parameters appended to it sometimes:
function load_javascript_on_admin_edit_post_page() {
global $parent_file;
// If we're on the edit post page.
if (
strpos($parent_file, 'post-new.php') !== -1 ||
strpos($parent_file, 'edit.php') !== -1 ||
strpos($parent_file, 'post.php') !== -1
) {
echo "
<script>
jQuery(document).ready(function(){
jQuery('.color_picker').iris({
palettes: ['#031649', '#FFF', '#CCC', '#999', '#666', '#333', '#000'],
change: function(event, ui){
jQuery(this).parents('.wp-picker-container').find('.wp-color-result').css('background-color', ui.color.toString());
}
});
});
</script>
";
}
}
add_action('in_admin_footer', 'load_javascript_on_admin_edit_post_page');
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.