Instantly share code, notes, and snippets.

@jonschr jonschr/functions.php
Last active Jan 25, 2019

Embed
What would you like to do?
Get theme colors into a usable format
/**
* Get the colors formatted for use with Iris, Automattic's color picker
*/
function output_the_colors() {
// get the colors
$color_palette = current( (array) get_theme_support( 'editor-color-palette' ) );
// bail if there aren't any colors found
if ( !$color_palette )
return;
// output begins
ob_start();
// output the names in a string
echo '[';
foreach ( $color_palette as $color ) {
echo "'" . $color['color'] . "', ";
}
echo ']';
return ob_get_clean();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment