Created
October 21, 2015 12:00
-
-
Save annalinneajohansson/1d6e826b798e31f931d6 to your computer and use it in GitHub Desktop.
Adds client custom colors to WYSIWYG editor and ACF color picker. #wordpress
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
<?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